Skip to content

Commit f2a2eeb

Browse files
committed
Improvements from review
1 parent c4ef70e commit f2a2eeb

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/app/qgsidentifyresultsdialog.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
256256
QList<QgsFeature> mFeatures;
257257
QMap< QString, QMap< QString, QVariant > > mWidgetCaches;
258258
QgsExpressionContextScope mExpressionContextScope;
259-
QToolButton *mSelectModeButton;
259+
QToolButton *mSelectModeButton = nullptr;
260260

261261
QgsMapLayer *layer( QTreeWidgetItem *item );
262262
QgsVectorLayer *vectorLayer( QTreeWidgetItem *item );

src/app/qgsmaptoolselectionhandler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class QgsMapToolSelectionHandler : public QObject
180180
//! Whether a geometry is being picked right now
181181
bool mSelectionActive = false;
182182

183-
SelectionMode mSelectionMode;
183+
SelectionMode mSelectionMode = SelectSimple;
184184

185185
//! Snap indicator used in radius selection mode
186186
std::unique_ptr<QgsSnapIndicator> mSnapIndicator;

src/gui/qgsmaptoolidentify.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "qgsfeaturestore.h"
2121
#include "qgsfields.h"
2222
#include "qgsgeometry.h"
23+
#include "qgsgeometryengine.h"
2324
#include "qgsidentifymenu.h"
2425
#include "qgslogger.h"
2526
#include "qgsmapcanvas.h"
@@ -252,6 +253,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QList<QgsMapToolIdentify::Identify
252253
int featureCount = 0;
253254

254255
QgsFeatureList featureList;
256+
std::unique_ptr<QgsGeometryEngine> selectionGeomPrepared;
255257

256258
// toLayerCoordinates will throw an exception for an 'invalid' point.
257259
// For example, if you project a world map onto a globe using EPSG 2163
@@ -273,14 +275,17 @@ bool QgsMapToolIdentify::identifyVectorLayer( QList<QgsMapToolIdentify::Identify
273275
QgsCoordinateTransform ct( mCanvas->mapSettings().destinationCrs(), layer->crs(), mCanvas->mapSettings().transformContext() );
274276
if ( ct.isValid() )
275277
selectionGeom.transform( ct );
278+
279+
// use prepared geometry for faster intersection test
280+
selectionGeomPrepared.reset( QgsGeometry::createGeometryEngine( selectionGeom.constGet() ) );
276281
}
277282
}
278283

279284
QgsFeatureIterator fit = layer->getFeatures( QgsFeatureRequest().setFilterRect( r ).setFlags( QgsFeatureRequest::ExactIntersect ) );
280285
QgsFeature f;
281286
while ( fit.nextFeature( f ) )
282287
{
283-
if ( isPointOrRectangle || selectionGeom.intersects( f.geometry() ) )
288+
if ( !selectionGeomPrepared || selectionGeomPrepared->intersects( f.geometry().constGet() ) )
284289
featureList << QgsFeature( f );
285290
}
286291
}

0 commit comments

Comments
 (0)