Package org.locationtech.jts.operation
Class IsSimpleOp
- java.lang.Object
-
- org.locationtech.jts.operation.IsSimpleOp
-
public class IsSimpleOp extends java.lang.Object
Tests whether aGeometry
is simple. In general, the SFS specification of simplicity follows the rule:- A Geometry is simple if and only if the only self-intersections are at boundary points.
Simplicity is defined for each
Geometry
type as follows:- Polygonal geometries are simple by definition, so
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, useGeometry.isValid()
). - Linear geometries are simple iff they do not self-intersect at interior points
(i.e. points other than boundary points).
This is equivalent to saying that no two linear components satisfy the SFS
Geometry.touches(Geometry)
predicate. - Zero-dimensional (point) geometries are simple if and only if they have no repeated points.
- Empty geometries are always simple, by definition
Lineal
geometries the evaluation of simplicity can be customized by supplying aBoundaryNodeRule
to define how boundary points are determined. The default is the SFS-standardBoundaryNodeRule.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 ofLineString
s touch only at their endpoints, useIsSimpleOp
withBoundaryNodeRule.ENDPOINT_BOUNDARY_RULE
. For example, this can be used to validate that a set of lines form a topologically valid linear network.- Version:
- 1.7
- See Also:
BoundaryNodeRule
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
IsSimpleOp.EndpointInfo
-
Field Summary
Fields Modifier and Type Field Description private Geometry
inputGeom
private boolean
isClosedEndpointsInInterior
private Coordinate
nonSimpleLocation
-
Constructor Summary
Constructors Constructor Description IsSimpleOp()
Deprecated.use IsSimpleOp(Geometry)IsSimpleOp(Geometry geom)
Creates a simplicity checker using the default SFS Mod-2 Boundary Node RuleIsSimpleOp(Geometry geom, BoundaryNodeRule boundaryNodeRule)
Creates a simplicity checker using a givenBoundaryNodeRule
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method 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 existsprivate 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.
-
-
-
Field Detail
-
inputGeom
private Geometry inputGeom
-
isClosedEndpointsInInterior
private boolean isClosedEndpointsInInterior
-
nonSimpleLocation
private Coordinate nonSimpleLocation
-
-
Constructor Detail
-
IsSimpleOp
public IsSimpleOp()
Deprecated.use IsSimpleOp(Geometry)Creates a simplicity checker using the default SFS Mod-2 Boundary Node Rule
-
IsSimpleOp
public IsSimpleOp(Geometry geom)
Creates a simplicity checker using the default SFS Mod-2 Boundary Node Rule- Parameters:
geom
- the geometry to test
-
IsSimpleOp
public IsSimpleOp(Geometry geom, BoundaryNodeRule boundaryNodeRule)
Creates a simplicity checker using a givenBoundaryNodeRule
- Parameters:
geom
- the geometry to testboundaryNodeRule
- the rule to use.
-
-
Method Detail
-
isSimple
public boolean isSimple()
Tests whether the geometry is simple.- Returns:
- true if the geometry is simple
-
computeSimple
private boolean computeSimple(Geometry geom)
-
getNonSimpleLocation
public Coordinate getNonSimpleLocation()
Gets a coordinate for the location where the geometry fails to be simple. (i.e. where it has a non-boundary self-intersection).isSimple()
must be called before this method is called.- Returns:
- a coordinate for the location of the non-boundary self-intersection or null if the geometry is simple
-
isSimple
public boolean isSimple(LineString geom)
Deprecated.use isSimple()Reports whether aLineString
is simple.- Parameters:
geom
- the lineal geometry to test- Returns:
- true if the geometry is simple
-
isSimple
public boolean isSimple(MultiLineString geom)
Deprecated.use isSimple()Reports whether aMultiLineString
geometry is simple.- Parameters:
geom
- the lineal geometry to test- Returns:
- true if the geometry is simple
-
isSimple
public boolean isSimple(MultiPoint mp)
Deprecated.use isSimple()A MultiPoint is simple iff it has no repeated points
-
isSimpleMultiPoint
private boolean isSimpleMultiPoint(MultiPoint mp)
-
isSimplePolygonal
private boolean isSimplePolygonal(Geometry geom)
Computes simplicity for polygonal geometries. Polygonal geometries are simple if and only if all of their component rings are simple.- Parameters:
geom
- a Polygonal geometry- Returns:
- true if the geometry is simple
-
isSimpleGeometryCollection
private boolean isSimpleGeometryCollection(Geometry geom)
Semantics for GeometryCollection is simple iff all components are simple.- Parameters:
geom
-- Returns:
- true if the geometry is simple
-
isSimpleLinearGeometry
private boolean isSimpleLinearGeometry(Geometry geom)
-
hasNonEndpointIntersection
private boolean hasNonEndpointIntersection(GeometryGraph graph)
For all edges, check if there are any intersections which are NOT at an endpoint. The Geometry is not simple if there are intersections not at endpoints.
-
hasClosedEndpointIntersection
private boolean hasClosedEndpointIntersection(GeometryGraph graph)
Tests that no edge intersection is the endpoint of a closed line. This ensures that closed lines are not touched at their endpoint, which is an interior point according to the Mod-2 rule To check this we compute the degree of each endpoint. The degree of endpoints of closed lines must be exactly 2.
-
addEndpoint
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
-
-