Skip to content

Commit 302c1a7

Browse files
Sandro Santillijef-n
Sandro Santilli
authored andcommittedJan 10, 2012
Use ST_MakeEnvelope with PostGIS 2.0+ to build query rectangle
1 parent 9a50005 commit 302c1a7

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed
 

‎src/providers/postgres/qgspostgresprovider.cpp

100644100755
Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,22 @@ void QgsPostgresProvider::select( QgsAttributeList fetchAttributes, QgsRectangle
537537

538538
if ( whereClause.isEmpty() )
539539
{
540-
QString qBox = QString( "%1('BOX3D(%2)'::box3d,%3)" )
541-
.arg( mConnectionRO->majorVersion() < 2 ? "setsrid" : "st_setsrid" )
542-
.arg( rect.asWktCoordinates() )
543-
.arg( mDetectedSrid );
540+
QString qBox;
541+
if ( mConnectionRO->majorVersion() < 2 )
542+
{
543+
qBox = QString( "setsrid('BOX3D(%1)'::box3d,%2)" )
544+
.arg( rect.asWktCoordinates() )
545+
.arg( mDetectedSrid );
546+
}
547+
else
548+
{
549+
qBox = QString( "st_makeenvelope(%1,%2,%3,%4,%5)" )
550+
.arg( rect.xMinimum() )
551+
.arg( rect.yMinimum() )
552+
.arg( rect.xMaximum() )
553+
.arg( rect.yMaximum() )
554+
.arg( mDetectedSrid );
555+
}
544556

545557
whereClause = QString( "%1 && %2" )
546558
.arg( quotedIdentifier( mGeometryColumn ) )

0 commit comments

Comments
 (0)
Please sign in to comment.