GEOS 3.15.0dev
|
#include <CoverageCleaner.h>
Public Member Functions | |
CoverageCleaner (std::vector< const Geometry * > &coverage) | |
void | setSnappingDistance (double snapDistance) |
void | setOverlapMergeStrategy (int mergeStrategy) |
void | setGapMaximumWidth (double maxWidth) |
void | clean () |
std::vector< std::unique_ptr< Geometry > > | getResult () |
std::vector< const Polygon * > | getOverlaps () |
std::vector< const Polygon * > | getMergedGaps () |
std::unique_ptr< Geometry > | toGeometry (std::vector< SegmentString * > &segStrings, const GeometryFactory *geomFact) |
std::unique_ptr< Geometry > | node (std::vector< const Geometry * > &coverage, double snapDistance) |
CoverageCleaner (const CoverageCleaner &)=delete | |
CoverageCleaner & | operator= (const CoverageCleaner &)=delete |
Static Public Member Functions | |
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 Public Attributes | |
static constexpr int | MERGE_LONGEST_BORDER = 0 |
static constexpr int | MERGE_MAX_AREA = 1 |
static constexpr int | MERGE_MIN_AREA = 2 |
static constexpr int | MERGE_MIN_INDEX = 3 |
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 result is a valid coverage according to CoverageValidator::isValid();
** Known Issues **
** Future Enhancements **
geos::coverage::CoverageCleaner::CoverageCleaner | ( | std::vector< const Geometry * > & | coverage | ) |
Create a new cleaner instance for a set of polygonal geometries.
coverage | an array of polygonal geometries to clean |
|
delete |
Disable copy construction and assignment. Apparently needed to make this class compile under MSVC. (See https://stackoverflow.com/q/29565299)
void geos::coverage::CoverageCleaner::clean | ( | ) |
Cleans the coverage.
|
static |
Cleans a set of polygonal geometries to form a valid coverage, using the default overlap merge strategy MERGE_LONGEST_BORDER
.
coverage | an array of polygonal geometries to clean |
snapDistance | the distance tolerance for snapping |
maxWidth | the maximum width of gaps to merge |
|
static |
Cleans a set of polygonal geometries to form a valid coverage, allowing all cleaning parameters to be specified.
coverage | an array of polygonal geometries to clean |
snapDistance | the distance tolerance for snapping |
mergeStrategy | the strategy to use for merging overlaps |
maxWidth | the maximum width of gaps to merge |
|
static |
Cleans a set of polygonal geometries to form a valid coverage, with default snapping tolerance and overlap merging, and merging gaps which are narrower than a specified width.
coverage | an array of polygonal geometries to clean |
maxWidth | the maximum width of gaps to merge |
|
static |
Cleans a set of polygonal geometries to form a valid coverage, using the default snapping distance tolerance.
coverage | an array of polygonal geometries to clean |
mergeStrategy | the strategy to use for merging overlaps |
maxWidth | the maximum width of gaps to merge |
std::vector< const Polygon * > geos::coverage::CoverageCleaner::getMergedGaps | ( | ) |
Gets polygons representing the gaps in the input which have been merged.
std::vector< const Polygon * > geos::coverage::CoverageCleaner::getOverlaps | ( | ) |
Gets polygons representing the overlaps in the input, which have been merged.
std::vector< std::unique_ptr< Geometry > > geos::coverage::CoverageCleaner::getResult | ( | ) |
Gets the cleaned coverage.
void geos::coverage::CoverageCleaner::setGapMaximumWidth | ( | double | maxWidth | ) |
Sets the maximum width of the gaps that will be filled and merged. The width of a gap is twice the radius of the Maximum Inscribed Circle in the gap polygon, A width of zero prevents gaps from being merged.
maxWidth | the maximum gap width to merge |
void geos::coverage::CoverageCleaner::setOverlapMergeStrategy | ( | int | mergeStrategy | ) |
Sets the overlap merge strategy to use. The default is MERGE_LONGEST_BORDER
.
mergeStrategy | the merge strategy code |
void geos::coverage::CoverageCleaner::setSnappingDistance | ( | double | snapDistance | ) |
Sets the snapping distance tolerance. The default is to use a small fraction of the input extent diameter. A distance of zero prevents snapping from being used.
snapDistance | the snapping distance tolerance |
|
staticconstexpr |
Merge strategy that chooses polygon with longest common border
|
staticconstexpr |
Merge strategy that chooses polygon with maximum area
|
staticconstexpr |
Merge strategy that chooses polygon with minimum area
|
staticconstexpr |
Merge strategy that chooses polygon with smallest input index