'Testing Distance() support on non-point geography fields.'

@skipUnlessDBFeature('has_Distance_function', 'supports_distance_geodetic')
def test_distance_function(self):

    if oracle:
        ref_dists = [0, 4899.68, 8081.3, 9115.15]
    elif spatialite:
        ref_dists = [326.61, 4899.68, 8081.3, 9115.15]
    else:
        ref_dists = [0, 4891.2, 8071.64, 9123.95]
    htown = City.objects.get(name='Houston')
    qs = Zipcode.objects.annotate(distance=Distance('poly', htown.point), distance2=Distance(htown.point, 'poly'))
    for (z, ref) in zip(qs, ref_dists):
        self.assertAlmostEqual(z.distance.m, ref, 2)
    if postgis:
        ref_dists = [0, 4899.68, 8081.3, 9115.15]
    for (z, ref) in zip(qs, ref_dists):
        self.assertAlmostEqual(z.distance2.m, ref, 2)
    if (not spatialite):
        hzip = Zipcode.objects.get(code='77002')
        self.assertEqual(qs.get(distance__lte=0), hzip)
