public class OverlayOp extends GeometryGraphOperation
Geometry
s. The overlay
can be used to determine any boolean combination of the geometries.Modifier and Type | Field and Description |
---|---|
static int |
DIFFERENCE
The code for the Difference overlay operation.
|
private EdgeList |
edgeList |
private GeometryFactory |
geomFact |
private PlanarGraph |
graph |
static int |
INTERSECTION
The code for the Intersection overlay operation.
|
private PointLocator |
ptLocator |
private Geometry |
resultGeom |
private java.util.List |
resultLineList |
private java.util.List |
resultPointList |
private java.util.List |
resultPolyList |
static int |
SYMDIFFERENCE
The code for the Symmetric Difference overlay operation.
|
static int |
UNION
The code for the Union overlay operation.
|
arg, li, resultPrecisionModel
Constructor and Description |
---|
OverlayOp(Geometry g0,
Geometry g1)
Constructs an instance to compute a single overlay operation
for the given geometries.
|
Modifier and Type | Method and Description |
---|---|
private void |
cancelDuplicateResultEdges()
If both a dirEdge and its sym are marked as being in the result, cancel
them out.
|
private Geometry |
computeGeometry(java.util.List resultPointList,
java.util.List resultLineList,
java.util.List resultPolyList,
int opcode) |
private void |
computeLabelling()
Compute initial labelling for all DirectedEdges at each node.
|
private void |
computeLabelsFromDepths()
Update the labels for edges according to their depths.
|
private void |
computeOverlay(int opCode) |
private void |
copyPoints(int argIndex)
Copy all nodes from an arg geometry into this graph.
|
static Geometry |
createEmptyResult(int overlayOpCode,
Geometry a,
Geometry b,
GeometryFactory geomFact)
Creates an empty result geometry of the appropriate dimension,
based on the given overlay operation and the dimensions of the inputs.
|
private void |
findResultAreaEdges(int opCode)
Find all edges whose label indicates that they are in the result area(s),
according to the operation being performed.
|
PlanarGraph |
getGraph()
Gets the graph constructed to compute the overlay.
|
Geometry |
getResultGeometry(int overlayOpCode)
Gets the result of the overlay for a given overlay operation.
|
protected void |
insertUniqueEdge(Edge e)
Insert an edge from one of the noded input graphs.
|
private void |
insertUniqueEdges(java.util.List edges) |
private boolean |
isCovered(Coordinate coord,
java.util.List geomList) |
boolean |
isCoveredByA(Coordinate coord)
Tests if an L edge should be included in the result or not.
|
boolean |
isCoveredByLA(Coordinate coord)
Tests if a point node should be included in the result or not.
|
static boolean |
isResultOfOp(int loc0,
int loc1,
int overlayOpCode)
Tests whether a point with given
Location s
relative to two geometries is contained in
the result of overlaying the geometries using
a given overlay operation. |
static boolean |
isResultOfOp(Label label,
int 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. |
private void |
labelIncompleteNode(Node n,
int targetIndex)
Label an isolated node with its relationship to the target geometry.
|
private void |
labelIncompleteNodes()
Incomplete nodes are nodes whose labels are incomplete.
|
private void |
mergeSymLabels()
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.
|
static Geometry |
overlayOp(Geometry geom0,
Geometry geom1,
int opCode)
Computes an overlay operation for
the given geometry arguments.
|
private void |
replaceCollapsedEdges()
If edges which have undergone dimensional collapse are found,
replace them with a new edge which is a L edge
|
private static int |
resultDimension(int opCode,
Geometry g0,
Geometry g1) |
private void |
updateNodeLabelling() |
getArgGeometry, setComputationPrecision
public static final int INTERSECTION
public static final int UNION
public static final int DIFFERENCE
public static final int SYMDIFFERENCE
private final PointLocator ptLocator
private GeometryFactory geomFact
private Geometry resultGeom
private PlanarGraph graph
private EdgeList edgeList
private java.util.List resultPolyList
private java.util.List resultLineList
private java.util.List resultPointList
public static Geometry overlayOp(Geometry geom0, Geometry geom1, int opCode)
geom0
- the first geometry argumentgeom1
- the second geometry argumentopCode
- the code for the desired overlay operationTopologyException
- if a robustness problem is encounteredpublic static boolean isResultOfOp(Label label, int opCode)
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
label
- the topological label of the pointopCode
- the code for the overlay operation to testpublic static boolean isResultOfOp(int loc0, int loc1, int overlayOpCode)
Location
s
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
loc0
- the code for the location in the first geometryloc1
- the code for the location in the second geometryoverlayOpCode
- the code for the overlay operation to testpublic Geometry getResultGeometry(int overlayOpCode)
Note: this method can be called once only.
overlayOpCode
- the overlay operation to performTopologyException
- if a robustness problem is encounteredpublic PlanarGraph getGraph()
private void computeOverlay(int opCode)
private void insertUniqueEdges(java.util.List edges)
protected void insertUniqueEdge(Edge e)
private void computeLabelsFromDepths()
private void replaceCollapsedEdges()
private void copyPoints(int argIndex)
private void computeLabelling()
private void mergeSymLabels()
private void updateNodeLabelling()
private void labelIncompleteNodes()
When each node labelling is completed, the labelling of the incident edges is updated, to complete their labelling as well.
private void labelIncompleteNode(Node n, int targetIndex)
private void findResultAreaEdges(int opCode)
private void cancelDuplicateResultEdges()
public boolean isCoveredByLA(Coordinate coord)
coord
- the point coordinatepublic boolean isCoveredByA(Coordinate coord)
coord
- the point coordinateprivate boolean isCovered(Coordinate coord, java.util.List geomList)
private Geometry computeGeometry(java.util.List resultPointList, java.util.List resultLineList, java.util.List resultPolyList, int opcode)
public static Geometry createEmptyResult(int overlayOpCode, Geometry a, Geometry b, GeometryFactory geomFact)
The empty result is constructed using the following rules:
INTERSECTION
- result has the dimension of the lowest input dimension
UNION
- result has the dimension of the highest input dimension
DIFFERENCE
- result has the dimension of the left-hand input
SYMDIFFERENCE
- result has the dimension of the highest input dimension
(since the symmetric Difference is the union of the differences).
overlayOpCode
- the code for the overlay operation being performeda
- an input geometryb
- an input geometrygeomFact
- the geometry factory being used for the operation