geos::coverage::CoveragePolygonValidator Class Reference

`#include <CoveragePolygonValidator.h>`

## Public Member Functions

| CoveragePolygonValidator (const Geometry *targetPolygon, std::vector< const Geometry * > &adjPolygons)
void | setGapWidth (double p_gapWidth)
std::unique_ptr< Geometry > | validate ()

## Static Public Member Functions

static std::unique_ptr< Geometry > | validate (const Geometry *targetPolygon, std::vector< const Geometry * > &adjPolygons)
static std::unique_ptr< Geometry > | validate (const Geometry *targetPolygon, std::vector< const Geometry * > &adjPolygons, double gapWidth)

## Detailed Description

Validates that a polygon forms a valid polygonal coverage with the set of polygons adjacent to it. If the polygon is coverage-valid an empty `geos::geom::LineString` is returned. Otherwise, the result is a linear geometry containing the polygon boundary linework causing the invalidity.

A polygon is coverage-valid if:

- The polygon interior does not intersect the interior of other polygons.
- If the polygon boundary intersects another polygon boundary, the vertices and line segments of the intersection match exactly.

The algorithm detects the following coverage errors:

- the polygon is a duplicate of another one
- a polygon boundary segment equals an adjacent segment (with same orientation). This determines that the polygons overlap
- a polygon boundary segment is collinear and overlaps an adjacent segment but is not equal to it
- a polygon boundary segment touches an adjacent segment at a non-vertex point
- a polygon boundary segment crosses into an adjacent polygon
- a polygon boundary segment is in the interior of an adjacent polygon

If any of these errors is present, the target polygon does not form a valid coverage with the adjacent polygons.

The validity rules do not preclude gaps between coverage polygons. However, this class can detect narrow gaps, by specifying a maximum gap width using `setGapWidth(double)`. Note that this will also identify narrow gaps separating disjoint coverage regions, and narrow gores. In some situations it may also produce false positives (i.e. linework identified as part of a gap which is wider than the given width). To fully identify gaps it maybe necessary to use `CoverageUnion` and analyze the holes in the result to see if they are acceptable.

A polygon may be coverage-valid with respect to a set of surrounding polygons, but the collection as a whole may not form a clean coverage. For example, the target polygon boundary may be fully matched by adjacent boundary segments, but the adjacent set contains polygons which are not coverage-valid relative to other ones in the set. A coverage is valid only if every polygon in the coverage is coverage-valid. Use `CoverageValidator` to validate an entire set of polygons.

The adjacent set may contain polygons which do not intersect the target polygon. These are effectively ignored during validation (but may decrease performance).

Author
  Martin Davis

## Constructor & Destructor Documentation

## CoveragePolygonValidator()

geos::coverage::CoveragePolygonValidator::CoveragePolygonValidator | ( | const Geometry * | targetPolygon,
|  | std::vector< const Geometry * > & | adjPolygons )

Create a new validator.

If the gap width is specified, the set of surrounding polygons should include all polygons which are within the gap width distance of the target polygon.

Parameters

  targetPolygon | the geometry to validate
  adjPolygons | the adjacent polygons in the polygonal coverage

## Member Function Documentation

## setGapWidth()

void geos::coverage::CoveragePolygonValidator::setGapWidth | ( | double | p_gapWidth | ) |

Sets the maximum gap width, if narrow gaps are to be detected.

Parameters

  p_gapWidth | the maximum width of gaps to detect

## validate() [1/3]

std::unique_ptr< Geometry > geos::coverage::CoveragePolygonValidator::validate | ( |  | ) |

Validates the coverage polygon against the set of adjacent polygons in the coverage.

Returns
  a linear geometry containing the segments causing invalidity (if any)

## validate() [2/3]

std::unique_ptr< Geometry > geos::coverage::CoveragePolygonValidator::validate | ( | const Geometry * | targetPolygon,
|  | std::vector< const Geometry * > & | adjPolygons )

static

Validates that a polygon is coverage-valid against the surrounding polygons in a polygonal coverage.

Parameters

  targetPolygon | the polygon to validate
  adjPolygons | the adjacent polygons

Returns
  a linear geometry containing the segments causing invalidity (if any)

## validate() [3/3]

std::unique_ptr< Geometry > geos::coverage::CoveragePolygonValidator::validate | ( | const Geometry * | targetPolygon,
|  | std::vector< const Geometry * > & | adjPolygons,
|  | double | gapWidth )

static

Validates that a polygon is coverage-valid against the surrounding polygons in a polygonal coverage, and forms no gaps narrower than a specified width.

The set of surrounding polygons should include all polygons which are within the gap width distance of the target polygon.

Parameters

  targetPolygon | the polygon to validate
  adjPolygons | a collection of the adjacent polygons
  gapWidth | the maximum width of invalid gaps

Returns
  a linear geometry containing the segments causing invalidity (if any)

The documentation for this class was generated from the following file:

- CoveragePolygonValidator.h