-
Notifications
You must be signed in to change notification settings - Fork 133
[Draw/walk area task] Prevent user from drawing self-intersecting polygons #3235
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
[Draw/walk area task] Prevent user from drawing self-intersecting polygons #3235
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3235 +/- ##
=========================================
Coverage 67.16% 67.17%
- Complexity 1411 1415 +4
=========================================
Files 303 303
Lines 7642 7664 +22
Branches 774 785 +11
=========================================
+ Hits 5133 5148 +15
Misses 2076 2076
- Partials 433 440 +7
🚀 New features to boost your workflow:
|
...ain/java/org/groundplatform/android/ui/datacollection/tasks/polygon/DrawAreaTaskViewModel.kt
Outdated
Show resolved
Hide resolved
...ain/java/org/groundplatform/android/ui/datacollection/tasks/polygon/DrawAreaTaskViewModel.kt
Outdated
Show resolved
Hide resolved
...ain/java/org/groundplatform/android/ui/datacollection/tasks/polygon/DrawAreaTaskViewModel.kt
Outdated
Show resolved
Hide resolved
...ain/java/org/groundplatform/android/ui/datacollection/tasks/polygon/DrawAreaTaskViewModel.kt
Outdated
Show resolved
Hide resolved
...ain/java/org/groundplatform/android/ui/datacollection/tasks/polygon/DrawAreaTaskViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/groundplatform/android/ui/util/PolygonUtil.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/groundplatform/android/ui/util/PolygonUtil.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/groundplatform/android/ui/util/PolygonUtil.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/groundplatform/android/ui/util/PolygonUtil.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/groundplatform/android/ui/util/PolygonUtil.kt
Outdated
Show resolved
Hide resolved
...ain/java/org/groundplatform/android/ui/datacollection/tasks/polygon/DrawAreaTaskViewModel.kt
Outdated
Show resolved
Hide resolved
...ain/java/org/groundplatform/android/ui/datacollection/tasks/polygon/DrawAreaTaskViewModel.kt
Outdated
Show resolved
Hide resolved
...ain/java/org/groundplatform/android/ui/datacollection/tasks/polygon/DrawAreaTaskViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/groundplatform/android/ui/util/PolygonUtil.kt
Outdated
Show resolved
Hide resolved
…on-intersection' into anandwana001/3234/complete-polygon-intersection
app/src/main/java/org/groundplatform/android/ui/util/PolygonUtil.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/groundplatform/android/ui/util/PolygonUtil.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/groundplatform/android/ui/util/PolygonUtil.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app/src/main/java/org/groundplatform/android/ui/util/PolygonUtil.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/groundplatform/android/ui/util/PolygonUtil.kt
Outdated
Show resolved
Hide resolved
...main/java/org/groundplatform/android/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt
Show resolved
Hide resolved
@anandwana001 Note I updated the PR description to reflect the new behavior rather than a description of the code |
Fixes #3234
This PR introduces a full system to detect and handle polygon self-intersections:
Implemented isSelfIntersecting(vertices) to check for crossing edges, with support for both open polylines and closed polygons.
Integrated validation into the workflow:
Add Point: checks the newly added edge, reverts the vertex, and shows a dialog if self-intersection is detected.
Complete Polygon: validates the would-be closed ring (vertices + first), blocking completion and showing a dialog if invalid.
Ensured the intersection flag resets when geometry is valid, preventing stale “intersecting” states.
Updated onFeatureUpdated to disable the Complete button when a polygon is invalid.
Added unit tests covering:
Open and closed polygons
Adjacent edges sharing vertices
True self-intersections (e.g., “X” shapes)
Edge cases like empty list, single point, or triangles
This provides reliable guardrails to prevent creating invalid polygons and ensures user feedback when intersections occur.
Screen.Recording.2025-08-21.at.9.16.31.AM.mov
@gino-m @jo-spek PTAL?