diff --git a/modules/core/src/main/java/org/locationtech/jts/coverage/CoverageValidator.java b/modules/core/src/main/java/org/locationtech/jts/coverage/CoverageValidator.java index fffb552cd..f570221e7 100644 --- a/modules/core/src/main/java/org/locationtech/jts/coverage/CoverageValidator.java +++ b/modules/core/src/main/java/org/locationtech/jts/coverage/CoverageValidator.java @@ -37,7 +37,7 @@ *

* 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)}. @@ -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. * + *

Known Bugs

+ * If the specified gap width is large, some narrow gaps may not be identified. + * * @author Martin Davis * */ @@ -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.