Skip to content

Commit

Permalink
Detect number of dimensions for tables with unconstrained type
Browse files Browse the repository at this point in the history
Fixes #9748

(cherry picked from commit f512e87)
  • Loading branch information
Sandro Santilli committed Mar 3, 2015
1 parent ffaa498 commit 3d6554e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/providers/postgres/qgspostgresconn.cpp
Expand Up @@ -1298,6 +1298,12 @@ void QgsPostgresConn::retrieveLayerTypes( QgsPostgresLayerProperty &layerPropert
query += QString::number( srid );
}

query += ",";
query += QString( "%1(%2%3)" )
.arg( majorVersion() < 2 ? "ndims" : "st_ndims" )
.arg( quotedIdentifier( layerProperty.geometryColName ) )
.arg( layerProperty.geometryColType == sctGeography ? "::geometry" : "" );

query += " FROM " + table;

//QgsDebugMsg( "Retrieving geometry types: " + query );
Expand All @@ -1310,6 +1316,10 @@ void QgsPostgresConn::retrieveLayerTypes( QgsPostgresLayerProperty &layerPropert
{
QString type = gresult.PQgetvalue( i, 0 );
QString srid = gresult.PQgetvalue( i, 1 );
QString ndims = gresult.PQgetvalue( i, 2 );

if ( ndims.toInt() > 2 ) layerProperty.force2d = true;

if ( type.isEmpty() )
continue;

Expand Down

0 comments on commit 3d6554e

Please sign in to comment.