Class OverlayOp

Hierarchy: Object , GeometryGraphOperation, OverlayOp
public class OverlayOp
extends GeometryGraphOperation
Computes the geometric overlay of two Geometrys. The overlay can be used to determine any boolean combination of the geometries.

Other

  • version: 1.7
public OverlayOp(Geometry g0, Geometry g1)
Constructs an instance to compute a single overlay operation for the given geometries.
Parameters:
g0 - g0 the first geometry argument
g1 - g1 the second geometry argument
public static Geometry overlayOp(Geometry geom0, Geometry geom1, int opCode)
Computes an overlay operation for the given geometry arguments.
Parameters:
geom0 - geom0 the first geometry argument
geom1 - geom1 the second geometry argument
opCode - opCode the code for the desired overlay operation
Returns:
the result of the overlay operation
Throws:
TopologyException - TopologyException if a robustness problem is encountered
public 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.

The method handles arguments of Location.NONE correctly

Parameters:
label - label the topological label of the point
opCode - opCode the code for the overlay operation to test
Returns:
true if the label locations correspond to the overlayOpCode
public static boolean isResultOfOp(int loc0, int loc1, int overlayOpCode)
Tests whether a point with given Locations 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:
loc0 - loc0 the code for the location in the first geometry
loc1 - loc1 the code for the location in the second geometry
overlayOpCode - overlayOpCode the code for the overlay operation to test
Returns:
true if the locations correspond to the overlayOpCode
public Geometry getResultGeometry(int overlayOpCode)
Gets the result of the overlay for a given overlay operation.

Note: this method can be called once only.

Parameters:
overlayOpCode - overlayOpCode the overlay operation to perform
Returns:
the compute result geometry
Throws:
TopologyException - TopologyException if a robustness problem is encountered
public PlanarGraph getGraph()
Gets the graph constructed to compute the overlay.
Returns:
the overlay graph
protected void insertUniqueEdge(Edge e)
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.
public boolean isCoveredByLA(Coordinate coord)
Tests if a point node should be included in the result or not.
Parameters:
coord - coord the point coordinate
Returns:
true if the coordinate point is covered by a result Line or Area geometry
public boolean isCoveredByA(Coordinate coord)
Tests if an L edge should be included in the result or not.
Parameters:
coord - coord the point coordinate
Returns:
true if the coordinate point is covered by a result Area geometry
public 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. The created geometry is always an atomic geometry, not a collection.

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).
Parameters:
overlayOpCode - overlayOpCode the code for the overlay operation being performed
a - a an input geometry
b - b an input geometry
geomFact - geomFact the geometry factory being used for the operation
Returns:
an empty atomic geometry of the appropriate dimension