Skip to content
Permalink
Browse files

Improvements from review

  • Loading branch information
wonder-sk committed Apr 26, 2018
1 parent c4ef70e commit f2a2eeba7b76938e4f2a4b7046a6aed660605ee2
Showing with 8 additions and 3 deletions.
  1. +1 −1 src/app/qgsidentifyresultsdialog.h
  2. +1 −1 src/app/qgsmaptoolselectionhandler.h
  3. +6 −1 src/gui/qgsmaptoolidentify.cpp
@@ -256,7 +256,7 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
QList<QgsFeature> mFeatures;
QMap< QString, QMap< QString, QVariant > > mWidgetCaches;
QgsExpressionContextScope mExpressionContextScope;
QToolButton *mSelectModeButton;
QToolButton *mSelectModeButton = nullptr;

QgsMapLayer *layer( QTreeWidgetItem *item );
QgsVectorLayer *vectorLayer( QTreeWidgetItem *item );
@@ -180,7 +180,7 @@ class QgsMapToolSelectionHandler : public QObject
//! Whether a geometry is being picked right now
bool mSelectionActive = false;

SelectionMode mSelectionMode;
SelectionMode mSelectionMode = SelectSimple;

//! Snap indicator used in radius selection mode
std::unique_ptr<QgsSnapIndicator> mSnapIndicator;
@@ -20,6 +20,7 @@
#include "qgsfeaturestore.h"
#include "qgsfields.h"
#include "qgsgeometry.h"
#include "qgsgeometryengine.h"
#include "qgsidentifymenu.h"
#include "qgslogger.h"
#include "qgsmapcanvas.h"
@@ -252,6 +253,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QList<QgsMapToolIdentify::Identify
int featureCount = 0;

QgsFeatureList featureList;
std::unique_ptr<QgsGeometryEngine> selectionGeomPrepared;

// toLayerCoordinates will throw an exception for an 'invalid' point.
// For example, if you project a world map onto a globe using EPSG 2163
@@ -273,14 +275,17 @@ bool QgsMapToolIdentify::identifyVectorLayer( QList<QgsMapToolIdentify::Identify
QgsCoordinateTransform ct( mCanvas->mapSettings().destinationCrs(), layer->crs(), mCanvas->mapSettings().transformContext() );
if ( ct.isValid() )
selectionGeom.transform( ct );

// use prepared geometry for faster intersection test
selectionGeomPrepared.reset( QgsGeometry::createGeometryEngine( selectionGeom.constGet() ) );
}
}

QgsFeatureIterator fit = layer->getFeatures( QgsFeatureRequest().setFilterRect( r ).setFlags( QgsFeatureRequest::ExactIntersect ) );
QgsFeature f;
while ( fit.nextFeature( f ) )
{
if ( isPointOrRectangle || selectionGeom.intersects( f.geometry() ) )
if ( !selectionGeomPrepared || selectionGeomPrepared->intersects( f.geometry().constGet() ) )
featureList << QgsFeature( f );
}
}

0 comments on commit f2a2eeb

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