Skip to content

Commit

Permalink
Use a better logic when building a rubber band model from a polygon g…
Browse files Browse the repository at this point in the history
…eometry
  • Loading branch information
nirvn committed Oct 22, 2023
1 parent 155d7bb commit fee6a6a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/core/rubberbandmodel.cpp
Expand Up @@ -333,17 +333,21 @@ void RubberbandModel::setDataFromGeometry( QgsGeometry geometry, const QgsCoordi
while ( abstractGeom->nextVertex( vertexId, pt ) )
{
if ( vertexId.part > 1 || vertexId.ring > 0 )
{
break;
}

// skip first vertex on polygon, as it's duplicate of the last one
if ( geometry.type() == Qgis::GeometryType::Polygon && vertexId.vertex == 0 )
// skip last vertex on polygon, as it's duplicate of the last one
if ( geometry.type() == Qgis::GeometryType::Polygon && vertexId.vertex == abstractGeom->vertexCount() )
{
continue;
}

mPointList << pt;
}
// insert the last point twice so the resutling rubberband's current coordinate property being modified (by e.g.
// the GNSS position) will not replace the last vertex from the passed geometry
mPointList << pt;
mPointList << mPointList.last();

mCurrentCoordinateIndex = mPointList.size() - 1;

Expand Down

0 comments on commit fee6a6a

Please sign in to comment.