Package org.locationtech.jts.precision
Class CommonBitsOp
- java.lang.Object
-
- org.locationtech.jts.precision.CommonBitsOp
-
public class CommonBitsOp extends java.lang.Object
Provides versions of Geometry spatial functions which use common bit removal to reduce the likelihood of robustness problems.In the current implementation no rounding is performed on the reshifted result geometry, which means that it is possible that the returned Geometry is invalid. Client classes should check the validity of the returned result themselves.
- Version:
- 1.7
-
-
Field Summary
Fields Modifier and Type Field Description private CommonBitsRemover
cbr
private boolean
returnToOriginalPrecision
-
Constructor Summary
Constructors Constructor Description CommonBitsOp()
Creates a new instance of class, which reshifts resultGeometry
s.CommonBitsOp(boolean returnToOriginalPrecision)
Creates a new instance of class, specifying whether the resultGeometry
s should be reshifted.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Geometry
buffer(Geometry geom0, double distance)
Computes the buffer a geometry, using enhanced precision.private Geometry
computeResultPrecision(Geometry result)
If required, returning the result to the original precision if required.Geometry
difference(Geometry geom0, Geometry geom1)
Computes the set-theoretic difference of twoGeometry
s, using enhanced precision.Geometry
intersection(Geometry geom0, Geometry geom1)
Computes the set-theoretic intersection of twoGeometry
s, using enhanced precision.private Geometry
removeCommonBits(Geometry geom0)
Computes a copy of the inputGeometry
with the calculated common bits removed from each coordinate.private Geometry[]
removeCommonBits(Geometry geom0, Geometry geom1)
Computes a copy of each inputGeometry
s with the calculated common bits removed from each coordinate.Geometry
symDifference(Geometry geom0, Geometry geom1)
Computes the set-theoretic symmetric difference of two geometries, using enhanced precision.Geometry
union(Geometry geom0, Geometry geom1)
Computes the set-theoretic union of twoGeometry
s, using enhanced precision.
-
-
-
Field Detail
-
returnToOriginalPrecision
private boolean returnToOriginalPrecision
-
cbr
private CommonBitsRemover cbr
-
-
Constructor Detail
-
CommonBitsOp
public CommonBitsOp()
Creates a new instance of class, which reshifts resultGeometry
s.
-
CommonBitsOp
public CommonBitsOp(boolean returnToOriginalPrecision)
Creates a new instance of class, specifying whether the resultGeometry
s should be reshifted.- Parameters:
returnToOriginalPrecision
-
-
-
Method Detail
-
intersection
public Geometry intersection(Geometry geom0, Geometry geom1)
Computes the set-theoretic intersection of twoGeometry
s, using enhanced precision.- Parameters:
geom0
- the first Geometrygeom1
- the second Geometry- Returns:
- the Geometry representing the set-theoretic intersection of the input Geometries.
-
union
public Geometry union(Geometry geom0, Geometry geom1)
Computes the set-theoretic union of twoGeometry
s, using enhanced precision.- Parameters:
geom0
- the first Geometrygeom1
- the second Geometry- Returns:
- the Geometry representing the set-theoretic union of the input Geometries.
-
difference
public Geometry difference(Geometry geom0, Geometry geom1)
Computes the set-theoretic difference of twoGeometry
s, using enhanced precision.- Parameters:
geom0
- the first Geometrygeom1
- the second Geometry, to be subtracted from the first- Returns:
- the Geometry representing the set-theoretic difference of the input Geometries.
-
symDifference
public Geometry symDifference(Geometry geom0, Geometry geom1)
Computes the set-theoretic symmetric difference of two geometries, using enhanced precision.- Parameters:
geom0
- the first Geometrygeom1
- the second Geometry- Returns:
- the Geometry representing the set-theoretic symmetric difference of the input Geometries.
-
buffer
public Geometry buffer(Geometry geom0, double distance)
Computes the buffer a geometry, using enhanced precision.- Parameters:
geom0
- the Geometry to bufferdistance
- the buffer distance- Returns:
- the Geometry representing the buffer of the input Geometry.
-
computeResultPrecision
private Geometry computeResultPrecision(Geometry result)
If required, returning the result to the original precision if required.In this current implementation, no rounding is performed on the reshifted result geometry, which means that it is possible that the returned Geometry is invalid.
- Parameters:
result
- the result Geometry to modify- Returns:
- the result Geometry with the required precision
-
removeCommonBits
private Geometry removeCommonBits(Geometry geom0)
Computes a copy of the inputGeometry
with the calculated common bits removed from each coordinate.- Parameters:
geom0
- the Geometry to remove common bits from- Returns:
- a copy of the input Geometry with common bits removed
-
removeCommonBits
private Geometry[] removeCommonBits(Geometry geom0, Geometry geom1)
Computes a copy of each inputGeometry
s with the calculated common bits removed from each coordinate.- Parameters:
geom0
- a Geometry to remove common bits fromgeom1
- a Geometry to remove common bits from- Returns:
- an array containing copies of the input Geometry's with common bits removed
-
-