Skip to content
Permalink
Browse files

flat geom (remove Z) if provider is 2D and geom is 3D + test

  • Loading branch information
luipir committed Sep 26, 2017
1 parent 016363f commit 3264709f709264fda57bd22284414224c2a62d84
Showing with 18 additions and 4 deletions.
  1. +10 −0 src/core/qgsvectordataprovider.cpp
  2. +8 −4 tests/src/python/test_qgsvectorlayereditbuffer.py
@@ -714,6 +714,16 @@ QgsGeometry* QgsVectorDataProvider::convertToProviderType( const QgsGeometry* ge
outputGeom->addMValue();
}

// remove Z if provider does not have
if ( !QgsWKBTypes::hasZ( providerGeomType ) && QgsWKBTypes::hasZ( geometry->wkbType() ) )
{
if ( !outputGeom )
{
outputGeom = geometry->clone();
}
outputGeom->dropZValue();
}

if ( outputGeom )
{
return new QgsGeometry( outputGeom );
@@ -20,7 +20,9 @@
QgsFeature,
QgsGeometry,
QgsPoint,
QgsField)
QgsField,
QgsWKBTypes,
QGis)
from qgis.testing import start_app, unittest
start_app()

@@ -100,11 +102,13 @@ def testAddFeatures(self):
[QgsPoint(1, 1), QgsPoint(2, 2)],
[QgsPoint(3, 3), QgsPoint(4, 4)],
]
geom = QgsGeometry.fromMultiPolyline(multiline)
f1 = QgsFeature(layer.fields(), 1)
f1.setGeometry(QgsGeometry.fromMultiPolyline(multiline))
f1.setGeometry(geom)
f1.setAttributes(["test", 123])
self.assertFalse(layer.addFeatures([f1]))
# self.assertFalse(layer.commitChanges())

self.assertTrue(QgsWKBTypes.isMultiType(QGis.fromOldWkbType(geom.wkbType())))
self.assertFalse((layer.editBuffer().addFeatures([f1])))

def testAddMultipleFeatures(self):
# test adding multiple features to an edit buffer

0 comments on commit 3264709

Please sign in to comment.
You can’t perform that action at this time.