Package org.locationtech.jts.precision
Class GeometryPrecisionReducer
- java.lang.Object
-
- org.locationtech.jts.precision.GeometryPrecisionReducer
-
public class GeometryPrecisionReducer extends java.lang.ObjectReduces the precision of aGeometryaccording to the suppliedPrecisionModel, ensuring that the result is topologically valid.- Version:
- 1.12
-
-
Field Summary
Fields Modifier and Type Field Description private booleanchangePrecisionModelprivate booleanisPointwiseprivate booleanremoveCollapsedprivate PrecisionModeltargetPM
-
Constructor Summary
Constructors Constructor Description GeometryPrecisionReducer(PrecisionModel pm)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private GeometrychangePM(Geometry geom, PrecisionModel newPM)Duplicates a geometry to one that uses a different PrecisionModel, without changing any coordinate values.private GeometryEditorcreateEditor(GeometryFactory geomFactory, PrecisionModel newPM)private GeometryFactorycreateFactory(GeometryFactory inputFactory, PrecisionModel pm)private GeometryfixPolygonalTopology(Geometry geom)Geometryreduce(Geometry geom)static Geometryreduce(Geometry g, PrecisionModel precModel)Convenience method for doing precision reduction on a single geometry, with collapses removed and keeping the geometry precision model the same, and preserving polygonal topology.private GeometryreducePointwise(Geometry geom)static GeometryreducePointwise(Geometry g, PrecisionModel precModel)Convenience method for doing pointwise precision reduction on a single geometry, with collapses removed and keeping the geometry precision model the same, but NOT preserving valid polygonal topology.voidsetChangePrecisionModel(boolean changePrecisionModel)Sets whether thePrecisionModelof the new reduced Geometry will be changed to be thePrecisionModelsupplied to specify the precision reduction.voidsetPointwise(boolean isPointwise)Sets whether the precision reduction will be done in pointwise fashion only.voidsetRemoveCollapsedComponents(boolean removeCollapsed)Sets whether the reduction will result in collapsed components being removed completely, or simply being collapsed to an (invalid) Geometry of the same type.
-
-
-
Field Detail
-
targetPM
private PrecisionModel targetPM
-
removeCollapsed
private boolean removeCollapsed
-
changePrecisionModel
private boolean changePrecisionModel
-
isPointwise
private boolean isPointwise
-
-
Constructor Detail
-
GeometryPrecisionReducer
public GeometryPrecisionReducer(PrecisionModel pm)
-
-
Method Detail
-
reduce
public static Geometry reduce(Geometry g, PrecisionModel precModel)
Convenience method for doing precision reduction on a single geometry, with collapses removed and keeping the geometry precision model the same, and preserving polygonal topology.- Parameters:
g- the geometry to reduceprecModel- the precision model to use- Returns:
- the reduced geometry
-
reducePointwise
public static Geometry reducePointwise(Geometry g, PrecisionModel precModel)
Convenience method for doing pointwise precision reduction on a single geometry, with collapses removed and keeping the geometry precision model the same, but NOT preserving valid polygonal topology.- Parameters:
g- the geometry to reduceprecModel- the precision model to use- Returns:
- the reduced geometry
-
setRemoveCollapsedComponents
public void setRemoveCollapsedComponents(boolean removeCollapsed)
Sets whether the reduction will result in collapsed components being removed completely, or simply being collapsed to an (invalid) Geometry of the same type. The default is to remove collapsed components.- Parameters:
removeCollapsed- iftruecollapsed components will be removed
-
setChangePrecisionModel
public void setChangePrecisionModel(boolean changePrecisionModel)
Sets whether thePrecisionModelof the new reduced Geometry will be changed to be thePrecisionModelsupplied to specify the precision reduction.The default is to not change the precision model
- Parameters:
changePrecisionModel- iftruethe precision model of the created Geometry will be the the precisionModel supplied in the constructor.
-
setPointwise
public void setPointwise(boolean isPointwise)
Sets whether the precision reduction will be done in pointwise fashion only. Pointwise precision reduction reduces the precision of the individual coordinates only, but does not attempt to recreate valid topology. This is only relevant for geometries containing polygonal components.- Parameters:
isPointwise- if reduction should be done pointwise only
-
changePM
private Geometry changePM(Geometry geom, PrecisionModel newPM)
Duplicates a geometry to one that uses a different PrecisionModel, without changing any coordinate values.- Parameters:
geom- the geometry to duplicatenewPM- the precision model to use- Returns:
- the geometry value with a new precision model
-
createEditor
private GeometryEditor createEditor(GeometryFactory geomFactory, PrecisionModel newPM)
-
createFactory
private GeometryFactory createFactory(GeometryFactory inputFactory, PrecisionModel pm)
-
-