Skip to content

Commit bf66e0f

Browse files
m-kuhn3nids
authored andcommitted
Offline editing: support for flattening Z and M layers.
1 parent 5ddc536 commit bf66e0f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/core/qgsofflineediting.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ QgsVectorLayer* QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlit
525525
if ( layer->hasGeometryType() )
526526
{
527527
QString geomType = "";
528-
switch ( layer->wkbType() )
528+
switch ( QGis::flatType( layer->wkbType() ) )
529529
{
530530
case QGis::WKBPoint:
531531
geomType = "POINT";
@@ -549,6 +549,10 @@ QgsVectorLayer* QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlit
549549
showWarning( tr( "QGIS wkbType %1 not supported" ).arg( layer->wkbType() ) );
550550
break;
551551
};
552+
553+
if ( QGis::flatType( layer->wkbType() ) != layer->wkbType() )
554+
showWarning( tr( "Will drop Z and M values from layer %1 in offline copy." ).arg( layer->name() ) );
555+
552556
QString sqlAddGeom = QString( "SELECT AddGeometryColumn('%1', 'Geometry', %2, '%3', 2)" )
553557
.arg( tableName )
554558
.arg( layer->crs().authid().startsWith( "EPSG:", Qt::CaseInsensitive ) ? layer->crs().authid().mid( 5 ).toLong() : 0 )
@@ -670,6 +674,15 @@ QgsVectorLayer* QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlit
670674
}
671675
f.setAttributes( newAttrs );
672676

677+
// The spatialite provider doesn't properly handle Z and M values
678+
if ( f.geometry() && f.geometry()->geometry() )
679+
{
680+
QgsAbstractGeometryV2* geom = f.geometry()->geometry()->clone();
681+
geom->dropZValue();
682+
geom->dropMValue();
683+
f.geometry()->setGeometry( geom );
684+
}
685+
673686
newLayer->addFeature( f, false );
674687

675688
emit progressUpdated( featureCount++ );

0 commit comments

Comments
 (0)