mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Simplify generation of SQL query for selecting features in a box.
This is propedeutic to upcoming changes related to boxes in PostGIS 2.0
This commit is contained in:
parent
cbf63027db
commit
7ef04f69ca
@ -1326,24 +1326,21 @@ void QgsPostgresProvider::select( QgsAttributeList fetchAttributes, QgsRectangle
|
||||
|
||||
if ( whereClause.isEmpty() )
|
||||
{
|
||||
QString qBox = QString( "%1('BOX3D(%2)'::box3d,%3)" )
|
||||
.arg( connectionRO->majorVersion() < 2 ? "setsrid"
|
||||
: "st_setsrid" )
|
||||
.arg( rect.asWktCoordinates() )
|
||||
.arg( srid );
|
||||
whereClause = QString( "%1 && %2" )
|
||||
.arg( quotedIdentifier( geometryColumn ) )
|
||||
.arg( qBox );
|
||||
if ( useIntersect )
|
||||
{
|
||||
// Contributed by #qgis irc "creeping"
|
||||
// This version actually invokes PostGIS's use of spatial indexes
|
||||
whereClause = QString( "%1 && %2('BOX3D(%3)'::box3d,%4) and %5(%1,%2('BOX3D(%3)'::box3d,%4))" )
|
||||
whereClause += QString( " and %1(%2,%3))" )
|
||||
.arg( connectionRO->majorVersion() < 2 ? "intersects"
|
||||
: "st_intersects" )
|
||||
.arg( quotedIdentifier( geometryColumn ) )
|
||||
.arg( connectionRO->majorVersion() < 2 ? "setsrid" : "st_setsrid" )
|
||||
.arg( rect.asWktCoordinates() )
|
||||
.arg( srid )
|
||||
.arg( connectionRO->majorVersion() < 2 ? "intersects" : "st_intersects" );
|
||||
}
|
||||
else
|
||||
{
|
||||
whereClause = QString( "%1 && %2('BOX3D(%3)'::box3d,%4)" )
|
||||
.arg( quotedIdentifier( geometryColumn ) )
|
||||
.arg( connectionRO->majorVersion() < 2 ? "setsrid" : "st_setsrid" )
|
||||
.arg( rect.asWktCoordinates() )
|
||||
.arg( srid );
|
||||
.arg( qBox );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user