Skip to content
Permalink
Browse files

Merge pull request #6870 from m-kuhn/offlineediting_zm

[FEATURE] Offline editing support for Z and M coordinates
  • Loading branch information
m-kuhn committed Apr 28, 2018
2 parents c1552e7 + fb14214 commit 4aaa652dce3f1cba00e34cde60ffceb6685fa5bb
Showing with 26 additions and 10 deletions.
  1. +26 −10 src/core/qgsofflineediting.cpp
@@ -48,10 +48,6 @@ extern "C"
#include <spatialite.h>
}

// TODO: DEBUG
#include <QDebug>
// END

#define CUSTOM_PROPERTY_IS_OFFLINE_EDITABLE "isOfflineEditable"
#define CUSTOM_PROPERTY_REMOTE_SOURCE "remoteSource"
#define CUSTOM_PROPERTY_REMOTE_PROVIDER "remoteProvider"
@@ -518,8 +514,10 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
// add geometry column
if ( layer->isSpatial() )
{
const QgsWkbTypes::Type sourceWkbType = layer->wkbType();

QString geomType;
switch ( layer->wkbType() )
switch ( QgsWkbTypes::flatType( sourceWkbType ) )
{
case QgsWkbTypes::Point:
geomType = QStringLiteral( "POINT" );
@@ -540,13 +538,31 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
geomType = QStringLiteral( "MULTIPOLYGON" );
break;
default:
showWarning( tr( "QGIS wkbType %1 not supported" ).arg( layer->wkbType() ) );
showWarning( tr( "Layer %1 has unsupported geometry type %2." ).arg( layer->name(), QgsWkbTypes::displayString( layer->wkbType() ) ) );
break;
};
QString sqlAddGeom = QStringLiteral( "SELECT AddGeometryColumn('%1', 'Geometry', %2, '%3', 2)" )
.arg( tableName )
.arg( layer->crs().authid().startsWith( QLatin1String( "EPSG:" ), Qt::CaseInsensitive ) ? layer->crs().authid().mid( 5 ).toLong() : 0 )
.arg( geomType );

QString zmInfo = QStringLiteral( "XY" );

if ( QgsWkbTypes::hasZ( sourceWkbType ) )
zmInfo += 'Z';
if ( QgsWkbTypes::hasM( sourceWkbType ) )
zmInfo += 'M';

QString epsgCode;

if ( layer->crs().authid().startsWith( QLatin1String( "EPSG:" ), Qt::CaseInsensitive ) )
{
epsgCode = layer->crs().authid().mid( 5 );
}
else
{
epsgCode = '0';
showWarning( tr( "Layer %1 has unsupported Coordinate Reference System (%2)." ).arg( layer->name(), layer->crs().authid() ) );
}

QString sqlAddGeom = QStringLiteral( "SELECT AddGeometryColumn('%1', 'Geometry', %2, '%3', '%4')" )
.arg( tableName, epsgCode, geomType, zmInfo );

// create spatial index
QString sqlCreateIndex = QStringLiteral( "SELECT CreateSpatialIndex('%1', 'Geometry')" ).arg( tableName );

0 comments on commit 4aaa652

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