Skip to content

Commit 2ebd26a

Browse files
author
Hugo Mercier
committed
[postgres] Fix detection of 2.5D layer types
1 parent 5f310a7 commit 2ebd26a

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/core/qgsdatasourceuri.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ QString QgsDataSourceURI::uri( bool expandAuthConfig ) const
543543
if ( mWkbType != QGis::WKBUnknown && mWkbType != QGis::WKBNoGeometry )
544544
{
545545
theUri += " type=";
546-
theUri += QgsWKBTypes::displayString( QgsWKBTypes::flatType(( QgsWKBTypes::Type( mWkbType ) ) ) );
546+
theUri += QgsWKBTypes::displayString( QgsWKBTypes::Type( mWkbType ) );
547547
}
548548

549549
if ( mSelectAtIdDisabled )

src/providers/postgres/qgspostgresconn.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,10 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
523523
layerProperty.tableName = tableName;
524524
layerProperty.geometryColName = column;
525525
layerProperty.geometryColType = columnType;
526+
if ( dim == 3 && !type.endsWith( 'M' ) )
527+
type += "Z";
528+
else if ( dim == 4 )
529+
type += "ZM";
526530
layerProperty.types = QList<QGis::WkbType>() << ( QgsPostgresConn::wkbTypeFromPostgis( type ) );
527531
layerProperty.srids = QList<int>() << srid;
528532
layerProperty.sql = "";

src/providers/postgres/qgspostgresprovider.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -2955,6 +2955,12 @@ bool QgsPostgresProvider::getGeometryDetails()
29552955
if ( result.PQntuples() == 1 )
29562956
{
29572957
detectedType = result.PQgetvalue( 0, 0 );
2958+
QString dim = result.PQgetvalue( 0, 2 );
2959+
if ( dim == "3" && !detectedType.endsWith( 'M' ) )
2960+
detectedType += "Z";
2961+
else if ( dim == "4" )
2962+
detectedType += "ZM";
2963+
29582964
detectedSrid = result.PQgetvalue( 0, 1 );
29592965
mSpatialColType = sctGeometry;
29602966
}

0 commit comments

Comments
 (0)