1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #34266 -- Added ClosestPoint GIS database functions.

This commit is contained in:
Niccolò Mineo
2023-01-13 17:48:27 +01:00
committed by Mariusz Felisiak
parent 4b066bde69
commit 79c298c9ce
8 changed files with 42 additions and 5 deletions

View File

@@ -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(