|
| static std::vector< std::unique_ptr< Geometry > > | clean (std::vector< const Geometry * > &coverage, double snapDistance, int mergeStrategy, double maxWidth) |
| |
| static std::vector< std::unique_ptr< Geometry > > | clean (std::vector< const Geometry * > &coverage, double snapDistance, double maxWidth) |
| |
| static std::vector< std::unique_ptr< Geometry > > | cleanOverlapGap (std::vector< const Geometry * > &coverage, int mergeStrategy, double maxWidth) |
| |
| static std::vector< std::unique_ptr< Geometry > > | cleanGapWidth (std::vector< const Geometry * > &coverage, double maxWidth) |
| |
|
static std::unique_ptr< Geometry > | toGeometry (std::vector< std::unique_ptr< SegmentString > > &segStrings, const GeometryFactory *geomFact) |
| |
Cleans the linework of a set of polygonal geometries to form a valid polygonal coverage. The input is an array of valid Polygon or MultiPolygon geometries which may contain topological errors such as overlaps and gaps. Empty or non-polygonal inputs are removed. Linework is snapped together to eliminate small discrepancies. Overlaps are merged with an adjacent polygon, according to a given merge strategy. Gaps narrower than a given width are filled and merged with an adjacent polygon. The output is an array of polygonal geometries forming a valid polygonal coverage.
** Snapping **
Snapping to nearby vertices and line segment snapping is used to improve noding robustness and eliminate small errors in an efficient way, By default this uses a very small snapping distance based on the extent of the input data. The snapping distance may be specified explicitly. This can reduce the number of overlaps and gaps that need to be merged, and reduce the risk of spikes formed by merging gaps. However, a large snapping distance may introduce undesirable data alteration.
** Overlap Merging **
Overlaps are merged with an adjacent polygon chosen according to a specified merge strategy. The supported strategies are:
This allows sorting the input according to some criteria to provide a priority for merging gaps.
** Gap Merging **
Gaps which are wider than a given distance are merged with an adjacent polygon. Polygon width is determined as twice the radius of the MaximumInscribedCircle of the gap polygon. Gaps are merged with the adjacent polygon with longest shared border. Empty holes in input polygons are treated as gaps, and may be filled in. Gaps which are not fully enclosed ("inlets") are not removed.
Cleaning can be run on a valid coverage to remove gaps.
The clean result is an array of polygonal geometries which match one-to-one with the input array. A result item may be null if:
- the input item is non-polygonal or empty
- the input item is so small it is snapped to collapse
- the input item is covered by another input item (which may be a larger or a duplicate (nearly or exactly) geometry)
The result is a valid coverage according to CoverageValidator::isValid();
** Known Issues **
- Long narrow gaps adjacent to multiple polygons may form spikes when merged with a single polygon.
** Future Enhancements **
- Provide an area-based tolerance for gap merging
- Prevent long narrow gaps from forming spikes by partitioning them before merging.
- Allow merging narrow parts of a gap while leaving wider portions.
- Support a priority value for each input polygon to control overlap and gap merging (this could also allow blocking polygons from being merge targets)
- See also
- CoverageValidator
- Author
- Martin Davis