diff options
author | Niccolò Mineo <niccolo@20tab.com> | 2023-01-13 17:48:27 +0100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-01-20 08:13:43 +0100 |
commit | 79c298c9ceb8e386f172330236f04bb0ae4f7fdd (patch) | |
tree | 2b251b25196c27ab07e8e0bc84c34b7ea06903aa /tests/gis_tests | |
parent | 4b066bde692078b194709d517b27e55defae787c (diff) | |
download | django-79c298c9ceb8e386f172330236f04bb0ae4f7fdd.tar.gz |
Fixed #34266 -- Added ClosestPoint GIS database functions.
Diffstat (limited to 'tests/gis_tests')
-rw-r--r-- | tests/gis_tests/geoapp/test_functions.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py index 59b0410aca..e9e2a5dcae 100644 --- a/tests/gis_tests/geoapp/test_functions.py +++ b/tests/gis_tests/geoapp/test_functions.py @@ -456,6 +456,18 @@ class GISFunctionsTests(FuncTestMixin, TestCase): ): qs.get(area__lt=500000) + @skipUnlessDBFeature("has_ClosestPoint_function") + def test_closest_point(self): + qs = Country.objects.annotate( + closest_point=functions.ClosestPoint("mpoly", functions.Centroid("mpoly")) + ) + for country in qs: + self.assertIsInstance(country.closest_point, Point) + self.assertEqual( + country.mpoly.intersection(country.closest_point), + country.closest_point, + ) + @skipUnlessDBFeature("has_LineLocatePoint_function") def test_line_locate_point(self): pos_expr = functions.LineLocatePoint( |