Skip to content

Commit

Permalink
Fix copy/pasting of features to/from the same layer ignores avoid ove…
Browse files Browse the repository at this point in the history
…rlap settings
  • Loading branch information
nirvn committed Oct 25, 2023
1 parent 7b2d4a9 commit 3ebf437
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10202,6 +10202,37 @@ void QgisApp::pasteFromClipboard( QgsMapLayer *destinationLayer )
if ( duplicateFeature )
{
pastedFeatures = features;

for ( auto &feature : pastedFeatures )
{
QgsGeometry geom = feature.geometry();

if ( !( geom.isEmpty() || geom.isNull( ) ) )
{
// avoid intersection if enabled in digitize settings
QList<QgsVectorLayer *> avoidIntersectionsLayers;
switch ( QgsProject::instance()->avoidIntersectionsMode() )
{
case Qgis::AvoidIntersectionsMode::AvoidIntersectionsCurrentLayer:
avoidIntersectionsLayers.append( pasteVectorLayer );
break;
case Qgis::AvoidIntersectionsMode::AvoidIntersectionsLayers:
avoidIntersectionsLayers = QgsProject::instance()->avoidIntersectionsLayers();
break;
case Qgis::AvoidIntersectionsMode::AllowIntersections:
break;
}
if ( avoidIntersectionsLayers.size() > 0 )
{
geom.avoidIntersectionsV2( avoidIntersectionsLayers );
feature.setGeometry( geom );
}

// count collapsed geometries
if ( geom.isEmpty() || geom.isNull( ) )
invalidGeometriesCount++;
}
}
}
else
{
Expand Down

0 comments on commit 3ebf437

Please sign in to comment.