Skip to content

Commit

Permalink
Fix LineString->getPoint(n) for M geometries (closes GH-1191)
Browse files Browse the repository at this point in the history
  • Loading branch information
pramsey committed Nov 15, 2024
2 parents fa08715 + 3c648f2 commit a5f51f7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- Fix ConcaveHullOfPolygons nested shell handling (GH-1169, Martin Davis)
- Fix RelateNG for computing IM for empty-nonempty cases (Martin Davis)
- Fix LineString->getPoint(n) for M geometries (GH-1191, @hsieyuan)
- Fix TopologyPreservingSimplifier/TaggedLineString to avoid jumping components (JTS-1096, Martin Davis)


## Changes in 3.13.0
2024-09-06
Expand Down
4 changes: 2 additions & 2 deletions cmake/cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ foreach(file ${files})
endif()

execute_process(
COMMAND "@CMAKE_COMMAND@" -E remove \"$ENV{DESTDIR}${file}\"
COMMAND "@CMAKE_COMMAND@" -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval)

Expand All @@ -43,7 +43,7 @@ endforeach()

message(STATUS "Deleting ${GEOS_INCLUDE_DIR} directory")
execute_process(
COMMAND "@CMAKE_COMMAND@" -E remove_directory \"${GEOS_INCLUDE_DIR}\"
COMMAND "@CMAKE_COMMAND@" -E remove_directory "${GEOS_INCLUDE_DIR}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval)

Expand Down
7 changes: 5 additions & 2 deletions src/simplify/TaggedLineString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -185,7 +185,6 @@ TaggedLineString::extractCoordinates(
const Coordinate&
TaggedLineString::getCoordinate(std::size_t i) const
{

return parentLine->getCoordinateN(i);
}

Expand All @@ -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);
}

Expand Down
10 changes: 10 additions & 0 deletions tests/unit/simplify/TopologyPreservingSimplifierTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,5 +442,15 @@ void object::test<34>()
ensure(simplified != nullptr); // no crash
}

//-- test from https://github.com/libgeos/geos/issues/1190
// testPolygonJumping
template<>
template<>
void object::test<35>()
{
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)))",
0.1,
"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)))");
}

} // namespace tut

0 comments on commit a5f51f7

Please # to comment.