Skip to content
Permalink
Browse files

remove M if provider does not have + relative test

  • Loading branch information
luipir committed Sep 26, 2017
1 parent a7e704e commit 6cd38fec49681ee03237a36e9923f356a47ab944
Showing with 22 additions and 0 deletions.
  1. +10 −0 src/core/qgsvectordataprovider.cpp
  2. +12 −0 tests/src/python/test_qgsvectorlayereditbuffer.py
@@ -724,6 +724,16 @@ QgsGeometry* QgsVectorDataProvider::convertToProviderType( const QgsGeometry* ge
outputGeom->dropZValue();
}

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

if ( outputGeom )
{
return new QgsGeometry( outputGeom );
@@ -150,6 +150,18 @@ def testAddFeatures(self):
f1.setAttributes(["test", 123])
self.assertFalse((layer.editBuffer().addFeatures([f1])))

# check is possibile to adapt M geom to NOT M provider type
layer = createEmptyLayer()
self.assertTrue(layer.startEditing())
self.assertEqual(layer.editBuffer().addedFeatures(), {})
geom = QgsGeometry.fromPoint(QgsPoint(1, 1))
geom.geometry().addMValue(1)
self.assertTrue(QgsWKBTypes.hasM(geom.geometry().wkbType()))
f1 = QgsFeature(layer.fields(), 1)
f1.setGeometry(geom)
f1.setAttributes(["test", 123])
self.assertTrue((layer.editBuffer().addFeatures([f1])))

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

0 comments on commit 6cd38fe

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