We've got this function internally, and I just thought it might be useful for people trying to build general purpose query generators (OK, I snarked at geodjango but without knowing whether the srid is geography or not it's hard for them I'd imagine)