Skip to content

Commit a5f51f7

Browse files
committed
Fix LineString->getPoint(n) for M geometries (closes GH-1191)
2 parents fa08715 + 3c648f2 commit a5f51f7

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
- Fix ConcaveHullOfPolygons nested shell handling (GH-1169, Martin Davis)
66
- Fix RelateNG for computing IM for empty-nonempty cases (Martin Davis)
77
- Fix LineString->getPoint(n) for M geometries (GH-1191, @hsieyuan)
8+
- Fix TopologyPreservingSimplifier/TaggedLineString to avoid jumping components (JTS-1096, Martin Davis)
9+
810

911
## Changes in 3.13.0
1012
2024-09-06

cmake/cmake_uninstall.cmake.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ foreach(file ${files})
3131
endif()
3232

3333
execute_process(
34-
COMMAND "@CMAKE_COMMAND@" -E remove \"$ENV{DESTDIR}${file}\"
34+
COMMAND "@CMAKE_COMMAND@" -E remove "$ENV{DESTDIR}${file}"
3535
OUTPUT_VARIABLE rm_out
3636
RESULT_VARIABLE rm_retval)
3737

@@ -43,7 +43,7 @@ endforeach()
4343

4444
message(STATUS "Deleting ${GEOS_INCLUDE_DIR} directory")
4545
execute_process(
46-
COMMAND "@CMAKE_COMMAND@" -E remove_directory \"${GEOS_INCLUDE_DIR}\"
46+
COMMAND "@CMAKE_COMMAND@" -E remove_directory "${GEOS_INCLUDE_DIR}"
4747
OUTPUT_VARIABLE rm_out
4848
RESULT_VARIABLE rm_retval)
4949

src/simplify/TaggedLineString.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ TaggedLineString::extractCoordinates(
169169

170170
if(size) {
171171
for(std::size_t i = 0; i < size; i++) {
172-
TaggedLineSegment* seg = segs[i];
172+
TaggedLineSegment* seg = segs[i];
173173
assert(seg);
174174
pts->add(seg->p0);
175175
}
@@ -185,7 +185,6 @@ TaggedLineString::extractCoordinates(
185185
const Coordinate&
186186
TaggedLineString::getCoordinate(std::size_t i) const
187187
{
188-
189188
return parentLine->getCoordinateN(i);
190189
}
191190

@@ -198,6 +197,10 @@ TaggedLineString::size() const
198197
const Coordinate&
199198
TaggedLineString::getComponentPoint() const
200199
{
200+
//-- when simplified use a valid coordinate
201+
if (resultSegs.size() > 0) {
202+
return resultSegs[0]->p0;
203+
}
201204
return getParentCoordinates()->getAt(1);
202205
}
203206

tests/unit/simplify/TopologyPreservingSimplifierTest.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,5 +442,15 @@ void object::test<34>()
442442
ensure(simplified != nullptr); // no crash
443443
}
444444

445+
//-- test from https://github.com/libgeos/geos/issues/1190
446+
// testPolygonJumping
447+
template<>
448+
template<>
449+
void object::test<35>()
450+
{
451+
checkTPS("MULTIPOLYGON (((689.333567 5733.539399, 689.335754 5733.534616, 689.338414 5733.528808, 689.33878 5733.528007, 689.339295 5733.526884, 689.343502 5733.53001, 689.364663 5733.545752, 689.376307 5733.554418, 689.390955 5733.565421, 689.401872 5733.573364, 689.449408 5733.60852, 689.449575 5733.609988, 689.448713 5733.61218, 689.450278 5733.61347, 689.452433 5733.614861, 689.46186 5733.617409, 689.455824 5733.632539, 689.45904 5733.635609, 689.458981 5733.646089, 689.447304 5733.646901, 689.434534 5733.647491, 689.40922 5733.642907, 689.320546 5733.620868, 689.302885 5733.61643, 689.301333 5733.616007, 689.300102 5733.615673, 689.30643 5733.600999, 689.310466 5733.59152, 689.318738 5733.572875, 689.321855 5733.565499, 689.326805 5733.554307, 689.331263 5733.544428, 689.333567 5733.539399)), ((689.488158 5733.746304, 689.48107 5733.739996, 689.48063 5733.740474, 689.471494 5733.732342, 689.466433 5733.727847, 689.447733 5733.712239, 689.437049 5733.709591, 689.41159 5733.702871, 689.378682 5733.693749, 689.326133 5733.678786, 689.295154 5733.685694, 689.287831 5733.686429, 689.286696 5733.686462, 689.276607 5733.686729, 689.260516 5733.685316, 689.23796 5733.680098, 689.242448 5733.667716, 689.254068 5733.635631, 689.258549 5733.623249, 689.258994 5733.622025, 689.250964 5733.620168, 689.253227 5733.613915, 689.275563 5733.619278, 689.296484 5733.624484, 689.390817 5733.647146, 689.390653 5733.651596, 689.453214 5733.669852, 689.456439 5733.665903, 689.460803 5733.666259, 689.464728 5733.671599, 689.467162 5733.67151, 689.540893 5733.636477, 689.558474 5733.626375, 689.571555 5733.61169, 689.606543 5733.552572, 689.611314 5733.553806, 689.635373 5733.569048, 689.64516 5733.573331, 689.679568 5733.588383, 689.673051 5733.603569, 689.688729 5733.608809, 689.674072 5733.643497, 689.683092 5733.646634, 689.673195 5733.672489, 689.645333 5733.669085, 689.635065 5733.690144, 689.62618 5733.712606, 689.601513 5733.71146, 689.592455 5733.71255, 689.586614 5733.714174, 689.580087 5733.717612, 689.570186 5733.725689, 689.557792 5733.763414, 689.55541 5733.762513, 689.554633 5733.762213, 689.547236 5733.765316, 689.545484 5733.767219, 689.506862 5733.759554, 689.491458 5733.748451, 689.488158 5733.746304)))",
452+
0.1,
453+
"MULTIPOLYGON (((689.300102 5733.615673, 689.46186 5733.617409, 689.458981 5733.646089, 689.300102 5733.615673)), ((689.488158 5733.746304, 689.23796 5733.680098, 689.253227 5733.613915, 689.467162 5733.67151, 689.679568 5733.588383, 689.488158 5733.746304)))");
454+
}
445455

446456
} // namespace tut

0 commit comments

Comments
 (0)