Tie MakeValid implementation directly to the old overlay operations
continuous-integration/drone/push Build is failing Details

3.9
pramsey 2020-07-30 11:05:21 -07:00
parent 9cc5f362f1
commit 4ef6f82756
1 changed files with 30 additions and 4 deletions

View File

@ -21,7 +21,9 @@
#include <geos/operation/valid/MakeValid.h>
#include <geos/operation/valid/IsValidOp.h>
#include <geos/operation/overlay/OverlayOp.h>
#include <geos/operation/polygonize/BuildArea.h>
#include <geos/operation/union/UnaryUnionOp.h>
#include <geos/geom/Geometry.h>
#include <geos/geom/GeometryCollection.h>
#include <geos/geom/GeometryFactory.h>
@ -44,11 +46,35 @@
#endif
using namespace geos::geom;
using geos::operation::overlay::OverlayOp;
using geos::operation::geounion::UnaryUnionOp;
namespace geos {
namespace operation { // geos.operation
namespace valid { // geos.operation.valid
static std::unique_ptr<geom::Geometry>
makeValidSymDifference(const geom::Geometry* g0, const geom::Geometry* g1)
{
std::unique_ptr<Geometry> r(OverlayOp::overlayOp(g0, g1, OverlayOp::opSYMDIFFERENCE));
return r;
}
static std::unique_ptr<geom::Geometry>
makeValidDifference(const geom::Geometry* g0, const geom::Geometry* g1)
{
std::unique_ptr<Geometry> r(OverlayOp::overlayOp(g0, g1, OverlayOp::opDIFFERENCE));
return r;
}
static std::unique_ptr<geom::Geometry>
makeValidUnion(const geom::Geometry* g0, const geom::Geometry* g1)
{
std::unique_ptr<Geometry> r(OverlayOp::overlayOp(g0, g1, OverlayOp::opUNION));
return r;
}
/*
* Fully node given linework
*/
@ -81,7 +107,7 @@ nodeLineWithFirstCoordinate(const geom::Geometry* geom)
point = line->getPointN(0);
}
return geom->Union(point.get());
return makeValidUnion(geom, point.get());
}
@ -190,7 +216,7 @@ static std::unique_ptr<geom::Geometry> MakeValidPoly(const geom::Geometry* geom)
* We want to retrieve any of those */
auto pi = extractUniquePoints(bound.get());
auto po = extractUniquePoints(cut_edges.get());
std::unique_ptr<geom::Geometry> collapse_points(pi->difference(po.get()));
std::unique_ptr<geom::Geometry> collapse_points = makeValidDifference(pi.get(), po.get());
assert(collapse_points);
pi.reset();
po.reset();
@ -222,7 +248,7 @@ static std::unique_ptr<geom::Geometry> MakeValidPoly(const geom::Geometry* geom)
assert(new_area_bound);
// Now symdif new and old area
std::unique_ptr<geom::Geometry> symdif(area->symDifference(new_area.get()));
std::unique_ptr<geom::Geometry> symdif = makeValidSymDifference(area.get(), new_area.get());
assert(symdif);
area = std::move(symdif);
@ -237,7 +263,7 @@ static std::unique_ptr<geom::Geometry> MakeValidPoly(const geom::Geometry* geom)
* NOTE: this is an expensive operation.
*
*/
std::unique_ptr<geom::Geometry> new_cut_edges(cut_edges->difference(new_area_bound.get()));
std::unique_ptr<geom::Geometry> new_cut_edges = makeValidDifference(cut_edges.get(), new_area_bound.get());
assert(new_cut_edges);
cut_edges = std::move(new_cut_edges);