diff --git a/src/geom/Geometry.cpp b/src/geom/Geometry.cpp index 7d5f17c6f8..4339335870 100644 --- a/src/geom/Geometry.cpp +++ b/src/geom/Geometry.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -322,10 +323,19 @@ Geometry::intersects(const Geometry* g) const return predicate::RectangleIntersects::intersects(*p, *this); } + auto typ = getGeometryTypeId(); + if (typ == GEOS_CURVEPOLYGON && g->getGeometryTypeId() == GEOS_POINT) { + auto loc = locate::SimplePointInAreaLocator::locatePointInSurface(*g->getCoordinate(), *detail::down_cast(this)); + return loc != Location::EXTERIOR; + } else if (typ == GEOS_POINT && g->getGeometryTypeId() == GEOS_CURVEPOLYGON) { + auto loc = locate::SimplePointInAreaLocator::locatePointInSurface(*getCoordinate(), *detail::down_cast(g)); + return loc != Location::EXTERIOR; + } + #if USE_RELATENG return operation::relateng::RelateNG::intersects(this, g); #else - if (getGeometryTypeId() == GEOS_GEOMETRYCOLLECTION) { + if (typ == GEOS_GEOMETRYCOLLECTION) { auto im = relate(g); bool res = im->isIntersects(); return res; diff --git a/tests/unit/capi/GEOSIntersectsTest.cpp b/tests/unit/capi/GEOSIntersectsTest.cpp index 395d2698ca..b86d8c282c 100644 --- a/tests/unit/capi/GEOSIntersectsTest.cpp +++ b/tests/unit/capi/GEOSIntersectsTest.cpp @@ -234,5 +234,30 @@ void object::test<11>() ensure_equals("curved geometry not supported", GEOSIntersects(geom2_, geom1_), 2); } +// test PIP special case for CurvePolygon +template<> +template<> +void object::test<12>() +{ + geom1_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE(CIRCULARSTRING(0 0, 1 1, 2 0), (2 0, 0 0)))"); + geom2_ = fromWKT("POINT (0.1556955 0.5355459)"); + + // PostGIS would return false here because geom2 is inside geom1 + // but outside the linearized form of geom1 + ensure_equals(GEOSIntersects(geom1_, geom2_), 1); + ensure_equals(GEOSIntersects(geom2_, geom1_), 1); +} + +template<> +template<> +void object::test<13>() +{ + geom1_ = fromWKT("CURVEPOLYGON (COMPOUNDCURVE(CIRCULARSTRING(0 0, 1 1, 2 0), (2 0, 0 0)))"); + geom2_ = fromWKT("POINT EMPTY"); + + ensure_equals(GEOSIntersects(geom1_, geom2_), 0); + ensure_equals(GEOSIntersects(geom2_, geom1_), 0); +} + } // namespace tut