Clean polygon geometries; remove holes, fix right hand rule #1961
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this? (check all applicable)
Related Issue
Describe this PR
This PR updates the postgis utils to clean the polygon geojson before any operations such as split by square , split by algorithm, create project outline, generate data extracts. It includes:
remove_holes
: It checks for any holes present in the polygon and removes it using exterior ringensure_right_hand_rule
: It ensures each polygon follows right hand rulecreate_single_polygon
: It creates a single polygon, mostly a project outline case, while creating projects or generating data extracts. Here, if the geojson has disjoint multipolygons, then it applies a convex hull to create a single AOI, or else it will use an exterior ring to create a single AOI. During data extracts, it won't apply convex hull; we will get data extracts in individual polygons inside MulitPolygon.With exterior ring for normal multipolygon case:
With disjoint mulitpolygon:
Single AOI for both cases:
Case I: After removing holes, fixing right hand rule and merging all polygons
Case II: Disjoint Multipolygon creating single AOI
Alternative Approaches Considered
Did you attempt any other approaches that are not documented in code?
Review Guide
Notes for the reviewer. How to test this change?
Checklist before requesting a review
[optional] What gif best describes this PR or how it makes you feel?