summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-03-23 09:16:33 +0100
committerGitHub <noreply@github.com>2021-03-23 09:16:33 +0100
commit2cd40263348a9c345a58c44d48922ac3b370a119 (patch)
tree0c80a631ea69793ed5c2f559697144576ad8789b
parent71ec102b01fcc85acae3819426a4e02ef423b0fa (diff)
Refs #32353, Refs #32352 -- Fixed GIS tests with PROJ 7.X.
Different PROJ versions use different transformations, all are correct as having a 1 meter accuracy. These are differences in PROJ versions that cannot and should not be handled in Django itself. Thanks Jani Tiainen and David Smith for reports. See: https://github.com/OSGeo/gdal/issues/3377
-rw-r--r--tests/gis_tests/gdal_tests/test_geom.py8
-rw-r--r--tests/gis_tests/geoapp/test_serializers.py9
-rw-r--r--tests/gis_tests/geos_tests/test_geos.py4
-rw-r--r--tests/gis_tests/test_geoforms.py4
4 files changed, 17 insertions, 8 deletions
diff --git a/tests/gis_tests/gdal_tests/test_geom.py b/tests/gis_tests/gdal_tests/test_geom.py
index d25627221d..a9571d583f 100644
--- a/tests/gis_tests/gdal_tests/test_geom.py
+++ b/tests/gis_tests/gdal_tests/test_geom.py
@@ -350,7 +350,9 @@ class OGRGeomTest(SimpleTestCase, TestDataMixin):
self.assertEqual(k1, orig)
self.assertNotEqual(k1, k2)
- prec = 3
+ # Different PROJ versions use different transformations, all are
+ # correct as having a 1 meter accuracy.
+ prec = -1
for p in (t1, t2, t3, k2):
self.assertAlmostEqual(trans.x, p.x, prec)
self.assertAlmostEqual(trans.y, p.y, prec)
@@ -360,7 +362,9 @@ class OGRGeomTest(SimpleTestCase, TestDataMixin):
ls_orig = OGRGeometry('LINESTRING(-104.609 38.255)', 4326)
ls_trans = OGRGeometry('LINESTRING(992385.4472045 481455.4944650)', 2774)
- prec = 3
+ # Different PROJ versions use different transformations, all are
+ # correct as having a 1 meter accuracy.
+ prec = -1
ls_orig.transform(ls_trans.srs)
# Making sure the coordinate dimension is still 2D.
self.assertEqual(2, ls_orig.coord_dim)
diff --git a/tests/gis_tests/geoapp/test_serializers.py b/tests/gis_tests/geoapp/test_serializers.py
index 4ec99c5de6..6d4b959026 100644
--- a/tests/gis_tests/geoapp/test_serializers.py
+++ b/tests/gis_tests/geoapp/test_serializers.py
@@ -77,10 +77,11 @@ class GeoJSONSerializerTests(TestCase):
def test_srid_option(self):
geojson = serializers.serialize('geojson', City.objects.all().order_by('name'), srid=2847)
geodata = json.loads(geojson)
- self.assertEqual(
- [int(c) for c in geodata['features'][0]['geometry']['coordinates']],
- [1564802, 5613214]
- )
+ coordinates = geodata['features'][0]['geometry']['coordinates']
+ # Different PROJ versions use different transformations, all are
+ # correct as having a 1 meter accuracy.
+ self.assertAlmostEqual(coordinates[0], 1564802, -1)
+ self.assertAlmostEqual(coordinates[1], 5613214, -1)
def test_deserialization_exception(self):
"""
diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py
index ca493c87f1..552ec8396d 100644
--- a/tests/gis_tests/geos_tests/test_geos.py
+++ b/tests/gis_tests/geos_tests/test_geos.py
@@ -1140,7 +1140,9 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
self.assertEqual(k1, orig)
self.assertNotEqual(k1, k2)
- prec = 3
+ # Different PROJ versions use different transformations, all are
+ # correct as having a 1 meter accuracy.
+ prec = -1
for p in (t1, t2, t3, k2):
self.assertAlmostEqual(trans.x, p.x, prec)
self.assertAlmostEqual(trans.y, p.y, prec)
diff --git a/tests/gis_tests/test_geoforms.py b/tests/gis_tests/test_geoforms.py
index 93cf5be20b..4768d9b39e 100644
--- a/tests/gis_tests/test_geoforms.py
+++ b/tests/gis_tests/test_geoforms.py
@@ -28,7 +28,9 @@ class GeometryFieldTest(SimpleTestCase):
# Making the field in a different SRID from that of the geometry, and
# asserting it transforms.
fld = forms.GeometryField(srid=32140)
- tol = 0.0001
+ # Different PROJ versions use different transformations, all are
+ # correct as having a 1 meter accuracy.
+ tol = 1
xform_geom = GEOSGeometry('POINT (951640.547328465 4219369.26171664)', srid=32140)
# The cleaned geometry is transformed to 32140 (the widget map_srid is 3857).
cleaned_geom = fld.clean('SRID=3857;POINT (-10615777.40976205 3473169.895707852)')