mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-07 00:15:48 -04:00
added intersect option to select to properly select features during select and identify operations. OGR does not support intersects so this is only implemented in the postgres provider
git-svn-id: http://svn.osgeo.org/qgis/trunk@739 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
d5d2c6ab03
commit
80f901f76c
@ -178,7 +178,7 @@ QgsFeature *QgsShapeFileProvider::getNextFeature(bool fetchAttributes)
|
||||
* with calls to getFirstFeature and getNextFeature.
|
||||
* @param mbr QgsRect containing the extent to use in selecting features
|
||||
*/
|
||||
void QgsShapeFileProvider::select(QgsRect *rect)
|
||||
void QgsShapeFileProvider::select(QgsRect *rect, bool useIntersect)
|
||||
{
|
||||
// spatial query to select features
|
||||
// std::cerr << "Selection rectangle is " << *rect << std::endl;
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
* with calls to getFirstFeature and getNextFeature.
|
||||
* @param mbr QgsRect containing the extent to use in selecting features
|
||||
*/
|
||||
void select(QgsRect *mbr);
|
||||
void select(QgsRect *mbr, bool useIntersect=false);
|
||||
/**
|
||||
* Set the data source specification. This may be a path or database
|
||||
* connection string
|
||||
|
@ -367,18 +367,26 @@ QgsFeature *QgsPostgresProvider::getNextFeature(bool fetchAttributes)
|
||||
* with calls to getFirstFeature and getNextFeature.
|
||||
* @param mbr QgsRect containing the extent to use in selecting features
|
||||
*/
|
||||
void QgsPostgresProvider::select(QgsRect * rect)
|
||||
void QgsPostgresProvider::select(QgsRect * rect, bool useIntersect)
|
||||
{
|
||||
// spatial query to select features
|
||||
//--std::cout << "Selection rectangle is " << *rect << std::endl;
|
||||
QString declare = QString("declare qgisf binary cursor for select "
|
||||
+ primaryKey
|
||||
+ ",asbinary(%1,'%2') as qgs_feature_geometry from %3").arg(geometryColumn).arg(endianString()).arg(tableName);
|
||||
if(useIntersect){
|
||||
declare += " where intersects(" + geometryColumn;
|
||||
declare += ", GeometryFromText('BOX3D(" + rect->stringRep();
|
||||
declare += ")'::box3d,";
|
||||
declare += srid;
|
||||
declare += "))";
|
||||
}else{
|
||||
declare += " where " + geometryColumn;
|
||||
declare += " && GeometryFromText('BOX3D(" + rect->stringRep();
|
||||
declare += ")'::box3d,";
|
||||
declare += srid;
|
||||
declare += ")";
|
||||
}
|
||||
//--std::cout << "Selecting features using: " << declare << std::endl;
|
||||
// set up the cursor
|
||||
if(ready){
|
||||
|
@ -78,7 +78,7 @@ class QgsPostgresProvider:public QgsDataProvider
|
||||
* with calls to getFirstFeature and getNextFeature.
|
||||
* @param mbr QgsRect containing the extent to use in selecting features
|
||||
*/
|
||||
void select(QgsRect * mbr);
|
||||
void select(QgsRect * mbr, bool useIntersect=false);
|
||||
/**
|
||||
* Set the data source specification. This must be a valid database
|
||||
* connection string:
|
||||
|
@ -56,10 +56,15 @@ public:
|
||||
virtual int fieldCount()=0;
|
||||
/**
|
||||
* Select features based on a bounding rectangle. Features can be retrieved
|
||||
* with calls to getFirstFeature and getNextFeature.
|
||||
* with calls to getFirstFeature and getNextFeature. Request for features
|
||||
* for use in drawing the map canvas should set useIntersect to false.
|
||||
* @param mbr QgsRect containing the extent to use in selecting features
|
||||
* @param useIntersect If true, use the intersects function to select features
|
||||
* rather than the PostGIS && operator that selects based on bounding box
|
||||
* overlap.
|
||||
*
|
||||
*/
|
||||
virtual void QgsDataProvider::select(QgsRect *mbr)=0;
|
||||
virtual void QgsDataProvider::select(QgsRect *mbr, bool useIntersect=false)=0;
|
||||
/**
|
||||
* Set the data source specification. This may be a path or database
|
||||
* connection string
|
||||
|
@ -500,7 +500,7 @@ int QgsVectorLayer::endian()
|
||||
void QgsVectorLayer::identify(QgsRect * r)
|
||||
{
|
||||
QApplication::setOverrideCursor(Qt::waitCursor);
|
||||
dataProvider->select(r);
|
||||
dataProvider->select(r,true);
|
||||
int featureCount = 0;
|
||||
QgsFeature *fet;
|
||||
unsigned char *feature;
|
||||
@ -633,7 +633,7 @@ void QgsVectorLayer::select(QgsRect * rect, bool lock)
|
||||
}
|
||||
}
|
||||
|
||||
dataProvider->select(rect);
|
||||
dataProvider->select(rect, true);
|
||||
|
||||
QgsFeature* fet;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user