Skip to content

Commit

Permalink
added DirectionsWaypoint#distance property
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasPaczos committed Feb 7, 2022
1 parent 7576641 commit 899ce65
Showing 1 changed file with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mapbox.api.directions.v5.models;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.auto.value.AutoValue;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand Down Expand Up @@ -37,7 +38,7 @@ public static Builder builder() {
public abstract String name();

/**
* A {@link Point} representing this waypoint location.
* A {@link Point} representing this waypoint location. This point is snapped to the road network.
*
* @return GeoJson Point representing this waypoint location
* @since 3.0.0
Expand All @@ -47,17 +48,18 @@ public Point location() {
return Point.fromLngLat(rawLocation()[0], rawLocation()[1]);
}

/**
* A {@link Point} representing this waypoint location.
*
* @return GeoJson Point representing this waypoint location
* @since 3.0.0
*/
@NonNull
@SerializedName("location")
@SuppressWarnings("mutable")
abstract double[] rawLocation();

/**
* The straight-line distance from the coordinate specified in the query
* to the location it was snapped to.
*/
@Nullable
public abstract Double distance();

/**
* Convert the current {@link DirectionsWaypoint} to its builder holding the currently assigned
* values. This allows you to modify a single property and then rebuild the object resulting in
Expand Down Expand Up @@ -112,7 +114,8 @@ public abstract static class Builder {
public abstract Builder name(@NonNull String name);

/**
* The rawLocation as a double array. Once the {@link DirectionsWaypoint} objects created,
* The rawLocation as a double array representing a location snapped to the road network.
* Once the {@link DirectionsWaypoint} objects created,
* this raw location gets converted into a {@link Point} object and is public exposed as such.
* The double array should have a length of two, index 0 being the longitude and index 1 being
* latitude.
Expand All @@ -124,6 +127,15 @@ public abstract static class Builder {
*/
public abstract Builder rawLocation(@NonNull double[] rawLocation);

/**
* The straight-line distance from the coordinate specified in the query
* to the location it was snapped to.
*
* @param distance distance from original requested location
*/
@Nullable
public abstract Builder distance(@Nullable Double distance);

/**
* Build a new {@link DirectionsWaypoint} object.
*
Expand Down

0 comments on commit 899ce65

Please sign in to comment.