-
Notifications
You must be signed in to change notification settings - Fork 35
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
Find nearest vertex sample #319
base: v.next
Are you sure you want to change the base?
Conversation
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.
Looks good, not much to add.
...n/java/com/esri/arcgismaps/sample/findnearestvertex/components/FindNearestVertexViewModel.kt
Outdated
Show resolved
Hide resolved
...n/java/com/esri/arcgismaps/sample/findnearestvertex/components/FindNearestVertexViewModel.kt
Outdated
Show resolved
Hide resolved
...n/java/com/esri/arcgismaps/sample/findnearestvertex/components/FindNearestVertexViewModel.kt
Outdated
Show resolved
Hide resolved
...n/java/com/esri/arcgismaps/sample/findnearestvertex/components/FindNearestVertexViewModel.kt
Outdated
Show resolved
Hide resolved
...n/java/com/esri/arcgismaps/sample/findnearestvertex/components/FindNearestVertexViewModel.kt
Outdated
Show resolved
Hide resolved
val vertexDistance = ((nearestVertexResult?.distance)?.div(5280.0))?.toInt()!! | ||
val coordinateDistance = ((nearestCoordinateResult?.distance)?.div(5280.0))?.toInt()!! |
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.
There's quite a lot going on here, would be a good idea to do the calculations for these in their own method.
Unchecked null asserts are also not a good idea - since vertexDistance
and coordinateDistance
are only used to update _distanceInformationFlow
we can leave these nullable and do a check there.
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.
I've fixed the unchecked null assert, but I can't find a good way to break up the calculation. I feel like if I did I'd need to take the source for the calculation out too, and then that would be 80% of the method anyway. It's less than ideal but this is how the original sample does it.
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.
Did a search and 5280 is the number of feet in a mile. Can do an extension function on Double
:
/**
* Converts a quantity in feet to miles.
*/
private fun Double.feetToMiles(): Double {
return this/5280.0
}
which then allows this:
val vertexDistance = nearestVertexResult?.distance?.feetToMiles()?.toInt()
val coordinateDistance = nearestCoordinateResult?.distance?.feetToMiles()?.toInt()
Which is a bit more readable.
Could do the int conversion in the extension, but I think it's better to leave that as its own thing or move it into the call to DistanceInformation
, or change the typing on DistanceInformation
, (etc).
...n/java/com/esri/arcgismaps/sample/findnearestvertex/components/FindNearestVertexViewModel.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Oliver Smith <[email protected]>
…arcgis-maps-sdk-kotlin-samples into find_nearest_vertex_sample
Description
Adding more functionality to the create and edit geometries working branch
Links and Data
Issues: https://devtopia.esri.com/runtime/kotlin/issues/4989
vTest: https://runtime-kotlin.esri.com/view/all/job/vtest/job/sampleviewer/80/
What To Review
Review like ordinary sample. The delete button is of particular interest since a new dropdown was added to try make it fit and have sufficient detail on what it does. Will fail style checks as README will likely be part of final stage.
How to Test
Run the sample on the sample viewer or the repo.