diff --git a/src/algorithm/construct/IndexedDistanceToPoint.cpp b/src/algorithm/construct/IndexedDistanceToPoint.cpp index 92c703ef81..e1fd585718 100644 --- a/src/algorithm/construct/IndexedDistanceToPoint.cpp +++ b/src/algorithm/construct/IndexedDistanceToPoint.cpp @@ -36,7 +36,7 @@ IndexedDistanceToPoint::IndexedDistanceToPoint(const Geometry& geom) void IndexedDistanceToPoint::init() { if (facetDistance != nullptr) - return; + return; ptLocator.reset(new IndexedPointInPolygonsLocator(targetGeometry)); facetDistance.reset(new IndexedFacetDistance(&targetGeometry)); } @@ -62,7 +62,8 @@ bool IndexedDistanceToPoint::isInArea(const Point& pt) std::unique_ptr IndexedDistanceToPoint::nearestPoints(const Point& pt) { + init(); return facetDistance->nearestPoints(&pt); } -}}} \ No newline at end of file +}}} diff --git a/tests/unit/algorithm/construct/LargestEmptyCircleTest.cpp b/tests/unit/algorithm/construct/LargestEmptyCircleTest.cpp index b0110fa0f9..5a09e2ef88 100644 --- a/tests/unit/algorithm/construct/LargestEmptyCircleTest.cpp +++ b/tests/unit/algorithm/construct/LargestEmptyCircleTest.cpp @@ -316,4 +316,30 @@ void object::test<19>() 0.01, 5.5, 4.5, 2.12 ); } + +// https://trac.osgeo.org/postgis/ticket/5626 +template<> +template<> +void object::test<20>() +{ + checkCircle( + "POINT(-11 40)", // input + "POLYGON((-71.1 42.3,-71.1 42.4,-71.2 42.3,-71.1 42.3))", // boundary + 0.1, // test tolerance + -71.15, 42.34, 60.19588 ); // expected x, y, radius +} + + +// https://trac.osgeo.org/postgis/ticket/5626 +template<> +template<> +void object::test<21>() +{ + checkCircle( + "POINT(-11.1111111 40)", // input + "POLYGON((-71.0821 42.3036,-71.0821 42.3936,-71.0901 42.3036,-71.0821 42.3036))", // boundary + 1, // test tolerance + -71.15, 42.34, 60.19588 ); // expected x, y, radius +} + } // namespace tut