[geos-commits] [SCM] GEOS branch main updated. 136e8e486f13e590da6096c196c49bc6ca272b2c

git at osgeo.org git at osgeo.org
Tue Dec 5 12:53:46 PST 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, main has been updated
       via  136e8e486f13e590da6096c196c49bc6ca272b2c (commit)
      from  b3d6d20a94fdbe6a8401d176668a6d7d76465673 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 136e8e486f13e590da6096c196c49bc6ca272b2c
Author: Martin Davis <mtnclimb at gmail.com>
Date:   Tue Dec 5 12:53:12 2023 -0800

    Fix PreparedPolygonContains for GC with MultiPoint (#1008)

diff --git a/src/geom/prep/AbstractPreparedPolygonContains.cpp b/src/geom/prep/AbstractPreparedPolygonContains.cpp
index cfc87436c..f0dbdeacc 100644
--- a/src/geom/prep/AbstractPreparedPolygonContains.cpp
+++ b/src/geom/prep/AbstractPreparedPolygonContains.cpp
@@ -186,7 +186,6 @@ bool AbstractPreparedPolygonContains::evalPointTestGeom(const Geometry *geom, Lo
     if (outermostLoc == Location::EXTERIOR) {
         return false;
     }
-
     // For the Covers predicate, we can return true
     // since no Points are on the exterior of the target
     // geometry.
@@ -195,19 +194,18 @@ bool AbstractPreparedPolygonContains::evalPointTestGeom(const Geometry *geom, Lo
     }
 
     // For the Contains predicate, we need to test if any
-    // of those points lie in the interior of the target
+    // of the test points lie in the interior of the target
     // geometry.
     if (outermostLoc == Location::INTERIOR) {
         return true;
     }
 
-    if (geom->getNumGeometries() > 1) {
-        // for MultiPoint, try to find at least one point
-        // in interior
-        return isAnyTestComponentInTargetInterior(geom);
+    // a single point must not be in interior
+    if (geom->getNumPoints() <= 1) {
+        return false;
     }
-
-    return false;
+    // for multiple points have to check all
+    return isAnyTestComponentInTargetInterior(geom);
 }
 
 //
diff --git a/tests/unit/geom/prep/PreparedGeometryTest.cpp b/tests/unit/geom/prep/PreparedGeometryTest.cpp
index ffdd90faf..c1df1abac 100644
--- a/tests/unit/geom/prep/PreparedGeometryTest.cpp
+++ b/tests/unit/geom/prep/PreparedGeometryTest.cpp
@@ -84,5 +84,19 @@ void object::test<2>
     ensure( pg1->intersects(g2.get()) );
 }
 
+// See https://github.com/libgeos/geos/issues/1007
+template<>
+template<>
+void object::test<3>
+()
+{
+    g1 = reader.read( "MULTIPOLYGON(((-60 -50,-70 -50,-60 -40,-60 -50)))" );
+    g2 = reader.read( "GEOMETRYCOLLECTION(MULTIPOINT((-60 -50),(-63 -49)))" );
+
+    pg1 = prep::PreparedGeometryFactory::prepare(g1.get());
+
+    ensure(  g1->contains(g2.get()) );
+    ensure( pg1->contains(g2.get()) );
+}
 
 } // namespace tut

-----------------------------------------------------------------------

Summary of changes:
 src/geom/prep/AbstractPreparedPolygonContains.cpp | 14 ++++++--------
 tests/unit/geom/prep/PreparedGeometryTest.cpp     | 14 ++++++++++++++
 2 files changed, 20 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list