public class GeometryFixer extends Object
Geometry.isValid().
Input geometries are always processed, so even valid inputs may have some minor alterations. The output is always a new geometry object.
Coordinate.isValid().Point: keep valid coordinate, or EMPTYLineString: coordinates are fixedLinearRing: coordinates are fixed. Keep valid ring, or else convert into LineStringPolygon: transform into a valid polygon or multipolygon,
preserving as much of the extent and vertices as possible.
MultiPolygon: each polygon is fixed,
then result made non-overlapping (via union)GeometryCollection: each element is fixedkeepCollapsed setting:
false: (default) collapses are converted to empty geometries
(and removed if they are elements of collections)true: collapses are converted to a valid geometry of lower dimensionGeometry.isValid()| Constructor and Description |
|---|
GeometryFixer(Geometry geom)
Creates a new instance to fix a given geometry.
|
| Modifier and Type | Method and Description |
|---|---|
static Geometry |
fix(Geometry geom)
Fixes a geometry to be valid.
|
static Geometry |
fix(Geometry geom,
boolean isKeepMulti)
Fixes a geometry to be valid, allowing to set a flag controlling how
single item results from fixed
MULTI geometries should be
returned. |
Geometry |
getResult()
Gets the fixed geometry.
|
void |
setKeepCollapsed(boolean isKeepCollapsed)
Sets whether collapsed geometries are converted to empty,
(which will be removed from collections),
or to a valid geometry of lower dimension.
|
void |
setKeepMulti(boolean isKeepMulti)
Sets whether fixed
MULTI geometries that consist of
only one item should still be returned as MULTI geometries. |
public GeometryFixer(Geometry geom)
geom - the geometry to be fixedpublic static Geometry fix(Geometry geom)
geom - the geometry to be fixedpublic static Geometry fix(Geometry geom, boolean isKeepMulti)
MULTI geometries should be
returned.geom - the geometry to be fixedisKeepMulti - a flag indicating if MULTI geometries should not be converted to single instance types
if they consist of only one item.public void setKeepCollapsed(boolean isKeepCollapsed)
isKeepCollapsed - whether collapses should be converted to a lower dimension geometrypublic void setKeepMulti(boolean isKeepMulti)
MULTI geometries that consist of
only one item should still be returned as MULTI geometries.
The default is to keep MULTI geometries.isKeepMulti - flag whether to keep MULTI geometries.public Geometry getResult()
Copyright © 2024. All rights reserved.