public class IsSimpleOp
extends java.lang.Object
Geometry
is simple.
In general, the SFS specification of simplicity
follows the rule:
Simplicity is defined for each Geometry
type as follows:
isSimple
trivially returns true.
(Note: this means that isSimple cannot be used to test
for (invalid) self-intersections in Polygons.
In order to check if a Polygonal geometry has self-intersections,
use Geometry.isValid()
).
Geometry.touches(Geometry)
predicate.
Lineal
geometries the evaluation of simplicity
can be customized by supplying a BoundaryNodeRule
to define how boundary points are determined.
The default is the SFS-standard BoundaryNodeRule.MOD2_BOUNDARY_RULE
.
Note that under the Mod-2 rule, closed LineStrings (rings)
will never satisfy the touches predicate at their endpoints, since these are
interior points, not boundary points.
If it is required to test whether a set of LineString
s touch
only at their endpoints, use IsSimpleOp
with BoundaryNodeRule.ENDPOINT_BOUNDARY_RULE
.
For example, this can be used to validate that a set of lines form a topologically valid
linear network.BoundaryNodeRule
Modifier and Type | Class and Description |
---|---|
private static class |
IsSimpleOp.EndpointInfo |
Modifier and Type | Field and Description |
---|---|
private Geometry |
inputGeom |
private boolean |
isClosedEndpointsInInterior |
private Coordinate |
nonSimpleLocation |
Constructor and Description |
---|
IsSimpleOp()
Deprecated.
use IsSimpleOp(Geometry)
|
IsSimpleOp(Geometry geom)
Creates a simplicity checker using the default SFS Mod-2 Boundary Node Rule
|
IsSimpleOp(Geometry geom,
BoundaryNodeRule boundaryNodeRule)
Creates a simplicity checker using a given
BoundaryNodeRule |
Modifier and Type | Method and Description |
---|---|
private void |
addEndpoint(java.util.Map endPoints,
Coordinate p,
boolean isClosed)
Add an endpoint to the map, creating an entry for it if none exists
|
private boolean |
computeSimple(Geometry geom) |
Coordinate |
getNonSimpleLocation()
Gets a coordinate for the location where the geometry
fails to be simple.
|
private boolean |
hasClosedEndpointIntersection(GeometryGraph graph)
Tests that no edge intersection is the endpoint of a closed line.
|
private boolean |
hasNonEndpointIntersection(GeometryGraph graph)
For all edges, check if there are any intersections which are NOT at an endpoint.
|
boolean |
isSimple()
Tests whether the geometry is simple.
|
boolean |
isSimple(LineString geom)
Deprecated.
use isSimple()
|
boolean |
isSimple(MultiLineString geom)
Deprecated.
use isSimple()
|
boolean |
isSimple(MultiPoint mp)
Deprecated.
use isSimple()
|
private boolean |
isSimpleGeometryCollection(Geometry geom)
Semantics for GeometryCollection is
simple iff all components are simple.
|
private boolean |
isSimpleLinearGeometry(Geometry geom) |
private boolean |
isSimpleMultiPoint(MultiPoint mp) |
private boolean |
isSimplePolygonal(Geometry geom)
Computes simplicity for polygonal geometries.
|
private Geometry inputGeom
private boolean isClosedEndpointsInInterior
private Coordinate nonSimpleLocation
public IsSimpleOp()
public IsSimpleOp(Geometry geom)
geom
- the geometry to testpublic IsSimpleOp(Geometry geom, BoundaryNodeRule boundaryNodeRule)
BoundaryNodeRule
geom
- the geometry to testboundaryNodeRule
- the rule to use.public boolean isSimple()
private boolean computeSimple(Geometry geom)
public Coordinate getNonSimpleLocation()
isSimple()
must be called before this method is called.public boolean isSimple(LineString geom)
LineString
is simple.geom
- the lineal geometry to testpublic boolean isSimple(MultiLineString geom)
MultiLineString
geometry is simple.geom
- the lineal geometry to testpublic boolean isSimple(MultiPoint mp)
private boolean isSimpleMultiPoint(MultiPoint mp)
private boolean isSimplePolygonal(Geometry geom)
geom
- a Polygonal geometryprivate boolean isSimpleGeometryCollection(Geometry geom)
geom
- private boolean isSimpleLinearGeometry(Geometry geom)
private boolean hasNonEndpointIntersection(GeometryGraph graph)
private boolean hasClosedEndpointIntersection(GeometryGraph graph)
private void addEndpoint(java.util.Map endPoints, Coordinate p, boolean isClosed)