Skip to content
Permalink
Browse files
Merge loops
  • Loading branch information
lbartoletti committed May 17, 2021
1 parent d3dac1c commit 9cac6d317988c7342da588059eae32a0d98b4797
Showing with 8 additions and 20 deletions.
  1. +8 −20 src/app/vertextool/qgsvertextool.cpp
@@ -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() );
}
}

0 comments on commit 9cac6d3

Please sign in to comment.