Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean polygon geometries; remove holes, fix right hand rule #1961

Merged
merged 2 commits into from
Dec 9, 2024

Conversation

Sujanadh
Copy link
Contributor

@Sujanadh Sujanadh commented Dec 9, 2024

What type of PR is this? (check all applicable)

  • πŸ• Feature
  • πŸ› Bug Fix
  • πŸ“ Documentation
  • πŸ§‘β€πŸ’» Refactor
  • βœ… Test
  • πŸ€– Build or CI
  • ❓ Other (please specify)

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 ring
  • ensure_right_hand_rule: It ensures each polygon follows right hand rule
  • create_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:
image

With disjoint mulitpolygon:
image

Single AOI for both cases:
Case I: After removing holes, fixing right hand rule and merging all polygons
image

Case II: Disjoint Multipolygon creating single AOI
image

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?

@Sujanadh Sujanadh requested a review from spwoodcock December 9, 2024 05:58
@Sujanadh Sujanadh self-assigned this Dec 9, 2024
@github-actions github-actions bot added enhancement New feature or request backend Related to backend code labels Dec 9, 2024
Copy link
Member

@spwoodcock spwoodcock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, this should help project creation a lot 😁

@spwoodcock spwoodcock merged commit 740504c into development Dec 9, 2024
5 checks passed
@spwoodcock spwoodcock deleted the feat/clean-polygon branch December 9, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to backend code enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants