The dispersion relation for planetary waves in the presence of mean flow and topography. Part I: analytical theory and one-dimensional examples