Class CoverageValidator
A polygonal coverage is a set of polygons which may be edge-adjacent but do
not overlap.
Coverage algorithms (such as CoverageUnion
or simplification)
generally require the input coverage to be valid to produce correct results.
A polygonal coverage is valid if:
- The interiors of all polygons do not intersect (are disjoint). This is the case if no polygon has a boundary which intersects the interior of another polygon, and no two polygons are identical.
- If the boundaries of polygons intersect, the vertices and line segments of the intersection match exactly.
A valid coverage may contain holes (regions of no coverage).
Sometimes it is desired to detect whether coverages contain
narrow gaps between polygons
(which can be a result of digitizing error or misaligned data).
This class can detect narrow gaps,
by specifying a maximum gap width using setGapWidth(double)
.
Note that this also identifies narrow gaps separating disjoint coverage regions,
and narrow gores.
In some situations it may also produce false positives
(linework identified as part of a gap which is actually wider).
See CoverageGapFinder
for an alternate way to detect gaps which may be more accurate.
- Author:
- Martin Davis
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
hasInvalidResult
(Geometry[] validateResult) Tests if some element of an array of geometries is a coverage invalidity indicator.static boolean
Tests whether a polygonal coverage is valid.void
setGapWidth
(double gapWidth) Sets the maximum gap width, if narrow gaps are to be detected.Geometry[]
validate()
Validates the polygonal coverage.static Geometry[]
Validates that a set of polygons forms a valid polygonal coverage, and returns linear geometries indicating the locations of invalidities, if any.static Geometry[]
Validates that a set of polygons forms a valid polygonal coverage and contains no gaps narrower than a specified width.
-
Constructor Details
-
CoverageValidator
Creates a new coverage validator- Parameters:
coverage
- a array of polygons representing a polygonal coverage
-
-
Method Details
-
isValid
Tests whether a polygonal coverage is valid.- Parameters:
coverage
- an array of polygons forming a coverage- Returns:
- true if the coverage is valid
-
hasInvalidResult
Tests if some element of an array of geometries is a coverage invalidity indicator.- Parameters:
validateResult
- an array produced by a polygonal coverage validation- Returns:
- true if the result has at least one invalid indicator
-
validate
Validates that a set of polygons forms a valid polygonal coverage, and returns linear geometries indicating the locations of invalidities, if any.- Parameters:
coverage
- an array of polygons forming a coverage- Returns:
- an array of linear geometries indicating coverage errors, or nulls
-
validate
Validates that a set of polygons forms a valid polygonal coverage and contains no gaps narrower than a specified width. The result is an array of linear geometries indicating the locations of invalidities, or null if the polygon is coverage-valid.- Parameters:
coverage
- an array of polygons forming a coveragegapWidth
- the maximum width of invalid gaps- Returns:
- an array of linear geometries indicating coverage errors, or nulls
-
setGapWidth
public void setGapWidth(double gapWidth) Sets the maximum gap width, if narrow gaps are to be detected.- Parameters:
gapWidth
- the maximum width of gaps to detect
-
validate
Validates the polygonal coverage. The result is an array of the same size as the input coverage. Each array entry is either null, or if the polygon does not form a valid coverage, a linear geometry containing the boundary segments which intersect polygon interiors, which are mismatched, or form gaps (if checked).- Returns:
- an array of nulls or linear geometries
-