Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release-3_0] Use a better logic when building a rubber band model from a polygon geometry #4678

Merged
merged 1 commit into from
Oct 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/core/rubberbandmodel.cpp
Original file line number Diff line number Diff line change
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
Loading