-
Notifications
You must be signed in to change notification settings - Fork 122
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
Show error Dialog and Don't allow user to draw mis-shapen polygons #3056
base: master
Are you sure you want to change the base?
Conversation
As per the issue description, the button's text in the dialog should be |
.../main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt
Outdated
Show resolved
Hide resolved
...main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskViewModel.kt
Outdated
Show resolved
Hide resolved
...main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskViewModel.kt
Outdated
Show resolved
Hide resolved
...main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskViewModel.kt
Outdated
Show resolved
Hide resolved
.../main/java/com/google/android/ground/ui/datacollection/tasks/polygon/DrawAreaTaskFragment.kt
Show resolved
Hide resolved
val showDialog = remember { mutableStateOf(true) } | ||
if (showDialog.value) { |
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.
We don't need this. ConfirmationDialog already maintains an internal state for visiblity
@@ -167,13 +184,21 @@ internal constructor( | |||
} | |||
|
|||
fun completePolygon() { | |||
check(LineString(vertices).isClosed()) { "Polygon is not complete" } |
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.
Why have we removed this check?
fun orientation(a: Coordinates, b: Coordinates, c: Coordinates): Int { | ||
val value = (b.lat - a.lat) * (c.lng - b.lng) - (b.lng - a.lng) * (c.lat - b.lat) | ||
return when { | ||
value > 0 -> 1 // Clockwise | ||
value < 0 -> -1 // Counter-clockwise | ||
else -> 0 // Collinear | ||
} | ||
} | ||
|
||
fun onSegment(a: Coordinates, b: Coordinates, c: Coordinates): Boolean { | ||
return c.lat in minOf(a.lat, b.lat)..maxOf(a.lat, b.lat) && | ||
c.lng in minOf(a.lng, b.lng)..maxOf(a.lng, b.lng) | ||
} |
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.
These can be pulled out and made private.
import com.google.android.ground.model.geometry.Coordinates | ||
|
||
/** Checks if two line segments intersect. */ | ||
fun segmentsIntersect(p1: Coordinates, p2: Coordinates, q1: Coordinates, q2: Coordinates): Boolean { |
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.
Please use a better function name
Fixes #2604
@shobhitagarwal1612 PTAL?
Screen.Recording.2025-02-19.at.6.40.32.PM.mov