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

Find nearest vertex sample #319

Open
wants to merge 14 commits into
base: v.next
Choose a base branch
from
Open

Conversation

darryl-lynch
Copy link
Collaborator

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.

@01smito01 01smito01 self-requested a review February 10, 2025 17:33
Copy link
Collaborator

@01smito01 01smito01 left a 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.

Copy link
Collaborator

@colinanderson colinanderson left a comment

Choose a reason for hiding this comment

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

@darryl-lynch looks good. A few comments to consider.

val distanceInformationFlow = _distanceInformationFlow.asStateFlow()

// create a message dialog view model for handling error messages
val messageDialogVM = MessageDialogViewModel()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think our general rule is to not use abbreviations so it would be ViewModel instead of VM but maybe a different style is used in the samples.

}.onFailure { error ->
messageDialogVM.showMessageDialog(
title = "Failed to load map",
description = error.message.toString()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need toString() here? Isn't the message already a string?

}

/**
* Finds the nearest vertex from [mapPoint] from the [polygon].
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't the comment be something like "Finds the nearest vertex on the polygon to the map point"?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe mapPoint should be clickPoint or tapPoint to make it clearer where the point comes from.

GeometryEngine.nearestCoordinate(geometry = polygon, point = mapPoint)
// set the nearest coordinate graphic's geometry to the nearest coordinate
nearestCoordinateGraphic.geometry = nearestCoordinateResult?.coordinate
// calculate the distances to the nearest vertex and nearest coordinate then convert to miles
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think m or km would be better since more parts of the world use metric measurements.

The image in the design shows km.

* Converts a quantity in feet to miles.
*/
private fun Double.feetToMiles(): Double {
return this/5280.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

We'd usually put spaces around the operator e.g. this / 5280.0

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this conversion correct for the spatial reference being used? You can use LinearUnit methods to convert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants