Class OverlayOp
- java.lang.Object
-
- org.locationtech.jts.operation.GeometryGraphOperation
-
- org.locationtech.jts.operation.overlay.OverlayOp
-
public class OverlayOp extends GeometryGraphOperation
Computes the geometric overlay of twoGeometry
s. The overlay can be used to determine any boolean combination of the geometries.- Version:
- 1.7
-
-
Field Summary
Fields Modifier and Type Field Description static int
DIFFERENCE
The code for the Difference overlay operation.static int
INTERSECTION
The code for the Intersection overlay operation.static int
SYMDIFFERENCE
The code for the Symmetric Difference overlay operation.static int
UNION
The code for the Union overlay operation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.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.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 givenLocation
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 topologicalLabel
relative to two geometries is contained in the result of overlaying the geometries using a given overlay operation.static Geometry
overlayOp(Geometry geom0, Geometry geom1, int opCode)
Computes an overlay operation for the given geometry arguments.-
Methods inherited from class org.locationtech.jts.operation.GeometryGraphOperation
getArgGeometry
-
-
-
-
Field Detail
-
INTERSECTION
public static final int INTERSECTION
The code for the Intersection overlay operation.- See Also:
- Constant Field Values
-
UNION
public static final int UNION
The code for the Union overlay operation.- See Also:
- Constant Field Values
-
DIFFERENCE
public static final int DIFFERENCE
The code for the Difference overlay operation.- See Also:
- Constant Field Values
-
SYMDIFFERENCE
public static final int SYMDIFFERENCE
The code for the Symmetric Difference overlay operation.- See Also:
- Constant Field Values
-
-
Method Detail
-
overlayOp
public static Geometry overlayOp(Geometry geom0, Geometry geom1, int opCode)
Computes an overlay operation for the given geometry arguments.- Parameters:
geom0
- the first geometry argumentgeom1
- the second geometry argumentopCode
- the code for the desired overlay operation- Returns:
- the result of the overlay operation
- Throws:
TopologyException
- if a robustness problem is encountered
-
isResultOfOp
public static boolean isResultOfOp(Label label, int opCode)
Tests whether a point with a given topologicalLabel
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
- the topological label of the pointopCode
- the code for the overlay operation to test- Returns:
- true if the label locations correspond to the overlayOpCode
-
isResultOfOp
public static boolean isResultOfOp(int loc0, int loc1, int overlayOpCode)
Tests whether a point with givenLocation
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- Parameters:
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 test- Returns:
- true if the locations correspond to the overlayOpCode
-
getResultGeometry
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
- the overlay operation to perform- Returns:
- the compute result geometry
- Throws:
TopologyException
- if a robustness problem is encountered
-
getGraph
public PlanarGraph getGraph()
Gets the graph constructed to compute the overlay.- Returns:
- the overlay graph
-
isCoveredByLA
public boolean isCoveredByLA(Coordinate coord)
Tests if a point node should be included in the result or not.- Parameters:
coord
- the point coordinate- Returns:
- true if the coordinate point is covered by a result Line or Area geometry
-
isCoveredByA
public boolean isCoveredByA(Coordinate coord)
Tests if an L edge should be included in the result or not.- Parameters:
coord
- the point coordinate- Returns:
- true if the coordinate point is covered by a result Area geometry
-
createEmptyResult
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 dimensionUNION
- result has the dimension of the highest input dimensionDIFFERENCE
- result has the dimension of the left-hand inputSYMDIFFERENCE
- result has the dimension of the highest input dimension (since the symmetric Difference is the union of the differences).
- Parameters:
overlayOpCode
- the code for the overlay operation being performeda
- an input geometryb
- an input geometrygeomFact
- the geometry factory being used for the operation- Returns:
- an empty atomic geometry of the appropriate dimension
-
-