Skip to content
Permalink
Browse files

added Z,M,ZM types to postgres output, allowed AddFeatures for layers…

… with measures
  • Loading branch information
blazek committed Jun 1, 2017
1 parent 90d2c92 commit e9a7dffb5a023cedd9ccba799a7d8544464dea1b
Showing with 27 additions and 21 deletions.
  1. +22 −19 src/providers/postgres/qgspostgresconn.cpp
  2. +5 −2 src/providers/postgres/qgspostgresprovider.cpp
@@ -1527,46 +1527,29 @@ void QgsPostgresConn::retrieveLayerTypes( QgsPostgresLayerProperty &layerPropert
void QgsPostgresConn::postgisWkbType( QgsWkbTypes::Type wkbType, QString &geometryType, int &dim )
{
dim = 2;
switch ( wkbType )
QgsWkbTypes::Type flatType = QgsWkbTypes::flatType( wkbType );
switch ( flatType )
{
case QgsWkbTypes::Point25D:
dim = 3;
FALLTHROUGH;
case QgsWkbTypes::Point:
geometryType = QStringLiteral( "POINT" );
break;

case QgsWkbTypes::LineString25D:
dim = 3;
FALLTHROUGH;
case QgsWkbTypes::LineString:
geometryType = QStringLiteral( "LINESTRING" );
break;

case QgsWkbTypes::Polygon25D:
dim = 3;
FALLTHROUGH;
case QgsWkbTypes::Polygon:
geometryType = QStringLiteral( "POLYGON" );
break;

case QgsWkbTypes::MultiPoint25D:
dim = 3;
FALLTHROUGH;
case QgsWkbTypes::MultiPoint:
geometryType = QStringLiteral( "MULTIPOINT" );
break;

case QgsWkbTypes::MultiLineString25D:
dim = 3;
FALLTHROUGH;
case QgsWkbTypes::MultiLineString:
geometryType = QStringLiteral( "MULTILINESTRING" );
break;

case QgsWkbTypes::MultiPolygon25D:
dim = 3;
FALLTHROUGH;
case QgsWkbTypes::MultiPolygon:
geometryType = QStringLiteral( "MULTIPOLYGON" );
break;
@@ -1580,6 +1563,26 @@ void QgsPostgresConn::postgisWkbType( QgsWkbTypes::Type wkbType, QString &geomet
dim = 0;
break;
}

if ( QgsWkbTypes::hasZ( wkbType ) && QgsWkbTypes::hasM( wkbType ) )
{
geometryType += "ZM";
dim = 4;
}
else if ( QgsWkbTypes::hasZ( wkbType ) )
{
geometryType += "Z";
dim = 3;
}
else if ( QgsWkbTypes::hasM( wkbType ) )
{
geometryType += "M";
dim = 3;
}
else if ( wkbType >= QgsWkbTypes::Point25D && wkbType <= QgsWkbTypes::MultiPolygon25D )
{
dim = 3;
}
}

QString QgsPostgresConn::postgisWkbTypeName( QgsWkbTypes::Type wkbType )
@@ -3539,8 +3539,11 @@ bool QgsPostgresProvider::getGeometryDetails()
{
// explicitly disable adding new features and editing of geometries
// as this would lead to corruption of measures
QgsMessageLog::logMessage( tr( "Editing and adding disabled for 2D+ layer (%1; %2)" ).arg( mGeometryColumn, mQuery ) );
mEnabledCapabilities &= ~( QgsVectorDataProvider::AddFeatures );

// Do not disable AddFeatures here, features are also added when copying layers. It should be user's

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson Jun 1, 2017

Collaborator

@blazek
I think we can safely remove this whole block - looking back through the history, it was originally added as a safeguard from long before QGIS had support for z/m dimensions.

This comment has been minimized.

Copy link
@blazek

blazek Jun 2, 2017

Author Member

Removed.

// when editing data with measure. If necessary, add a warning in editing UI.
//QgsMessageLog::logMessage( tr( "Editing and adding disabled for 2D+ layer (%1; %2)" ).arg( mGeometryColumn, mQuery ) );
//mEnabledCapabilities &= ~( QgsVectorDataProvider::AddFeatures );
}

QgsDebugMsg( QString( "Spatial column type is %1" ).arg( QgsPostgresConn::displayStringForGeomType( mSpatialColType ) ) );

0 comments on commit e9a7dff

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