OverlayNG.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2020 Sandro Santilli <strk@kbt.io>
* Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last Port: operation/overlayng/OverlayNG.java 4c88fea52
*
**********************************************************************/
#pragma once
#include <geos/geom/Geometry.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/operation/overlayng/OverlayGraph.h>
#include <geos/operation/overlayng/OverlayEdgeRing.h>
#include <geos/operation/overlayng/InputGeometry.h>
#include <geos/export.h>
// Forward declarations
namespace geos {
namespace geom {
class GeometryFactory;
class PrecisionModel;
}
namespace noding {
class Noder;
}
namespace operation {
namespace overlayng {
}
}
}
namespace geos { // geos.
namespace operation { // geos.operation
namespace overlayng { // geos.operation.overlayng
class GEOS_DLL OverlayNG {
using Geometry = geos::geom::Geometry;
using PrecisionModel = geos::geom::PrecisionModel;
using Location = geos::geom::Location;
private:
// Members
const geom::PrecisionModel* pm;
InputGeometry inputGeom;
const geom::GeometryFactory* geomFact;
int opCode;
noding::Noder* noder;
bool isStrictMode;
bool isOptimized;
bool isAreaResultOnly;
bool isOutputEdges;
bool isOutputResultEdges;
bool isOutputNodedEdges;
// Methods
std::unique_ptr<geom::Geometry> computeEdgeOverlay();
void labelGraph(OverlayGraph* graph);
std::unique_ptr<geom::Geometry> extractResult(int opCode, OverlayGraph* graph);
std::unique_ptr<geom::Geometry> createEmptyResult();
public:
static constexpr bool STRICT_MODE_DEFAULT = false;
static constexpr int INTERSECTION = 1;
static constexpr int UNION = 2;
static constexpr int DIFFERENCE = 3;
static constexpr int SYMDIFFERENCE = 4;
OverlayNG(const geom::Geometry* geom0, const geom::Geometry* geom1, const geom::GeometryFactory* p_geomFact, int p_opCode)
: pm(p_geomFact->getPrecisionModel())
, inputGeom(geom0, geom1)
, geomFact(p_geomFact)
, opCode(p_opCode)
, noder(nullptr)
, isStrictMode(STRICT_MODE_DEFAULT)
, isOptimized(true)
, isAreaResultOnly(false)
, isOutputEdges(false)
, isOutputResultEdges(false)
, isOutputNodedEdges(false)
{}
OverlayNG(const geom::Geometry* geom0, const geom::Geometry* geom1, const geom::PrecisionModel* p_pm, int p_opCode)
: pm(p_pm)
, inputGeom(geom0, geom1)
, geomFact(geom0->getFactory())
, opCode(p_opCode)
, noder(nullptr)
, isStrictMode(STRICT_MODE_DEFAULT)
, isOptimized(true)
, isAreaResultOnly(false)
, isOutputEdges(false)
, isOutputResultEdges(false)
, isOutputNodedEdges(false)
{}
OverlayNG(const geom::Geometry* geom0, const geom::Geometry* geom1, int p_opCode)
: OverlayNG(geom0, geom1, geom0->getFactory()->getPrecisionModel(), p_opCode)
{}
OverlayNG(const geom::Geometry* geom0, const geom::PrecisionModel* p_pm)
: OverlayNG(geom0, nullptr, p_pm, UNION)
{}
void setOptimized(bool p_isOptimized) { isOptimized = p_isOptimized; }
void setStrictMode(bool p_isStrictMode) { isStrictMode = p_isStrictMode; }
void setAreaResultOnly(bool p_areaResultOnly) { isAreaResultOnly = p_areaResultOnly; }
void setOutputEdges(bool p_isOutputEdges) { isOutputEdges = p_isOutputEdges; }
void setOutputResultEdges(bool p_isOutputResultEdges) { isOutputResultEdges = p_isOutputResultEdges; }
void setNoder(noding::Noder* p_noder) { noder = p_noder; }
void setOutputNodedEdges(bool p_isOutputNodedEdges)
{
isOutputEdges = true;
isOutputNodedEdges = p_isOutputNodedEdges;
}
std::unique_ptr<Geometry> getResult();
static bool isResultOfOpPoint(const OverlayLabel* label, int opCode);
static bool isResultOfOp(int overlayOpCode, Location loc0, Location loc1);
static std::unique_ptr<Geometry>
overlay(const Geometry* geom0, const Geometry* geom1,
int opCode, const PrecisionModel* pm);
static std::unique_ptr<Geometry>
overlay(const Geometry* geom0, const Geometry* geom1,
int opCode, const PrecisionModel* pm, noding::Noder* noder);
static std::unique_ptr<Geometry>
overlay(const Geometry* geom0, const Geometry* geom1,
int opCode, noding::Noder* noder);
static std::unique_ptr<Geometry>
overlay(const Geometry* geom0, const Geometry* geom1, int opCode);
static std::unique_ptr<Geometry>
geomunion(const Geometry* geom, const PrecisionModel* pm);
static std::unique_ptr<Geometry>
geomunion(const Geometry* geom, const PrecisionModel* pm, noding::Noder* noder);
};
} // namespace geos.operation.overlayng
} // namespace geos.operation
} // namespace geos
geos::geom::GeometryFactory
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::geom::PrecisionModel
Specifies the precision model of the Coordinate in a Geometry.
Definition PrecisionModel.h:87
geos::noding::Noder
Computes all intersections between segments in a set of SegmentString.
Definition Noder.h:46
geos::operation::overlayng::InputGeometry
Definition InputGeometry.h:41
geos::operation::overlayng::OverlayGraph
Definition OverlayGraph.h:52
geos::operation::overlayng::OverlayLabel
Definition OverlayLabel.h:86
geos::operation::overlayng::OverlayNG
Definition OverlayNG.h:120
geos::operation::overlayng::OverlayNG::setOptimized
void setOptimized(bool p_isOptimized)
Definition OverlayNG.h:247
geos::operation::overlayng::OverlayNG::OverlayNG
OverlayNG(const geom::Geometry *geom0, const geom::Geometry *geom1, const geom::GeometryFactory *p_geomFact, int p_opCode)
Definition OverlayNG.h:185
geos::operation::overlayng::OverlayNG::getResult
std::unique_ptr< Geometry > getResult()
geos::operation::overlayng::OverlayNG::overlay
static std::unique_ptr< Geometry > overlay(const Geometry *geom0, const Geometry *geom1, int opCode, const PrecisionModel *pm, noding::Noder *noder)
geos::operation::overlayng::OverlayNG::overlay
static std::unique_ptr< Geometry > overlay(const Geometry *geom0, const Geometry *geom1, int opCode)
geos::operation::overlayng::OverlayNG::geomunion
static std::unique_ptr< Geometry > geomunion(const Geometry *geom, const PrecisionModel *pm, noding::Noder *noder)
geos::operation::overlayng::OverlayNG::OverlayNG
OverlayNG(const geom::Geometry *geom0, const geom::Geometry *geom1, const geom::PrecisionModel *p_pm, int p_opCode)
Definition OverlayNG.h:204
geos::operation::overlayng::OverlayNG::overlay
static std::unique_ptr< Geometry > overlay(const Geometry *geom0, const Geometry *geom1, int opCode, noding::Noder *noder)
geos::operation::overlayng::OverlayNG::isResultOfOpPoint
static bool isResultOfOpPoint(const OverlayLabel *label, int opCode)
geos::operation::overlayng::OverlayNG::OverlayNG
OverlayNG(const geom::Geometry *geom0, const geom::Geometry *geom1, int p_opCode)
Definition OverlayNG.h:231
geos::operation::overlayng::OverlayNG::geomunion
static std::unique_ptr< Geometry > geomunion(const Geometry *geom, const PrecisionModel *pm)
geos::operation::overlayng::OverlayNG::overlay
static std::unique_ptr< Geometry > overlay(const Geometry *geom0, const Geometry *geom1, int opCode, const PrecisionModel *pm)
geos::operation::overlayng::OverlayNG::STRICT_MODE_DEFAULT
static constexpr bool STRICT_MODE_DEFAULT
Definition OverlayNG.h:173
geos::operation::overlayng::OverlayNG::isResultOfOp
static bool isResultOfOp(int overlayOpCode, Location loc0, Location loc1)
geos::geom
Definition Angle.h:26
geos::geom::Location
Location
Constants representing the location of a point relative to a geometry.
Definition Location.h:32
geos::noding
Classes to compute nodings for arrangements of line segments and line segment sequences.
Definition CoverageCleaner.h:42
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38