Class IsSimpleOp
- java.lang.Object
-
- org.locationtech.jts.operation.valid.IsSimpleOp
-
public class IsSimpleOp extends java.lang.Object
Tests whether aGeometry
is simple as defined by the OGC SFS specification.Simplicity is defined for each
Geometry
type as follows:- Point geometries are simple.
- MultiPoint geometries are simple if every point is unique
- LineString geometries are simple if they do not self-intersect at interior points (i.e. points other than the endpoints). Closed linestrings which intersect only at their endpoints are simple (i.e. valid LinearRingss.
- MultiLineString geometries are simple if their elements are simple and they intersect only at points which are boundary points of both elements. (The notion of boundary points can be user-specified - see below).
- Polygonal geometries have no definition of simplicity.
The
isSimple
code checks if all polygon rings are simple. (Note: this means that isSimple cannot be used to test for all self-intersections in Polygons. In order to check if a Polygonal geometry has self-intersections, useGeometry.isValid()
). - GeometryCollection geometries are simple if all their elements are simple.
- Empty geometries are simple
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) have no boundary. This means that an intersection at the endpoints of two closed LineStrings makes the geometry non-simple. If it is required to test whether a set of
LineString
s touch only at their endpoints, useBoundaryNodeRule.ENDPOINT_BOUNDARY_RULE
. For example, this can be used to validate that a collection of lines form a topologically valid linear network.By default this class finds a single non-simple location. To find all non-simple locations, set
setFindAllLocations(boolean)
before callingisSimple()
, and retrieve the locations viagetNonSimpleLocations()
. This can be used to find all intersection points in a linear network.- Version:
- 1.7
- See Also:
BoundaryNodeRule
,Geometry.isValid()
-
-
Constructor Summary
Constructors Constructor Description 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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Coordinate
getNonSimpleLocation()
Gets the coordinate for an location where the geometry fails to be simple.static Coordinate
getNonSimpleLocation(Geometry geom)
Gets a non-simple location in a geometry, if any.java.util.List<Coordinate>
getNonSimpleLocations()
Gets all non-simple intersection locations.boolean
isSimple()
Tests whether the geometry is simple.static boolean
isSimple(Geometry geom)
Tests whether a geometry is simple.void
setFindAllLocations(boolean isFindAll)
Sets whether all non-simple intersection points will be found.
-
-
-
Constructor Detail
-
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 boundary node rule to use.
-
-
Method Detail
-
isSimple
public static boolean isSimple(Geometry geom)
Tests whether a geometry is simple.- Parameters:
geom
- the geometry to test- Returns:
- true if the geometry is simple
-
getNonSimpleLocation
public static Coordinate getNonSimpleLocation(Geometry geom)
Gets a non-simple location in a geometry, if any.- Parameters:
geom
- the input geometry- Returns:
- a non-simple location, or null if the geometry is simple
-
setFindAllLocations
public void setFindAllLocations(boolean isFindAll)
Sets whether all non-simple intersection points will be found.- Parameters:
isFindAll
- whether to find all non-simple points
-
isSimple
public boolean isSimple()
Tests whether the geometry is simple.- Returns:
- true if the geometry is simple
-
getNonSimpleLocation
public Coordinate getNonSimpleLocation()
Gets the coordinate for an location where the geometry fails to be simple. (i.e. where it has a non-boundary self-intersection).- Returns:
- a coordinate for the location of the non-boundary self-intersection or null if the geometry is simple
-
getNonSimpleLocations
public java.util.List<Coordinate> getNonSimpleLocations()
Gets all non-simple intersection locations.- Returns:
- a list of the coordinates of non-simple locations
-
-