Skip to content

Commit

Permalink
Add vertical transform test which doesn't require grid files
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 12, 2024
1 parent d6f2b78 commit 87fad86
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/src/python/test_qgsfeatureiterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,45 @@ def callback(feature):
self.assertEqual(res, ['a', 'b'])
layer.rollBack()

def test_vertical_transformation_4978_to_4979(self):
"""
Test vertical transformations are correctly handled during iteration
EPSG:4978 to EPSG:4979
"""

vl = QgsVectorLayer('PointZ?crs=EPSG:4978', 'gda2020points', 'memory')
self.assertTrue(vl.isValid())
self.assertEqual(vl.crs().authid(), 'EPSG:4978')

self.assertEqual(vl.crs3D().horizontalCrs().authid(), 'EPSG:4978')

f = QgsFeature()
f.setGeometry(QgsPoint(134.445567853,
-23.445567853,
5543.325))
self.assertTrue(vl.dataProvider().addFeature(f))

dest_crs = QgsCoordinateReferenceSystem('EPSG:4979')
self.assertTrue(dest_crs.isValid())
self.assertEqual(dest_crs.horizontalCrs().authid(), 'EPSG:4979')

transform = QgsCoordinateTransform(
vl.crs3D(),
dest_crs,
QgsCoordinateTransformContext()
)

request = QgsFeatureRequest().setCoordinateTransform(
transform)

transformed_features = list(vl.getFeatures(request))
self.assertEqual(len(transformed_features), 1)
geom = transformed_features[0].geometry()
self.assertAlmostEqual(geom.constGet().x(), -9.8921668708, 4)
self.assertAlmostEqual(geom.constGet().y(), 89.839008, 4)
self.assertAlmostEqual(geom.constGet().z(), -6351023.00373, 3)

def test_vertical_transformation_gda2020_to_AVWS(self):
"""
Test vertical transformations are correctly handled during iteration
Expand Down

0 comments on commit 87fad86

Please sign in to comment.