Hamiltonian structure for drift waves and geostrophic flow