public class DouglasPeuckerSimplifier extends Object
Geometry
using the Douglas-Peucker algorithm.
Ensures that any polygonal geometries returned are valid.
Simple lines are not guaranteed to remain simple after simplification.
All geometry types are handled.
Empty and point geometries are returned unchanged.
Empty geometry components are deleted.
Note that in general D-P does not preserve topology -
e.g. polygons can be split, collapse to lines or disappear
holes can be created or disappear,
and lines can cross.
To simplify geometry while preserving topology use TopologyPreservingSimplifier
.
(However, using D-P is significantly faster).
TopologyPreservingSimplifier
Constructor and Description |
---|
DouglasPeuckerSimplifier(Geometry inputGeom)
Creates a simplifier for a given geometry.
|
Modifier and Type | Method and Description |
---|---|
Geometry |
getResultGeometry()
Gets the simplified geometry.
|
void |
setDistanceTolerance(double distanceTolerance)
Sets the distance tolerance for the simplification.
|
void |
setEnsureValid(boolean isEnsureValidTopology)
Controls whether simplified polygons will be "fixed"
to have valid topology.
|
static Geometry |
simplify(Geometry geom,
double distanceTolerance)
Simplifies a geometry using a given tolerance.
|
public DouglasPeuckerSimplifier(Geometry inputGeom)
inputGeom
- the geometry to simplifypublic static Geometry simplify(Geometry geom, double distanceTolerance)
geom
- geometry to simplifydistanceTolerance
- the tolerance to usepublic void setDistanceTolerance(double distanceTolerance)
distanceTolerance
- the approximation tolerance to usepublic void setEnsureValid(boolean isEnsureValidTopology)
isEnsureValidTopology
- public Geometry getResultGeometry()
Copyright © 2024. All rights reserved.