-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Routable points support for services-geocoding (#1522)
- Loading branch information
1 parent
d112384
commit c7a13df
Showing
11 changed files
with
611 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
services-geocoding/src/main/java/com/mapbox/api/geocoding/v5/models/RoutablePoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.mapbox.api.geocoding.v5.models; | ||
|
||
import androidx.annotation.Nullable; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import com.google.gson.Gson; | ||
import com.google.gson.TypeAdapter; | ||
import com.google.gson.annotations.SerializedName; | ||
import com.mapbox.geojson.Point; | ||
|
||
/** | ||
* Object representing {@link CarmenFeature}'s routable point. | ||
*/ | ||
@AutoValue | ||
public abstract class RoutablePoint { | ||
|
||
/** | ||
* A string representing the routable point name. | ||
* | ||
* @return routable point name | ||
*/ | ||
@Nullable | ||
@SerializedName("name") | ||
public abstract String name(); | ||
|
||
/** | ||
* A {@link Point} object which represents the routable point location. | ||
* | ||
* @return a GeoJson {@link Point} which defines the routable point location | ||
*/ | ||
@Nullable | ||
public Point coordinate() { | ||
final double[] coordinate = rawCoordinate(); | ||
if (coordinate != null && coordinate.length == 2) { | ||
return Point.fromLngLat(coordinate[0], coordinate[1]); | ||
} | ||
return null; | ||
} | ||
|
||
// No public access thus, we lessen enforcement on mutability here. | ||
@Nullable | ||
@SerializedName("coordinates") | ||
@SuppressWarnings("mutable") | ||
abstract double[] rawCoordinate(); | ||
|
||
/** | ||
* Convert current instance values into another Builder to quickly change one or more values. | ||
* | ||
* @return a new instance of {@link Builder} | ||
*/ | ||
@SuppressWarnings("unused") | ||
public abstract Builder toBuilder(); | ||
|
||
/** | ||
* Gson type adapter for parsing Gson to this class. | ||
* | ||
* @param gson the built {@link Gson} object | ||
* @return the type adapter for this class | ||
*/ | ||
public static TypeAdapter<RoutablePoint> typeAdapter(Gson gson) { | ||
return new AutoValue_RoutablePoint.GsonTypeAdapter(gson); | ||
} | ||
|
||
/** | ||
* This builder can be used to set the values describing the {@link RoutablePoint}. | ||
*/ | ||
@AutoValue.Builder | ||
@SuppressWarnings("unused") | ||
public abstract static class Builder { | ||
|
||
/** | ||
* A string representing the routable point name. | ||
* | ||
* @param name routable point name | ||
* @return this builder for chaining options together | ||
*/ | ||
public abstract Builder name(@Nullable String name); | ||
|
||
/** | ||
* Raw coordinates (longitude and latitude, order matters) | ||
* that represent the routable point location. | ||
* | ||
* @param coordinate raw coordinates that represent the routable point location | ||
* @return this builder for chaining options together | ||
*/ | ||
public abstract Builder rawCoordinate(@Nullable double[] coordinate); | ||
|
||
/** | ||
* Build a new {@link RoutablePoint} object. | ||
* | ||
* @return a new {@link RoutablePoint} using the provided values in this builder | ||
*/ | ||
public abstract RoutablePoint build(); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
services-geocoding/src/main/java/com/mapbox/api/geocoding/v5/models/RoutablePoints.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.mapbox.api.geocoding.v5.models; | ||
|
||
import androidx.annotation.Nullable; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import com.google.gson.Gson; | ||
import com.google.gson.TypeAdapter; | ||
import com.google.gson.annotations.SerializedName; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* An object with the routable points for the {@link CarmenFeature}. | ||
*/ | ||
@AutoValue | ||
public abstract class RoutablePoints { | ||
|
||
/** | ||
* A list of routable points for the {@link CarmenFeature}, or null if no points were found. | ||
* | ||
* @return a list of routable points for the {@link CarmenFeature}, | ||
* or null if no points were found | ||
*/ | ||
@Nullable | ||
@SerializedName("points") | ||
public abstract List<RoutablePoint> points(); | ||
|
||
/** | ||
* Convert current instance values into another Builder to quickly change one or more values. | ||
* | ||
* @return a new instance of {@link Builder} | ||
*/ | ||
@SuppressWarnings("unused") | ||
public abstract Builder toBuilder(); | ||
|
||
/** | ||
* Gson type adapter for parsing Gson to this class. | ||
* | ||
* @param gson the built {@link Gson} object | ||
* @return the type adapter for this class | ||
*/ | ||
public static TypeAdapter<RoutablePoints> typeAdapter(Gson gson) { | ||
return new AutoValue_RoutablePoints.GsonTypeAdapter(gson); | ||
} | ||
|
||
/** | ||
* This builder can be used to set the values describing the {@link RoutablePoints}. | ||
*/ | ||
@AutoValue.Builder | ||
@SuppressWarnings("unused") | ||
public abstract static class Builder { | ||
|
||
/** | ||
* A list of routable points for the {@link CarmenFeature}, | ||
* or null if no points were found. | ||
* | ||
* @param points a list of routable points for the {@link CarmenFeature}, | ||
* or null if no points were found | ||
* @return this builder for chaining options together | ||
*/ | ||
public abstract Builder points(@Nullable List<RoutablePoint> points); | ||
|
||
/** | ||
* Build a new {@link RoutablePoints} object. | ||
* | ||
* @return a new {@link RoutablePoints} using the provided values in this builder | ||
*/ | ||
public abstract RoutablePoints build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.