summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrancisco Couzo <franciscouzo@gmail.com>2019-03-20 13:54:42 -0300
committerTim Graham <timograham@gmail.com>2019-03-20 12:54:42 -0400
commit0193bf874f08f21cdec628b8d80d261471bfe5fc (patch)
treee095cbff7cd8c6a0abf98f2378f1d99747daa5dc /tests
parent638d5ea37557a668f59d76bb34ee4e076787b524 (diff)
Fixed #28738 -- Added the GeometryDistance function.
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/geoapp/test_functions.py15
1 files changed, 15 insertions, 0 deletions
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)