Skip to content

Commit

Permalink
Fix overlay op regression with mixed GeometryCollection on 3.9 branch (
Browse files Browse the repository at this point in the history
…#1050)

* Fix overlay op regression with mixed GeometryCollection on 3.9 branch
* Test overlay op with mixed GeometryCollection
  • Loading branch information
mwtoews committed Mar 4, 2024
1 parent d1d221f commit f781576
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -18,6 +18,7 @@ xxxx-xx-xx
- Remove undefined behaviour in use of null PrecisionModel (GH-931, Jeff Walton)
- Skip over testing empty distances for mixed collections (GH-979, Paul Ramsey)
- Add missing cstdint headers (GH-990, GH-743, Regina Obe, Sergei Trofimovich)
- HeuristicOverlay: Fix overlay op regression (GH-1050, Mike Taves)


## Changes in 3.9.4
Expand Down
3 changes: 2 additions & 1 deletion src/geom/HeuristicOverlay.cpp
Expand Up @@ -421,7 +421,8 @@ HeuristicOverlay(const Geometry* g0, const Geometry* g1, int opCode)

return ret;
}
catch(const geos::util::TopologyException& ex) {
catch(const geos::util::IllegalArgumentException& ex) {
// Mixed GeometryCollection; see GH-1050
::geos::ignore_unused_variable_warning(ex);

#if GEOS_DEBUG_HEURISTICOVERLAY
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/capi/GEOSDifferenceTest.cpp
Expand Up @@ -40,5 +40,33 @@ void object::test<1>()
GEOSGeom_destroy(result);
}

/**
* Mixed GeometryCollection types permitted at a high-level
*/
template<>
template<>
void object::test<2>()
{
GEOSGeometry* a = GEOSGeomFromWKT("GEOMETRYCOLLECTION (POINT (51 -1), LINESTRING (52 -1, 49 2))");
GEOSGeometry* b = GEOSGeomFromWKT("POINT (2 3)");

ensure(a);
ensure(b);

GEOSGeometry* ab = GEOSDifference(a, b);
GEOSGeometry* ba = GEOSDifference(b, a);

ensure(ab);
ensure(ba);

ensure_geometry_equals(ab, a);
ensure_geometry_equals(ba, b);

GEOSGeom_destroy(a);
GEOSGeom_destroy(b);
GEOSGeom_destroy(ab);
GEOSGeom_destroy(ba);
}

} // namespace tut

0 comments on commit f781576

Please sign in to comment.