Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
* Interface that defines the distance service.
*
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
public interface DistanceService {

/**
Expand All @@ -28,7 +30,9 @@ public interface DistanceService {
* @param coordinates converted to a {@link MultiPoint#toJson()}.
* @return The {@link DistanceResponse} in a Call wrapper
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
@POST("distances/v1/{user}/{profile}")
Call<DistanceResponse> getCall(
// NOTE: DistanceServiceRx should be updated as well
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,22 @@
*
* @see <a href="https://www.mapbox.com/api-documentation/?language=Java#distance">Mapbox Distance API documentation</a>
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
public class MapboxDistance extends MapboxService<DistanceResponse> {

protected Builder builder = null;
private DistanceService service = null;
private Call<DistanceResponse> call = null;
private Gson gson;

@Deprecated
protected MapboxDistance(Builder builder) {
this.builder = builder;
}

@Deprecated
protected Gson getGson() {
// Gson instance with type adapters
if (gson == null) {
Expand All @@ -62,6 +66,7 @@ protected Gson getGson() {
return gson;
}

@Deprecated
private DistanceService getService() {
//No need to recreate it
if (service != null) {
Expand All @@ -88,7 +93,9 @@ private DistanceService getService() {
*
* @return call
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
public Call<DistanceResponse> getCall() {
// No need to recreate it
if (call != null) {
Expand All @@ -112,7 +119,9 @@ public Call<DistanceResponse> getCall() {
* @return The distance v1 response.
* @throws IOException Signals that an I/O exception of some sort has occurred.
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
@Override
public Response<DistanceResponse> executeCall() throws IOException {
return getCall().execute();
Expand All @@ -123,7 +132,9 @@ public Response<DistanceResponse> executeCall() throws IOException {
*
* @param callback A Retrofit callback.
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
@Override
public void enqueueCall(Callback<DistanceResponse> callback) {
getCall().enqueue(callback);
Expand All @@ -133,7 +144,9 @@ public void enqueueCall(Callback<DistanceResponse> callback) {
* Cancel the call
*
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
@Override
public void cancelCall() {
getCall().cancel();
Expand All @@ -144,7 +157,9 @@ public void cancelCall() {
*
* @return cloned call
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
@Override
public Call<DistanceResponse> cloneCall() {
return getCall().clone();
Expand All @@ -154,7 +169,9 @@ public Call<DistanceResponse> cloneCall() {
* Builds your distance query by adding parameters.
*
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
public static class Builder<T extends Builder> extends MapboxBuilder {

private String accessToken;
Expand All @@ -167,7 +184,9 @@ public static class Builder<T extends Builder> extends MapboxBuilder {
* Constructor
*
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
public Builder() {
}

Expand All @@ -176,7 +195,9 @@ public Builder() {
* {@link DirectionsCriteria#PROFILE_DEFAULT_USER}.
* @return Builder
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
public T setUser(String user) {
this.user = user;
return (T) this;
Expand All @@ -185,7 +206,9 @@ public T setUser(String user) {
/**
* @return the user as String.
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
public String getUser() {
return user;
}
Expand All @@ -199,7 +222,9 @@ public String getUser() {
* {@link DirectionsCriteria} constants.
* @return Builder
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
public T setProfile(String profile) {
this.profile = profile;
return (T) this;
Expand All @@ -209,7 +234,9 @@ public T setProfile(String profile) {
* @return String containing A directions profile ID; either {@code driving},
* {@code walking}, or {@code cycling}.
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
public String getProfile() {
return profile;
}
Expand All @@ -220,11 +247,13 @@ public RequestBody getCoordinates() {
MultiPoint.fromCoordinates(coordinates).toJson());
}

@Deprecated
public T setCoordinates(List<Position> coordinates) {
this.coordinates = coordinates;
return (T) this;
}

@Deprecated
private void validateProfile() throws ServicesException {
if (profile == null || !(profile.equals(DirectionsCriteria.PROFILE_CYCLING)
|| profile.equals(DirectionsCriteria.PROFILE_DRIVING)
Expand All @@ -234,6 +263,7 @@ private void validateProfile() throws ServicesException {
}
}

@Deprecated
private void validateTrace() throws ServicesException {
if (coordinates == null || coordinates.size() <= 0) {
throw new ServicesException("Using Mapbox Distance API requires to set some coordinates.");
Expand All @@ -252,7 +282,9 @@ private void validateTrace() throws ServicesException {
* this API.
* @return Builder
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
@Override
public T setAccessToken(String accessToken) {
this.accessToken = accessToken;
Expand All @@ -262,7 +294,9 @@ public T setAccessToken(String accessToken) {
/**
* @return Mapbox access token
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
@Override
public String getAccessToken() {
return this.accessToken;
Expand All @@ -279,7 +313,9 @@ public T setClientAppName(String appName) {
* @param baseUrl base url used as end point
* @return Builder
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
@Override
public T setBaseUrl(String baseUrl) {
super.baseUrl = baseUrl;
Expand All @@ -293,7 +329,9 @@ public T setBaseUrl(String baseUrl) {
* @throws ServicesException Generic Exception occurring when something with the Distance
* API goes wrong.
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
@Override
public MapboxDistance build() throws ServicesException {
validateAccessToken(accessToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
* A custom deserializer that assumes a {@link MultiPoint} string.
*
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
public class DistanceGeometryDeserializer implements JsonDeserializer<Geometry> {

/**
Expand All @@ -26,7 +28,9 @@ public class DistanceGeometryDeserializer implements JsonDeserializer<Geometry>
* @throws JsonParseException This exception is raised if there is a serious issue that occurs
* during parsing of a Json string.
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
@Override
public Geometry deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.util.List;

@Deprecated
public class DistanceResponse extends FeatureCollection {

private String code;
Expand All @@ -18,19 +19,24 @@ public class DistanceResponse extends FeatureCollection {
*
* @param features List of {@link Feature}.
* @since 2.0.0
* @deprecated replace by the Directions Matrix API.
*/
@Deprecated
protected DistanceResponse(List<Feature> features) {
super(features);
}

@Deprecated
public String getCode() {
return code;
}

@Deprecated
public void setCode(String code) {
this.code = code;
}

@Deprecated
public int[][] getDurations() {

int[][] tempDurations = new int[durations.size()][durations.size()];
Expand Down
21 changes: 1 addition & 20 deletions mapbox/libjava-services/src/test/fixtures/distance_v1.json
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
{
"code": "Ok",
"durations": [
[
0,
2930.1,
4784
],
[
2952.8,
0,
5320.6
],
[
4765.9,
5275.5,
0
]
]
}
{"code":"Ok","durations":[[0,3837.1,5177.2],[3883.4,0,5334],[5150.3,5288.1,0]]}