Skip to content

Commit

Permalink
Use ST_MakeEnvelope with PostGIS 2.0+ to build query rectangle
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandro Santilli authored and jef-n committed Jan 10, 2012
1 parent 9a50005 commit 302c1a7
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/providers/postgres/qgspostgresprovider.cpp 100644 → 100755
Expand Up @@ -537,10 +537,22 @@ void QgsPostgresProvider::select( QgsAttributeList fetchAttributes, QgsRectangle

if ( whereClause.isEmpty() )
{
QString qBox = QString( "%1('BOX3D(%2)'::box3d,%3)" )
.arg( mConnectionRO->majorVersion() < 2 ? "setsrid" : "st_setsrid" )
.arg( rect.asWktCoordinates() )
.arg( mDetectedSrid );
QString qBox;
if ( mConnectionRO->majorVersion() < 2 )
{
qBox = QString( "setsrid('BOX3D(%1)'::box3d,%2)" )
.arg( rect.asWktCoordinates() )
.arg( mDetectedSrid );
}
else
{
qBox = QString( "st_makeenvelope(%1,%2,%3,%4,%5)" )
.arg( rect.xMinimum() )
.arg( rect.yMinimum() )
.arg( rect.xMaximum() )
.arg( rect.yMaximum() )
.arg( mDetectedSrid );
}

whereClause = QString( "%1 && %2" )
.arg( quotedIdentifier( mGeometryColumn ) )
Expand Down

0 comments on commit 302c1a7

Please sign in to comment.