Skip to content
Permalink
Browse files

[postgis] Fix creation of new Z/M enabled, curved geometry type layers

  • Loading branch information
nyalldawson committed Feb 12, 2019
1 parent 2e20f13 commit 07746dbc0e5b34e31e85e944fc6f53113721a696
Showing with 41 additions and 1 deletion.
  1. +41 −1 src/providers/postgres/qgspostgresprovider.cpp
@@ -3760,6 +3760,46 @@ bool QgsPostgresProvider::convertField( QgsField &field, const QMap<QString, QVa
return true;
}


void postgisGeometryType( QgsWkbTypes::Type wkbType, QString &geometryType, int &dim )
{
dim = 2;
QgsWkbTypes::Type flatType = QgsWkbTypes::flatType( wkbType );
geometryType = QgsWkbTypes::displayString( flatType ).toUpper();
switch ( flatType )
{
case QgsWkbTypes::Unknown:
geometryType = QStringLiteral( "GEOMETRY" );
break;

case QgsWkbTypes::NoGeometry:
geometryType.clear();
dim = 0;
break;

default:
break;
}

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

QgsVectorLayerExporter::ExportError QgsPostgresProvider::createEmptyLayer( const QString &uri,
const QgsFields &fields,
QgsWkbTypes::Type wkbType,
@@ -3944,7 +3984,7 @@ QgsVectorLayerExporter::ExportError QgsPostgresProvider::createEmptyLayer( const
int dim = 2;
long srid = srs.postgisSrid();

QgsPostgresConn::postgisWkbType( wkbType, geometryType, dim );
postgisGeometryType( wkbType, geometryType, dim );

// create geometry column
if ( !geometryType.isEmpty() )

0 comments on commit 07746db

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