Skip to content

Commit

Permalink
ForceOrderPoints: fix interior ring order
Browse files Browse the repository at this point in the history
- Reverse interior ring order to be opposite of exterior ring
- Modify logic to operate on object reference instead of copy

Previously, the interior ring order was always identical to the exterior ring order,
which was incorrect. This fix ensures that the interior ring order is the inverse
of the exterior ring order, as required.

Additionally, the reversal operation was being performed on a copy of the object
rather than a reference, rendering it ineffective. This has been corrected to
operate on the actual object.

These changes should resolve issues #268
  • Loading branch information
lbartoletti committed Jul 11, 2024
1 parent 81fdf79 commit e5a0198
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/detail/transform/ForceOrderPoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,12 @@ ForceOrderPoints::visit(Polygon &p)
}
}

const bool isCCWO{algorithm::isCounterClockWiseOriented(ext)};
for (size_t i = 0; i < p.numInteriorRings(); ++i) {
LineString inter = p.interiorRingN(i);
LineString &inter = p.interiorRingN(i);

if (algorithm::isCounterClockWiseOriented(inter)) {
// interior ring is pointing up, reverse
if (_orientCCW) {
inter.reverse();
}
} else {
if (!_orientCCW) {
inter.reverse();
}
if (algorithm::isCounterClockWiseOriented(inter) == isCCWO) {
inter.reverse();
}
}

Expand Down

0 comments on commit e5a0198

Please sign in to comment.