GEOS  3.9.1dev
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
geos::operation::overlay::OverlayOp Class Reference

Computes the geometric overlay of two Geometry. More...

#include <OverlayOp.h>

Inheritance diagram for geos::operation::overlay::OverlayOp:
[legend]
Collaboration diagram for geos::operation::overlay::OverlayOp:
[legend]

Public Types

enum  OpCode { opINTERSECTION = 1, opUNION = 2, opDIFFERENCE = 3, opSYMDIFFERENCE = 4 }
 The spatial functions supported by this class. More...
 

Public Member Functions

 OverlayOp (const geom::Geometry *g0, const geom::Geometry *g1)
 Construct an OverlayOp with the given Geometry args. More...
 
 ~OverlayOp () override
 
geom::GeometrygetResultGeometry (OpCode overlayOpCode)
 Gets the result of the overlay for a given overlay operation. More...
 
geomgraph::PlanarGraphgetGraph ()
 Gets the graph constructed to compute the overlay. More...
 
bool isCoveredByLA (const geom::Coordinate &coord)
 This method is used to decide if a point node should be included in the result or not. More...
 
bool isCoveredByA (const geom::Coordinate &coord)
 This method is used to decide if an L edge should be included in the result or not. More...
 
- Public Member Functions inherited from geos::operation::GeometryGraphOperation
 GeometryGraphOperation (const geom::Geometry *g0, const geom::Geometry *g1)
 
 GeometryGraphOperation (const geom::Geometry *g0, const geom::Geometry *g1, const algorithm::BoundaryNodeRule &boundaryNodeRule)
 
 GeometryGraphOperation (const geom::Geometry *g0)
 
virtual ~GeometryGraphOperation ()
 
const geom::GeometrygetArgGeometry (unsigned int i) const
 

Static Public Member Functions

static geom::GeometryoverlayOp (const geom::Geometry *geom0, const geom::Geometry *geom1, OpCode opCode)
 Computes an overlay operation for the given geometry arguments. More...
 
static bool isResultOfOp (const geomgraph::Label &label, OpCode opCode)
 Tests whether a point with a given topological Label relative to two geometries is contained in the result of overlaying the geometries using a given overlay operation. More...
 
static bool isResultOfOp (geom::Location loc0, geom::Location loc1, OpCode opCode)
 This method will handle arguments of Location.NULL correctly. More...
 
static std::unique_ptr< geom::GeometrycreateEmptyResult (OverlayOp::OpCode overlayOpCode, const geom::Geometry *a, const geom::Geometry *b, const geom::GeometryFactory *geomFact)
 

Protected Member Functions

void insertUniqueEdge (geomgraph::Edge *e)
 Insert an edge from one of the noded input graphs. More...
 
- Protected Member Functions inherited from geos::operation::GeometryGraphOperation
void setComputationPrecision (const geom::PrecisionModel *pm)
 

Private Member Functions

void computeOverlay (OpCode opCode)
 
void insertUniqueEdges (std::vector< geomgraph::Edge * > *edges, const geom::Envelope *env=nullptr)
 
void computeLabelsFromDepths ()
 Update the labels for edges according to their depths. More...
 
void replaceCollapsedEdges ()
 If edges which have undergone dimensional collapse are found, replace them with a new edge which is a L edge. More...
 
void copyPoints (int argIndex, const geom::Envelope *env=nullptr)
 Copy all nodes from an arg geometry into this graph. More...
 
void computeLabelling ()
 Compute initial labelling for all DirectedEdges at each node. More...
 
void mergeSymLabels ()
 
void updateNodeLabelling ()
 
void labelIncompleteNodes ()
 
void labelIncompleteNode (geomgraph::Node *n, int targetIndex)
 Label an isolated node with its relationship to the target geometry. More...
 
void findResultAreaEdges (OpCode opCode)
 Find all edges whose label indicates that they are in the result area(s), according to the operation being performed. More...
 
void cancelDuplicateResultEdges ()
 
bool isCovered (const geom::Coordinate &coord, std::vector< geom::Geometry * > *geomList)
 
bool isCovered (const geom::Coordinate &coord, std::vector< geom::Polygon * > *geomList)
 
bool isCovered (const geom::Coordinate &coord, std::vector< geom::LineString * > *geomList)
 
geom::GeometrycomputeGeometry (std::vector< geom::Point * > *nResultPointList, std::vector< geom::LineString * > *nResultLineList, std::vector< geom::Polygon * > *nResultPolyList, OverlayOp::OpCode opCode)
 
int mergeZ (geomgraph::Node *n, const geom::Polygon *poly) const
 Merge Z values of node with those of the segment or vertex in the given Polygon it is on. More...
 
int mergeZ (geomgraph::Node *n, const geom::LineString *line) const
 
double getAverageZ (int targetIndex)
 
void checkObviouslyWrongResult (OpCode opCode)
 

Static Private Member Functions

static geom::Dimension::DimensionType resultDimension (OverlayOp::OpCode overlayOpCode, const geom::Geometry *g0, const geom::Geometry *g1)
 
static double getAverageZ (const geom::Polygon *poly)
 

Private Attributes

algorithm::PointLocator ptLocator
 
const geom::GeometryFactorygeomFact
 
geom::GeometryresultGeom
 
geomgraph::PlanarGraph graph
 
geomgraph::EdgeList edgeList
 
std::vector< geom::Polygon * > * resultPolyList
 
std::vector< geom::LineString * > * resultLineList
 
std::vector< geom::Point * > * resultPointList
 
std::vector< geomgraph::Edge * > dupEdges
 Caches for memory management. More...
 
double avgz [2]
 
bool avgzcomputed [2]
 
ElevationMatrixelevationMatrix
 

Additional Inherited Members

- Protected Attributes inherited from geos::operation::GeometryGraphOperation
algorithm::LineIntersector li
 
const geom::PrecisionModelresultPrecisionModel
 
std::vector< geomgraph::GeometryGraph * > arg
 The operation args into an array so they can be accessed by index. More...
 

Detailed Description

Computes the geometric overlay of two Geometry.

The overlay can be used to determine any boolean combination of the geometries.

Definition at line 70 of file OverlayOp.h.

Member Enumeration Documentation

The spatial functions supported by this class.

These operations implement various boolean combinations of the resultants of the overlay.

Enumerator
opINTERSECTION 

The code for the Intersection overlay operation.

opUNION 

The code for the Union overlay operation.

opDIFFERENCE 

The code for the Difference overlay operation.

opSYMDIFFERENCE 

The code for the Symmetric Difference overlay operation.

Definition at line 79 of file OverlayOp.h.

Constructor & Destructor Documentation

geos::operation::overlay::OverlayOp::OverlayOp ( const geom::Geometry g0,
const geom::Geometry g1 
)

Construct an OverlayOp with the given Geometry args.

Ownership of passed args will remain to caller, and the OverlayOp won't change them in any way.

geos::operation::overlay::OverlayOp::~OverlayOp ( )
override

Member Function Documentation

void geos::operation::overlay::OverlayOp::cancelDuplicateResultEdges ( )
private

If both a dirEdge and its sym are marked as being in the result, cancel them out.

void geos::operation::overlay::OverlayOp::checkObviouslyWrongResult ( OpCode  opCode)
private

Throw TopologyException if an obviously wrong result has been computed.

geom::Geometry* geos::operation::overlay::OverlayOp::computeGeometry ( std::vector< geom::Point * > *  nResultPointList,
std::vector< geom::LineString * > *  nResultLineList,
std::vector< geom::Polygon * > *  nResultPolyList,
OverlayOp::OpCode  opCode 
)
private

Build a Geometry containing all Geometries in the given vectors. Takes element's ownership, vector control is left to caller.

void geos::operation::overlay::OverlayOp::computeLabelling ( )
private

Compute initial labelling for all DirectedEdges at each node.

In this step, DirectedEdges will acquire a complete labelling (i.e. one with labels for both Geometries) only if they are incident on a node which has edges for both Geometries

void geos::operation::overlay::OverlayOp::computeLabelsFromDepths ( )
private

Update the labels for edges according to their depths.

For each edge, the depths are first normalized. Then, if the depths for the edge are equal, this edge must have collapsed into a line edge. If the depths are not equal, update the label with the locations corresponding to the depths (i.e. a depth of 0 corresponds to a Location of EXTERIOR, a depth of 1 corresponds to INTERIOR)

void geos::operation::overlay::OverlayOp::computeOverlay ( OpCode  opCode)
private
void geos::operation::overlay::OverlayOp::copyPoints ( int  argIndex,
const geom::Envelope env = nullptr 
)
private

Copy all nodes from an arg geometry into this graph.

The node label in the arg geometry overrides any previously computed label for that argIndex. (E.g. a node may be an intersection node with a previously computed label of BOUNDARY, but in the original arg Geometry it is actually in the interior due to the Boundary Determination Rule)

static std::unique_ptr<geom::Geometry> geos::operation::overlay::OverlayOp::createEmptyResult ( OverlayOp::OpCode  overlayOpCode,
const geom::Geometry a,
const geom::Geometry b,
const geom::GeometryFactory geomFact 
)
static

Creates an empty result geometry of the appropriate dimension, based on the given overlay operation and the dimensions of the inputs. The created geometry is always an atomic geometry, not a collection.

The empty result is constructed using the following rules:

  • opINTERSECTION result has the dimension of the lowest input dimension
  • opUNION - result has the dimension of the highest input dimension
  • opDIFFERENCE - result has the dimension of the left-hand input
  • opSYMDIFFERENCE - result has the dimension of the highest input dimension
void geos::operation::overlay::OverlayOp::findResultAreaEdges ( OpCode  opCode)
private

Find all edges whose label indicates that they are in the result area(s), according to the operation being performed.

Since we want polygon shells to be oriented CW, choose dirEdges with the interior of the result on the RHS. Mark them as being in the result. Interior Area edges are the result of dimensional collapses. They do not form part of the result area boundary.

double geos::operation::overlay::OverlayOp::getAverageZ ( int  targetIndex)
private
static double geos::operation::overlay::OverlayOp::getAverageZ ( const geom::Polygon poly)
staticprivate
geomgraph::PlanarGraph& geos::operation::overlay::OverlayOp::getGraph ( )
inline

Gets the graph constructed to compute the overlay.

Returns
the overlay graph

Definition at line 151 of file OverlayOp.h.

geom::Geometry* geos::operation::overlay::OverlayOp::getResultGeometry ( OpCode  overlayOpCode)

Gets the result of the overlay for a given overlay operation.

Note: this method can be called once only.

Parameters
overlayOpCodethe overlay operation to perform
Returns
the compute result geometry
Exceptions
TopologyExceptionif a robustness problem is encountered
void geos::operation::overlay::OverlayOp::insertUniqueEdge ( geomgraph::Edge e)
protected

Insert an edge from one of the noded input graphs.

Checks edges that are inserted to see if an identical edge already exists. If so, the edge is not inserted, but its label is merged with the existing edge.

void geos::operation::overlay::OverlayOp::insertUniqueEdges ( std::vector< geomgraph::Edge * > *  edges,
const geom::Envelope env = nullptr 
)
private
bool geos::operation::overlay::OverlayOp::isCovered ( const geom::Coordinate coord,
std::vector< geom::Geometry * > *  geomList 
)
private
Returns
true if the coord is located in the interior or boundary of a geometry in the list.
bool geos::operation::overlay::OverlayOp::isCovered ( const geom::Coordinate coord,
std::vector< geom::Polygon * > *  geomList 
)
private
Returns
true if the coord is located in the interior or boundary of a geometry in the list.
bool geos::operation::overlay::OverlayOp::isCovered ( const geom::Coordinate coord,
std::vector< geom::LineString * > *  geomList 
)
private
Returns
true if the coord is located in the interior or boundary of a geometry in the list.
bool geos::operation::overlay::OverlayOp::isCoveredByA ( const geom::Coordinate coord)

This method is used to decide if an L edge should be included in the result or not.

Returns
true if the coord point is covered by a result Area geometry
bool geos::operation::overlay::OverlayOp::isCoveredByLA ( const geom::Coordinate coord)

This method is used to decide if a point node should be included in the result or not.

Returns
true if the coord point is covered by a result Line or Area geometry
static bool geos::operation::overlay::OverlayOp::isResultOfOp ( const geomgraph::Label label,
OpCode  opCode 
)
static

Tests whether a point with a given topological Label relative to two geometries is contained in the result of overlaying the geometries using a given overlay operation.

The method handles arguments of Location::NONE correctly

Parameters
labelthe topological label of the point
opCodethe code for the overlay operation to test
Returns
true if the label locations correspond to the overlayOpCode
static bool geos::operation::overlay::OverlayOp::isResultOfOp ( geom::Location  loc0,
geom::Location  loc1,
OpCode  opCode 
)
static

This method will handle arguments of Location.NULL correctly.

Returns
true if the locations correspond to the opCode
void geos::operation::overlay::OverlayOp::labelIncompleteNode ( geomgraph::Node n,
int  targetIndex 
)
private

Label an isolated node with its relationship to the target geometry.

void geos::operation::overlay::OverlayOp::labelIncompleteNodes ( )
private

Incomplete nodes are nodes whose labels are incomplete.

(e.g. the location for one Geometry is NULL). These are either isolated nodes, or nodes which have edges from only a single Geometry incident on them.

Isolated nodes are found because nodes in one graph which don't intersect nodes in the other are not completely labelled by the initial process of adding nodes to the nodeList. To complete the labelling we need to check for nodes that lie in the interior of edges, and in the interior of areas.

When each node labelling is completed, the labelling of the incident edges is updated, to complete their labelling as well.

void geos::operation::overlay::OverlayOp::mergeSymLabels ( )
private

For nodes which have edges from only one Geometry incident on them, the previous step will have left their dirEdges with no labelling for the other Geometry. However, the sym dirEdge may have a labelling for the other Geometry, so merge the two labels.

int geos::operation::overlay::OverlayOp::mergeZ ( geomgraph::Node n,
const geom::Polygon poly 
) const
private

Merge Z values of node with those of the segment or vertex in the given Polygon it is on.

int geos::operation::overlay::OverlayOp::mergeZ ( geomgraph::Node n,
const geom::LineString line 
) const
private

Merge Z values of node with those of the segment or vertex in the given LineString it is on.

Returns
1 if an intersection is found, 0 otherwise.
static geom::Geometry* geos::operation::overlay::OverlayOp::overlayOp ( const geom::Geometry geom0,
const geom::Geometry geom1,
OpCode  opCode 
)
static

Computes an overlay operation for the given geometry arguments.

Parameters
geom0the first geometry argument
geom1the second geometry argument
opCodethe code for the desired overlay operation
Returns
the result of the overlay operation
Exceptions
TopologyExceptionif a robustness problem is encountered
void geos::operation::overlay::OverlayOp::replaceCollapsedEdges ( )
private

If edges which have undergone dimensional collapse are found, replace them with a new edge which is a L edge.

static geom::Dimension::DimensionType geos::operation::overlay::OverlayOp::resultDimension ( OverlayOp::OpCode  overlayOpCode,
const geom::Geometry g0,
const geom::Geometry g1 
)
staticprivate

For empty result, what is the correct geometry type to apply to the empty?

void geos::operation::overlay::OverlayOp::updateNodeLabelling ( )
private

Member Data Documentation

double geos::operation::overlay::OverlayOp::avgz[2]
private

Average Z of input geometries

Definition at line 389 of file OverlayOp.h.

bool geos::operation::overlay::OverlayOp::avgzcomputed[2]
private

Definition at line 390 of file OverlayOp.h.

std::vector<geomgraph::Edge*> geos::operation::overlay::OverlayOp::dupEdges
private

Caches for memory management.

Definition at line 371 of file OverlayOp.h.

geomgraph::EdgeList geos::operation::overlay::OverlayOp::edgeList
private

Definition at line 217 of file OverlayOp.h.

ElevationMatrix* geos::operation::overlay::OverlayOp::elevationMatrix
private

Definition at line 395 of file OverlayOp.h.

const geom::GeometryFactory* geos::operation::overlay::OverlayOp::geomFact
private

Definition at line 211 of file OverlayOp.h.

geomgraph::PlanarGraph geos::operation::overlay::OverlayOp::graph
private

Definition at line 215 of file OverlayOp.h.

algorithm::PointLocator geos::operation::overlay::OverlayOp::ptLocator
private

Definition at line 209 of file OverlayOp.h.

geom::Geometry* geos::operation::overlay::OverlayOp::resultGeom
private

Definition at line 213 of file OverlayOp.h.

std::vector<geom::LineString*>* geos::operation::overlay::OverlayOp::resultLineList
private

Definition at line 221 of file OverlayOp.h.

std::vector<geom::Point*>* geos::operation::overlay::OverlayOp::resultPointList
private

Definition at line 223 of file OverlayOp.h.

std::vector<geom::Polygon*>* geos::operation::overlay::OverlayOp::resultPolyList
private

Definition at line 219 of file OverlayOp.h.


The documentation for this class was generated from the following file: