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

Remove trailing zeros from coordinates #424

Merged
merged 4 commits into from
Apr 14, 2017
Merged

Remove trailing zeros from coordinates #424

merged 4 commits into from
Apr 14, 2017

Conversation

cammace
Copy link

@cammace cammace commented Mar 30, 2017

closes #338

@cammace cammace self-assigned this Mar 30, 2017
@@ -27,24 +28,27 @@
* @since 1.0.0
*/
private Position(double longitude, double latitude, double altitude) {
// Used to remove any trailing zeros and prevent a coordinate being over 7 significant figures.
DecimalFormat decimalFormat = new DecimalFormat("0.######");
Copy link
Member

Choose a reason for hiding this comment

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

Because this same logic is used in several place, how about exposing it as static utility method?

@@ -47,4 +51,10 @@ public static String join(CharSequence delimiter, Object[] tokens) {
return sb.toString();
}

public static String formatCoordinate(double coordinate) {
// Used to remove any trailing zeros and prevent a coordinate being over 7 significant figures.
Copy link
Member

Choose a reason for hiding this comment

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

@cammace Let's make it a javadoc instead.

public static String formatCoordinate(double coordinate) {
// Used to remove any trailing zeros and prevent a coordinate being over 7 significant figures.
DecimalFormat decimalFormat = new DecimalFormat("0.######", new DecimalFormatSymbols(Locale.US));
return String.format(Locale.US, "%s",
Copy link
Member

Choose a reason for hiding this comment

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

@cammace We have a constant for the default locale already.

@zugaldia zugaldia mentioned this pull request Apr 14, 2017
@cammace cammace merged commit d1a263f into master Apr 14, 2017
@cammace cammace deleted the cam-338-fix branch April 14, 2017 17:28
@cammace cammace mentioned this pull request Apr 15, 2017
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When building the directions API call we add trailing zeros to digits
2 participants