Skip to content

Commit

Permalink
Merge loops
Browse files Browse the repository at this point in the history
  • Loading branch information
lbartoletti committed May 17, 2021
1 parent d3dac1c commit 9cac6d3
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/app/vertextool/qgsvertextool.cpp
Expand Up @@ -2174,42 +2174,30 @@ void QgsVertexTool::moveVertex( const QgsPointXY &mapPoint, const QgsPointLocato

applyEditsToLayers( edits );

if ( QgsProject::instance()->topologicalEditing() && ( mapPointMatch->hasEdge() || mapPointMatch->hasMiddleSegment() ) && mapPointMatch->layer() )
if ( QgsProject::instance()->topologicalEditing() )
{
// topo editing: add vertex to existing segments when moving/adding a vertex to such segment.
// this requires that the snapping match is to a segment and the segment layer's CRS
// is the same (otherwise we would need to reproject the point and it will not be coincident)
const auto editKeys = edits.keys();
for ( QgsVectorLayer *layer : editKeys )
{
if ( layer->crs() == mapPointMatch->layer()->crs() )
const auto editGeom = edits[layer].values();
for ( QgsGeometry g : editGeom )
{
const auto editGeom = edits[layer].values();
for ( QgsGeometry g : editGeom )
QgsGeometry p = QgsGeometry::fromPointXY( QgsPointXY( layerPoint.x(), layerPoint.y() ) );
QgsGeometry pts = g.convertToType( QgsWkbTypes::PointGeometry, true );
if ( ( mapPointMatch->hasEdge() || mapPointMatch->hasMiddleSegment() ) && mapPointMatch->layer() && ( layer->crs() == mapPointMatch->layer()->crs() ) )
{
QgsGeometry p = QgsGeometry::fromPointXY( QgsPointXY( layerPoint.x(), layerPoint.y() ) );
if ( g.convertToType( QgsWkbTypes::PointGeometry, true ).contains( p ) )
if ( pts.contains( p ) )
{
if ( !layerPoint.is3D() )
layerPoint.addZValue( defaultZValue() );
layer->addTopologicalPoints( layerPoint );
mapPointMatch->layer()->addTopologicalPoints( layerPoint );
}
}
}
}
}

if ( QgsProject::instance()->topologicalEditing() && QgsProject::instance()->avoidIntersectionsMode() != QgsProject::AvoidIntersectionsMode::AllowIntersections )
{
const auto editKeys = edits.keys();
for ( QgsVectorLayer *layer : editKeys )
{
const auto editGeom = edits[layer].values();
for ( QgsGeometry g : editGeom )
{
QgsGeometry pts = g.convertToType( QgsWkbTypes::PointGeometry, true );
for ( const auto &p : pts.asMultiPoint() )
if ( QgsProject::instance()->avoidIntersectionsMode() != QgsProject::AvoidIntersectionsMode::AllowIntersections )
QgsMapToolEdit::addTopologicalPoints( pts.asMultiPoint() );
}
}
Expand Down

0 comments on commit 9cac6d3

Please sign in to comment.