Skip to content

Commit

Permalink
Fix DiscreteHausdorffDistance for LinearRing (#1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts authored Nov 22, 2023
1 parent 301bc46 commit 4286a70
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
8 changes: 0 additions & 8 deletions include/geos/algorithm/distance/DiscreteHausdorffDistance.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,11 @@
#endif

namespace geos {
namespace algorithm {
//class RayCrossingCounter;
}
namespace geom {
class Geometry;
class Coordinate;
//class CoordinateSequence;
}
namespace index {
namespace intervalrtree {
//class SortedPackedIntervalRTree;
}
}
}

namespace geos {
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/distance/DistanceToPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ DistanceToPoint::computeDistance(const geom::Geometry& geom,
return;
}

if(geom.getGeometryTypeId() == GEOS_LINESTRING) {
if(geom.getGeometryTypeId() == GEOS_LINESTRING || geom.getGeometryTypeId() == GEOS_LINEARRING) {
const LineString* ls = static_cast<const LineString*>(&geom);
computeDistance(*ls, pt, ptDist);
}
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/algorithm/distance/DiscreteHausdorffDistanceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,16 @@ void object::test<7>
DiscreteHausdorffDistance::distance(*g2, *g3));
}

// see https://github.com/libgeos/geos/issues/987
template<>
template<>
void object::test<8>
()
{
runTest("LINEARRING (0 0, 0 10, 10 10, 10 0, 0 0)",
"LINEARRING (1 1, 1 9, 8 8, 9 1, 1 1)",
2.8284271247461903);
}

} // namespace tut

0 comments on commit 4286a70

Please sign in to comment.