Class IsValidOp
java.lang.Object
org.locationtech.jts.operation.valid.IsValidOp
Implements the algorithms required to compute the
isValid()
method
for Geometry
s.
See the documentation for the various geometry types for a specification of validity.- Version:
- 1.7
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
If the following condition is TRUE JTS will validate inverted shells and exverted holes (the ESRI SDE model)private Geometry
private TopologyValidationError
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
checkClosedRing
(LinearRing ring) private void
checkClosedRings
(Polygon poly) private void
private void
checkConsistentArea
(GeometryGraph graph) Checks that the arrangement of edges in a polygonal geometry graph forms a consistent area.private void
checkHolesInShell
(Polygon p, GeometryGraph graph) Tests that each hole is inside the polygon shell.private void
checkHolesNotNested
(Polygon p, GeometryGraph graph) Tests that no hole is nested inside another hole.private void
checkInvalidCoordinates
(Coordinate[] coords) private void
private void
Check that a ring does not self-intersect, except at its endpoints.private void
Check that there is no ring which self-intersects (except of course at its endpoints).private Coordinate
checkShellInsideHole
(LinearRing shell, LinearRing hole, GeometryGraph graph) This routine checks to see if a shell is properly contained in a hole.private void
checkShellNotNested
(LinearRing shell, Polygon p, GeometryGraph graph) Check if a shell is incorrectly nested within a polygon.private void
checkShellsNotNested
(MultiPolygon mp, GeometryGraph graph) Tests that no element polygon is wholly in the interior of another element polygon.private void
checkTooFewPoints
(GeometryGraph graph) private void
private void
private void
Checks validity of a LinearRing.private void
Checks validity of a LineString.private void
Checks validity of a MultiPoint.private void
private void
checkValid
(Point g) Checks validity of a Point.private void
Checks the validity of a polygon.static Coordinate
findPtNotNode
(Coordinate[] testCoords, LinearRing searchRing, GeometryGraph graph) Find a point from the list of testCoords that is NOT a node in the edge for the list of searchCoordsComputes the validity of the geometry, and if not valid returns the validation error for the geometry, or null if the geometry is valid.boolean
isValid()
Computes the validity of the geometry, and returns true if it is valid.static boolean
isValid
(Coordinate coord) Checks whether a coordinate is valid for processing.static boolean
Tests whether aGeometry
is valid.void
setSelfTouchingRingFormingHoleValid
(boolean isValid) Sets whether polygons using Self-Touching Rings to form holes are reported as valid.
-
Field Details
-
parentGeometry
-
isSelfTouchingRingFormingHoleValid
private boolean isSelfTouchingRingFormingHoleValidIf the following condition is TRUE JTS will validate inverted shells and exverted holes (the ESRI SDE model) -
validErr
-
-
Constructor Details
-
IsValidOp
-
-
Method Details
-
isValid
Tests whether aGeometry
is valid.- Parameters:
geom
- the Geometry to test- Returns:
- true if the geometry is valid
-
isValid
Checks whether a coordinate is valid for processing. Coordinates are valid iff their x and y ordinates are in the range of the floating point representation.- Parameters:
coord
- the coordinate to validate- Returns:
true
if the coordinate is valid
-
findPtNotNode
public static Coordinate findPtNotNode(Coordinate[] testCoords, LinearRing searchRing, GeometryGraph graph) Find a point from the list of testCoords that is NOT a node in the edge for the list of searchCoords- Returns:
- the point found, or
null
if none found
-
setSelfTouchingRingFormingHoleValid
public void setSelfTouchingRingFormingHoleValid(boolean isValid) Sets whether polygons using Self-Touching Rings to form holes are reported as valid. If this flag is set, the following Self-Touching conditions are treated as being valid:- the shell ring self-touches to create a hole touching the shell
- a hole ring self-touches to create two holes touching at a point
The default (following the OGC SFS standard) is that this condition is not valid (
false
).This does not affect whether Self-Touching Rings disconnecting the polygon interior are considered valid (these are considered to be invalid under the SFS, and many other spatial models as well). This includes "bow-tie" shells, which self-touch at a single point causing the interior to be disconnected, and "C-shaped" holes which self-touch at a single point causing an island to be formed.
- Parameters:
isValid
- states whether geometry with this condition is valid
-
isValid
public boolean isValid()Computes the validity of the geometry, and returns true if it is valid.- Returns:
- true if the geometry is valid
-
getValidationError
Computes the validity of the geometry, and if not valid returns the validation error for the geometry, or null if the geometry is valid.- Returns:
- the validation error, if the geometry is invalid or null if the geometry is valid
-
checkValid
-
checkValid
Checks validity of a Point. -
checkValid
Checks validity of a MultiPoint. -
checkValid
Checks validity of a LineString. Almost anything goes for linestrings! -
checkValid
Checks validity of a LinearRing. -
checkValid
Checks the validity of a polygon. Sets the validErr flag. -
checkValid
-
checkValid
-
checkInvalidCoordinates
-
checkInvalidCoordinates
-
checkClosedRings
-
checkClosedRing
-
checkTooFewPoints
-
checkConsistentArea
Checks that the arrangement of edges in a polygonal geometry graph forms a consistent area.- Parameters:
graph
-- See Also:
-
checkNoSelfIntersectingRings
Check that there is no ring which self-intersects (except of course at its endpoints). This is required by OGC topology rules (but not by other models such as ESRI SDE, which allow inverted shells and exverted holes).- Parameters:
graph
- the topology graph of the geometry
-
checkNoSelfIntersectingRing
Check that a ring does not self-intersect, except at its endpoints. Algorithm is to count the number of times each node along edge occurs. If any occur more than once, that must be a self-intersection. -
checkHolesInShell
Tests that each hole is inside the polygon shell. This routine assumes that the holes have previously been tested to ensure that all vertices lie on the shell or on the same side of it (i.e. that the hole rings do not cross the shell ring). In other words, this test is only correct if the ConsistentArea test is passed first. Given this, a simple point-in-polygon test of a single point in the hole can be used, provided the point is chosen such that it does not lie on the shell.- Parameters:
p
- the polygon to be tested for hole inclusiongraph
- a GeometryGraph incorporating the polygon
-
checkHolesNotNested
Tests that no hole is nested inside another hole. This routine assumes that the holes are disjoint. To ensure this, holes have previously been tested to ensure that:- they do not partially overlap
(checked by
checkRelateConsistency
) - they are not identical
(checked by
checkRelateConsistency
)
- they do not partially overlap
(checked by
-
checkShellsNotNested
Tests that no element polygon is wholly in the interior of another element polygon.Preconditions:
- shells do not partially overlap
- shells do not touch along an edge
- no duplicate rings exist
-
checkShellNotNested
Check if a shell is incorrectly nested within a polygon. This is the case if the shell is inside the polygon shell, but not inside a polygon hole. (If the shell is inside a polygon hole, the nesting is valid.)The algorithm used relies on the fact that the rings must be properly contained. E.g. they cannot partially overlap (this has been previously checked by
checkRelateConsistency
) -
checkShellInsideHole
This routine checks to see if a shell is properly contained in a hole. It assumes that the edges of the shell and hole do not properly intersect.- Returns:
null
if the shell is properly contained, or a Coordinate which is not inside the hole if it is not
-
checkConnectedInteriors
-