Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[postgres] Fix detection of 2.5D layer types
  • Loading branch information
Hugo Mercier committed Feb 9, 2016
1 parent 5f310a7 commit 2ebd26a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/qgsdatasourceuri.cpp
Expand Up @@ -543,7 +543,7 @@ QString QgsDataSourceURI::uri( bool expandAuthConfig ) const
if ( mWkbType != QGis::WKBUnknown && mWkbType != QGis::WKBNoGeometry )
{
theUri += " type=";
theUri += QgsWKBTypes::displayString( QgsWKBTypes::flatType(( QgsWKBTypes::Type( mWkbType ) ) ) );
theUri += QgsWKBTypes::displayString( QgsWKBTypes::Type( mWkbType ) );
}

if ( mSelectAtIdDisabled )
Expand Down
4 changes: 4 additions & 0 deletions src/providers/postgres/qgspostgresconn.cpp
Expand Up @@ -523,6 +523,10 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
layerProperty.tableName = tableName;
layerProperty.geometryColName = column;
layerProperty.geometryColType = columnType;
if ( dim == 3 && !type.endsWith( 'M' ) )
type += "Z";
else if ( dim == 4 )
type += "ZM";
layerProperty.types = QList<QGis::WkbType>() << ( QgsPostgresConn::wkbTypeFromPostgis( type ) );
layerProperty.srids = QList<int>() << srid;
layerProperty.sql = "";
Expand Down
6 changes: 6 additions & 0 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -2955,6 +2955,12 @@ bool QgsPostgresProvider::getGeometryDetails()
if ( result.PQntuples() == 1 )
{
detectedType = result.PQgetvalue( 0, 0 );
QString dim = result.PQgetvalue( 0, 2 );
if ( dim == "3" && !detectedType.endsWith( 'M' ) )
detectedType += "Z";
else if ( dim == "4" )
detectedType += "ZM";

detectedSrid = result.PQgetvalue( 0, 1 );
mSpatialColType = sctGeometry;
}
Expand Down

0 comments on commit 2ebd26a

Please sign in to comment.