Skip to content

Commit 7701ea6

Browse files
committed
[delete part] use snapping index to find part
1 parent 42908eb commit 7701ea6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/app/qgsmaptooldeletepart.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,17 @@ QgsGeometry QgsMapToolDeletePart::partUnderPoint( QPoint point, QgsFeatureId &fi
160160
}
161161
case QgsWkbTypes::PolygonGeometry:
162162
{
163-
QgsPointXY layerCoords = toLayerCoordinates( vlayer, point );
164-
double searchRadius = QgsTolerance::vertexSearchRadius( mCanvas->currentLayer(), mCanvas->mapSettings() );
165-
QgsRectangle selectRect( layerCoords.x() - searchRadius, layerCoords.y() - searchRadius,
166-
layerCoords.x() + searchRadius, layerCoords.y() + searchRadius );
167-
QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFilterRect( selectRect ) );
168-
fit.nextFeature( f );
163+
QgsPointLocator::Match match = mCanvas->snappingUtils()->snapToCurrentLayer( point, QgsPointLocator::Area );
164+
if ( !match.isValid() )
165+
return geomPart;
166+
167+
vlayer->getFeatures( QgsFeatureRequest().setFilterFid( match.featureId() ) ).nextFeature( f );
169168
QgsGeometry g = f.geometry();
170169
if ( g.isNull() )
171170
return geomPart;
171+
172+
QgsPointXY layerCoords = toLayerCoordinates( vlayer, point );
173+
172174
if ( !g.isMultipart() )
173175
{
174176
fid = f.id();

0 commit comments

Comments
 (0)