Skip to content
Permalink
Browse files
add test for dxf 3d
  • Loading branch information
vcloarec authored and github-actions committed Nov 18, 2021
1 parent fe77663 commit 90551e7dc3b6f33766bd823ec6aba4bab1046d6e
Showing with 1,614 additions and 0 deletions.
  1. +38 −0 tests/src/python/test_provider_ogr.py
  2. +1,576 −0 tests/testdata/points_lines_3d.dxf
@@ -1730,6 +1730,14 @@ def test_provider_sublayer_details(self):
self.assertEqual(res[0].geometryColumnName(), '')
self.assertEqual(res[0].driverName(), 'ESRI Shapefile')

# check a feature
vl = res[0].toLayer(options)
self.assertTrue(vl.isValid())
feature = next(vl.getFeatures())
self.assertEqual(feature.geometry().wkbType(), QgsWkbTypes.MultiPolygonZ)
self.assertEqual(feature.geometry().asWkt(), 'MultiPolygonZ (((0 0 0, 0 1 0, 1 1 0, 0 0 0)),((0 0 0, 1 1 0, 1 0 0,'
' 0 0 0)),((0 0 0, 0 -1 0, 1 -1 0, 0 0 0)),((0 0 0, 1 -1 0, 1 0 0, 0 0 0)))')

# single layer geopackage -- sublayers MUST have the layerName set on the uri,
# in case more layers are added in future to the gpkg
res = metadata.querySublayers(os.path.join(TEST_DATA_DIR, 'curved_polys.gpkg'))
@@ -2463,6 +2471,36 @@ def test_provider_feature_iterator_options(self):
f = vl.getFeature(2)
self.assertEqual(f.geometry().asWkt(), 'Point (2 2)')

def test_provider_dxf_3d(self):
"""Test issue GH #45938"""

metadata = QgsProviderRegistry.instance().providerMetadata('ogr')
layers = metadata.querySublayers(os.path.join(TEST_DATA_DIR, 'points_lines_3d.dxf'),
Qgis.SublayerQueryFlag.ResolveGeometryType)

options = QgsProviderSublayerDetails.LayerOptions(QgsCoordinateTransformContext())

for ld in layers:
if ld.wkbType() == QgsWkbTypes.PointZ:
point_layer = ld.toLayer(options)
if ld.wkbType() == QgsWkbTypes.LineStringZ:
polyline_layer = ld.toLayer(options)

self.assertTrue(point_layer.isValid())
self.assertEqual(point_layer.featureCount(), 11)
feature = next(point_layer.getFeatures())
self.assertTrue(feature.isValid())
self.assertEqual(feature.geometry().wkbType(), QgsWkbTypes.Point25D)
self.assertEqual(feature.geometry().asWkt(),
'PointZ (635660.10747100005391985 1768912.79759799991734326 3.36980799999999991)')

self.assertTrue(polyline_layer.isValid())
self.assertEqual(polyline_layer.featureCount(), 2)
feature = next(polyline_layer.getFeatures())
self.assertTrue(feature.isValid())
self.assertEqual(feature.geometry().wkbType(), QgsWkbTypes.LineString25D)
self.assertEqual(feature.geometry().vertexAt(1).asWkt(),
'PointZ (635660.11699699994642287 1768910.93880999996326864 3.33884099999999995)')

if __name__ == '__main__':
unittest.main()
Loading

0 comments on commit 90551e7

Please sign in to comment.