mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #15165 -- Prevented wrong results with perimeter on geodetic fields.
This commit is contained in:
parent
e051930123
commit
00cb9e13b4
4 changed files with 35 additions and 7 deletions
|
@ -444,6 +444,8 @@ Distance_Sphere(geom1, geom2) | N/A | OK (meter
|
|||
|
||||
Distance_Spheroid(geom1, geom2, spheroid) | N/A | OK (meters) | N/A
|
||||
|
||||
ST_Perimeter(geom1) | OK | :-( (degrees) | OK
|
||||
|
||||
|
||||
================================
|
||||
Distance functions on Spatialite
|
||||
|
@ -457,6 +459,8 @@ ST_Distance(geom1, geom2, use_ellipsoid=True) | N/A | OK (
|
|||
|
||||
ST_Distance(geom1, geom2, use_ellipsoid=False) | N/A | OK (meters), less accurate, quick
|
||||
|
||||
Perimeter(geom1) | OK | :-( (degrees)
|
||||
|
||||
''' # NOQA
|
||||
|
||||
|
||||
|
@ -688,6 +692,20 @@ class DistanceFunctionsTests(TestCase):
|
|||
for city in qs:
|
||||
self.assertEqual(0, city.perim.m)
|
||||
|
||||
@skipUnlessDBFeature("has_Perimeter_function")
|
||||
def test_perimeter_geodetic(self):
|
||||
# Currently only Oracle supports calculating the perimeter on geodetic
|
||||
# geometries (without being transformed).
|
||||
qs1 = CensusZipcode.objects.annotate(perim=Perimeter('poly'))
|
||||
if connection.features.supports_perimeter_geodetic:
|
||||
self.assertAlmostEqual(qs1[0].perim.m, 18406.3818954314, 3)
|
||||
else:
|
||||
with self.assertRaises(NotImplementedError):
|
||||
list(qs1)
|
||||
# But should work fine when transformed to projected coordinates
|
||||
qs2 = CensusZipcode.objects.annotate(perim=Perimeter(Transform('poly', 32140))).filter(name='77002')
|
||||
self.assertAlmostEqual(qs2[0].perim.m, 18404.355, 3)
|
||||
|
||||
@skipUnlessDBFeature("supports_null_geometries", "has_Area_function", "has_Distance_function")
|
||||
def test_measurement_null_fields(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue