From 0193bf874f08f21cdec628b8d80d261471bfe5fc Mon Sep 17 00:00:00 2001 From: Francisco Couzo Date: Wed, 20 Mar 2019 13:54:42 -0300 Subject: Fixed #28738 -- Added the GeometryDistance function. --- tests/gis_tests/geoapp/test_functions.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py index 817e0b2611..4f8cc9e712 100644 --- a/tests/gis_tests/geoapp/test_functions.py +++ b/tests/gis_tests/geoapp/test_functions.py @@ -240,6 +240,21 @@ class GISFunctionsTests(FuncTestMixin, TestCase): self.assertEqual(ref_hash, h1.geohash[:len(ref_hash)]) self.assertEqual(ref_hash[:5], h2.geohash) + @skipUnlessDBFeature('has_GeometryDistance_function') + def test_geometry_distance(self): + point = Point(-90, 40, srid=4326) + qs = City.objects.annotate(distance=functions.GeometryDistance('point', point)).order_by('distance') + self.assertEqual([city.distance for city in qs], [ + 2.99091995527296, + 5.33507274054713, + 9.33852187483721, + 9.91769193646233, + 11.556465744884, + 14.713098433352, + 34.3635252198568, + 276.987855073372, + ]) + @skipUnlessDBFeature("has_Intersection_function") def test_intersection(self): geom = Point(5, 23, srid=4326) -- cgit v1.3