Class IsValidOp
- java.lang.Object
-
- org.locationtech.jts.operation.valid.IsValidOp
-
public class IsValidOp extends java.lang.Object
Implements the algorithms required to compute theisValid()
method forGeometry
s. See the documentation for the various geometry types for a specification of validity.- Version:
- 1.7
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
isSelfTouchingRingFormingHoleValid
If the following condition is TRUE JTS will validate inverted shells and exverted holes (the ESRI SDE model)private Geometry
parentGeometry
private TopologyValidationError
validErr
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkClosedRing(LinearRing ring)
private void
checkClosedRings(Polygon poly)
private void
checkConnectedInteriors(GeometryGraph graph)
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
checkInvalidCoordinates(Polygon poly)
private void
checkNoSelfIntersectingRing(EdgeIntersectionList eiList)
Check that a ring does not self-intersect, except at its endpoints.private void
checkNoSelfIntersectingRings(GeometryGraph graph)
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
checkValid(Geometry g)
private void
checkValid(GeometryCollection gc)
private void
checkValid(LinearRing g)
Checks validity of a LinearRing.private void
checkValid(LineString g)
Checks validity of a LineString.private void
checkValid(MultiPoint g)
Checks validity of a MultiPoint.private void
checkValid(MultiPolygon g)
private void
checkValid(Point g)
Checks validity of a Point.private void
checkValid(Polygon g)
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 searchCoordsTopologyValidationError
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.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
isValid(Geometry geom)
Tests whether aGeometry
is valid.void
setSelfTouchingRingFormingHoleValid(boolean isValid)
Sets whether polygons using Self-Touching Rings to form holes are reported as valid.
-
-
-
Field Detail
-
parentGeometry
private Geometry parentGeometry
-
isSelfTouchingRingFormingHoleValid
private boolean isSelfTouchingRingFormingHoleValid
If the following condition is TRUE JTS will validate inverted shells and exverted holes (the ESRI SDE model)
-
validErr
private TopologyValidationError validErr
-
-
Constructor Detail
-
IsValidOp
public IsValidOp(Geometry parentGeometry)
-
-
Method Detail
-
isValid
public static boolean isValid(Geometry geom)
Tests whether aGeometry
is valid.- Parameters:
geom
- the Geometry to test- Returns:
- true if the geometry is valid
-
isValid
public static boolean isValid(Coordinate coord)
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
public TopologyValidationError 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
private void checkValid(Geometry g)
-
checkValid
private void checkValid(Point g)
Checks validity of a Point.
-
checkValid
private void checkValid(MultiPoint g)
Checks validity of a MultiPoint.
-
checkValid
private void checkValid(LineString g)
Checks validity of a LineString. Almost anything goes for linestrings!
-
checkValid
private void checkValid(LinearRing g)
Checks validity of a LinearRing.
-
checkValid
private void checkValid(Polygon g)
Checks the validity of a polygon. Sets the validErr flag.
-
checkValid
private void checkValid(MultiPolygon g)
-
checkValid
private void checkValid(GeometryCollection gc)
-
checkInvalidCoordinates
private void checkInvalidCoordinates(Coordinate[] coords)
-
checkInvalidCoordinates
private void checkInvalidCoordinates(Polygon poly)
-
checkClosedRings
private void checkClosedRings(Polygon poly)
-
checkClosedRing
private void checkClosedRing(LinearRing ring)
-
checkTooFewPoints
private void checkTooFewPoints(GeometryGraph graph)
-
checkConsistentArea
private void checkConsistentArea(GeometryGraph graph)
Checks that the arrangement of edges in a polygonal geometry graph forms a consistent area.- Parameters:
graph
-- See Also:
ConsistentAreaTester
-
checkNoSelfIntersectingRings
private void checkNoSelfIntersectingRings(GeometryGraph graph)
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
private void checkNoSelfIntersectingRing(EdgeIntersectionList eiList)
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
private void checkHolesInShell(Polygon p, GeometryGraph graph)
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
private void checkHolesNotNested(Polygon p, GeometryGraph graph)
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
private void checkShellsNotNested(MultiPolygon mp, GeometryGraph graph)
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
private void checkShellNotNested(LinearRing shell, Polygon p, GeometryGraph graph)
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
private Coordinate checkShellInsideHole(LinearRing shell, LinearRing hole, GeometryGraph graph)
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
private void checkConnectedInteriors(GeometryGraph graph)
-
-