Skip to content
Permalink
Browse files

Use ST_MakeEnvelope with PostGIS 2.0+ to build query rectangle

  • Loading branch information
Sandro Santilli authored and jef-n committed Jan 10, 2012
1 parent 9a50005 commit 302c1a7ebb8c3c6f45b4ad0a71fe394a8cd9760f
Showing with 16 additions and 4 deletions.
  1. +16 −4 src/providers/postgres/qgspostgresprovider.cpp
@@ -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 ) )

0 comments on commit 302c1a7

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