Skip to content
Permalink
Browse files

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

(cherry picked from commit 07746db)
  • Loading branch information
nyalldawson committed Feb 12, 2019
1 parent 05dd5f1 commit a61abe5bb3b4c1b633f2f76b69a7f274abeb33d3
Showing with 41 additions and 1 deletion.
  1. +41 −1 src/providers/postgres/qgspostgresprovider.cpp
@@ -3769,6 +3769,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,
@@ -3953,7 +3993,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 a61abe5

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