diff --git a/NEWS.md b/NEWS.md index 877845bbba..40af8671bb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,7 @@ - GEOSLineSubstring, avoid crash with NaN length fraction (GH-1077, Dan Baston) - MinimumClearance, avoid crash on NaN inputs (GH-1079, Dan Baston) - Fix LineString->getPoint(n) for M geometries (GH-1191, @hsieyuan) + - Fix TopologyPreservingSimplifier/TaggedLineString to avoid jumping components (JTS-1096, Martin Davis) ## Changes in 3.12.2 diff --git a/src/simplify/TaggedLineString.cpp b/src/simplify/TaggedLineString.cpp index e0dc40ddbf..9a6d09324d 100644 --- a/src/simplify/TaggedLineString.cpp +++ b/src/simplify/TaggedLineString.cpp @@ -169,7 +169,7 @@ TaggedLineString::extractCoordinates( if(size) { for(std::size_t i = 0; i < size; i++) { - TaggedLineSegment* seg = segs[i]; + TaggedLineSegment* seg = segs[i]; assert(seg); pts->add(seg->p0); } @@ -185,7 +185,6 @@ TaggedLineString::extractCoordinates( const Coordinate& TaggedLineString::getCoordinate(std::size_t i) const { - return parentLine->getCoordinateN(i); } @@ -198,6 +197,10 @@ TaggedLineString::size() const const Coordinate& TaggedLineString::getComponentPoint() const { + //-- when simplified use a valid coordinate + if (resultSegs.size() > 0) { + return resultSegs[0]->p0; + } return getParentCoordinates()->getAt(1); }