Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PreparedPolygonContains for GeometryCollection with MultiPoint #1008

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/geom/prep/AbstractPreparedPolygonContains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
}

//
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/geom/prep/PreparedGeometryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading