Skip to content

Commit

Permalink
Add function CoverageValidator.isValid(coverage, gapwidth)
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Mar 4, 2025
1 parent 7e9a424 commit 41dacde
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* <p>
* A valid coverage may contain holes (regions of no coverage).
* Sometimes it is desired to detect whether coverages contain
* narrow gaps between polygons
* holes which are 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 {@link #setGapWidth(double)}.
Expand All @@ -47,6 +47,9 @@
* (linework identified as part of a gap which is actually wider).
* See {@link CoverageGapFinder} for an alternate way to detect gaps which may be more accurate.
*
* <h3>Known Bugs</h3>
* If the specified gap width is large, some narrow gaps may not be identified.
*
* @author Martin Davis
*
*/
Expand All @@ -62,6 +65,20 @@ public static boolean isValid(Geometry[] coverage) {
return ! hasInvalidResult(v.validate());
}

/**
* Tests whether a polygonal coverage is valid
* and contains no gaps narrower than a specified width.
*
* @param coverage an array of polygons forming a coverage
* @param gapWidth the maximum width of invalid gaps
* @return true if the coverage is valid with no narrow gaps
*/
public static boolean isValid(Geometry[] coverage, double gapWidth) {
CoverageValidator v = new CoverageValidator(coverage);
v.setGapWidth(gapWidth);
return ! hasInvalidResult(v.validate());
}

/**
* Tests if some element of an array of geometries is a coverage invalidity
* indicator.
Expand Down

0 comments on commit 41dacde

Please sign in to comment.