Skip to content

Commit c41e3f8

Browse files
author
Cameron Mace
authored
Deprecated all distance methods (#405)
* deprecated all distance methods * removed deprecated tag from package info files
1 parent c093380 commit c41e3f8

5 files changed

Lines changed: 53 additions & 20 deletions

File tree

mapbox/libjava-services/src/main/java/com/mapbox/services/api/distance/v1/DistanceService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
* Interface that defines the distance service.
1616
*
1717
* @since 2.0.0
18+
* @deprecated replace by the Directions Matrix API.
1819
*/
20+
@Deprecated
1921
public interface DistanceService {
2022

2123
/**
@@ -28,7 +30,9 @@ public interface DistanceService {
2830
* @param coordinates converted to a {@link MultiPoint#toJson()}.
2931
* @return The {@link DistanceResponse} in a Call wrapper
3032
* @since 2.0.0
33+
* @deprecated replace by the Directions Matrix API.
3134
*/
35+
@Deprecated
3236
@POST("distances/v1/{user}/{profile}")
3337
Call<DistanceResponse> getCall(
3438
// NOTE: DistanceServiceRx should be updated as well

mapbox/libjava-services/src/main/java/com/mapbox/services/api/distance/v1/MapboxDistance.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,22 @@
3939
*
4040
* @see <a href="https://www.mapbox.com/api-documentation/?language=Java#distance">Mapbox Distance API documentation</a>
4141
* @since 2.0.0
42+
* @deprecated replace by the Directions Matrix API.
4243
*/
44+
@Deprecated
4345
public class MapboxDistance extends MapboxService<DistanceResponse> {
4446

4547
protected Builder builder = null;
4648
private DistanceService service = null;
4749
private Call<DistanceResponse> call = null;
4850
private Gson gson;
4951

52+
@Deprecated
5053
protected MapboxDistance(Builder builder) {
5154
this.builder = builder;
5255
}
5356

57+
@Deprecated
5458
protected Gson getGson() {
5559
// Gson instance with type adapters
5660
if (gson == null) {
@@ -62,6 +66,7 @@ protected Gson getGson() {
6266
return gson;
6367
}
6468

69+
@Deprecated
6570
private DistanceService getService() {
6671
//No need to recreate it
6772
if (service != null) {
@@ -88,7 +93,9 @@ private DistanceService getService() {
8893
*
8994
* @return call
9095
* @since 2.0.0
96+
* @deprecated replace by the Directions Matrix API.
9197
*/
98+
@Deprecated
9299
public Call<DistanceResponse> getCall() {
93100
// No need to recreate it
94101
if (call != null) {
@@ -112,7 +119,9 @@ public Call<DistanceResponse> getCall() {
112119
* @return The distance v1 response.
113120
* @throws IOException Signals that an I/O exception of some sort has occurred.
114121
* @since 2.0.0
122+
* @deprecated replace by the Directions Matrix API.
115123
*/
124+
@Deprecated
116125
@Override
117126
public Response<DistanceResponse> executeCall() throws IOException {
118127
return getCall().execute();
@@ -123,7 +132,9 @@ public Response<DistanceResponse> executeCall() throws IOException {
123132
*
124133
* @param callback A Retrofit callback.
125134
* @since 2.0.0
135+
* @deprecated replace by the Directions Matrix API.
126136
*/
137+
@Deprecated
127138
@Override
128139
public void enqueueCall(Callback<DistanceResponse> callback) {
129140
getCall().enqueue(callback);
@@ -133,7 +144,9 @@ public void enqueueCall(Callback<DistanceResponse> callback) {
133144
* Cancel the call
134145
*
135146
* @since 2.0.0
147+
* @deprecated replace by the Directions Matrix API.
136148
*/
149+
@Deprecated
137150
@Override
138151
public void cancelCall() {
139152
getCall().cancel();
@@ -144,7 +157,9 @@ public void cancelCall() {
144157
*
145158
* @return cloned call
146159
* @since 2.0.0
160+
* @deprecated replace by the Directions Matrix API.
147161
*/
162+
@Deprecated
148163
@Override
149164
public Call<DistanceResponse> cloneCall() {
150165
return getCall().clone();
@@ -154,7 +169,9 @@ public Call<DistanceResponse> cloneCall() {
154169
* Builds your distance query by adding parameters.
155170
*
156171
* @since 2.0.0
172+
* @deprecated replace by the Directions Matrix API.
157173
*/
174+
@Deprecated
158175
public static class Builder<T extends Builder> extends MapboxBuilder {
159176

160177
private String accessToken;
@@ -167,7 +184,9 @@ public static class Builder<T extends Builder> extends MapboxBuilder {
167184
* Constructor
168185
*
169186
* @since 2.0.0
187+
* @deprecated replace by the Directions Matrix API.
170188
*/
189+
@Deprecated
171190
public Builder() {
172191
}
173192

@@ -176,7 +195,9 @@ public Builder() {
176195
* {@link DirectionsCriteria#PROFILE_DEFAULT_USER}.
177196
* @return Builder
178197
* @since 2.0.0
198+
* @deprecated replace by the Directions Matrix API.
179199
*/
200+
@Deprecated
180201
public T setUser(String user) {
181202
this.user = user;
182203
return (T) this;
@@ -185,7 +206,9 @@ public T setUser(String user) {
185206
/**
186207
* @return the user as String.
187208
* @since 2.0.0
209+
* @deprecated replace by the Directions Matrix API.
188210
*/
211+
@Deprecated
189212
public String getUser() {
190213
return user;
191214
}
@@ -199,7 +222,9 @@ public String getUser() {
199222
* {@link DirectionsCriteria} constants.
200223
* @return Builder
201224
* @since 2.0.0
225+
* @deprecated replace by the Directions Matrix API.
202226
*/
227+
@Deprecated
203228
public T setProfile(String profile) {
204229
this.profile = profile;
205230
return (T) this;
@@ -209,7 +234,9 @@ public T setProfile(String profile) {
209234
* @return String containing A directions profile ID; either {@code driving},
210235
* {@code walking}, or {@code cycling}.
211236
* @since 2.0.0
237+
* @deprecated replace by the Directions Matrix API.
212238
*/
239+
@Deprecated
213240
public String getProfile() {
214241
return profile;
215242
}
@@ -220,11 +247,13 @@ public RequestBody getCoordinates() {
220247
MultiPoint.fromCoordinates(coordinates).toJson());
221248
}
222249

250+
@Deprecated
223251
public T setCoordinates(List<Position> coordinates) {
224252
this.coordinates = coordinates;
225253
return (T) this;
226254
}
227255

256+
@Deprecated
228257
private void validateProfile() throws ServicesException {
229258
if (profile == null || !(profile.equals(DirectionsCriteria.PROFILE_CYCLING)
230259
|| profile.equals(DirectionsCriteria.PROFILE_DRIVING)
@@ -234,6 +263,7 @@ private void validateProfile() throws ServicesException {
234263
}
235264
}
236265

266+
@Deprecated
237267
private void validateTrace() throws ServicesException {
238268
if (coordinates == null || coordinates.size() <= 0) {
239269
throw new ServicesException("Using Mapbox Distance API requires to set some coordinates.");
@@ -252,7 +282,9 @@ private void validateTrace() throws ServicesException {
252282
* this API.
253283
* @return Builder
254284
* @since 2.0.0
285+
* @deprecated replace by the Directions Matrix API.
255286
*/
287+
@Deprecated
256288
@Override
257289
public T setAccessToken(String accessToken) {
258290
this.accessToken = accessToken;
@@ -262,7 +294,9 @@ public T setAccessToken(String accessToken) {
262294
/**
263295
* @return Mapbox access token
264296
* @since 2.0.0
297+
* @deprecated replace by the Directions Matrix API.
265298
*/
299+
@Deprecated
266300
@Override
267301
public String getAccessToken() {
268302
return this.accessToken;
@@ -279,7 +313,9 @@ public T setClientAppName(String appName) {
279313
* @param baseUrl base url used as end point
280314
* @return Builder
281315
* @since 2.0.0
316+
* @deprecated replace by the Directions Matrix API.
282317
*/
318+
@Deprecated
283319
@Override
284320
public T setBaseUrl(String baseUrl) {
285321
super.baseUrl = baseUrl;
@@ -293,7 +329,9 @@ public T setBaseUrl(String baseUrl) {
293329
* @throws ServicesException Generic Exception occurring when something with the Distance
294330
* API goes wrong.
295331
* @since 2.0.0
332+
* @deprecated replace by the Directions Matrix API.
296333
*/
334+
@Deprecated
297335
@Override
298336
public MapboxDistance build() throws ServicesException {
299337
validateAccessToken(accessToken);

mapbox/libjava-services/src/main/java/com/mapbox/services/api/distance/v1/gson/DistanceGeometryDeserializer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
* A custom deserializer that assumes a {@link MultiPoint} string.
1414
*
1515
* @since 2.0.0
16+
* @deprecated replace by the Directions Matrix API.
1617
*/
18+
@Deprecated
1719
public class DistanceGeometryDeserializer implements JsonDeserializer<Geometry> {
1820

1921
/**
@@ -26,7 +28,9 @@ public class DistanceGeometryDeserializer implements JsonDeserializer<Geometry>
2628
* @throws JsonParseException This exception is raised if there is a serious issue that occurs
2729
* during parsing of a Json string.
2830
* @since 2.0.0
31+
* @deprecated replace by the Directions Matrix API.
2932
*/
33+
@Deprecated
3034
@Override
3135
public Geometry deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
3236
throws JsonParseException {

mapbox/libjava-services/src/main/java/com/mapbox/services/api/distance/v1/models/DistanceResponse.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import java.util.List;
88

9+
@Deprecated
910
public class DistanceResponse extends FeatureCollection {
1011

1112
private String code;
@@ -18,19 +19,24 @@ public class DistanceResponse extends FeatureCollection {
1819
*
1920
* @param features List of {@link Feature}.
2021
* @since 2.0.0
22+
* @deprecated replace by the Directions Matrix API.
2123
*/
24+
@Deprecated
2225
protected DistanceResponse(List<Feature> features) {
2326
super(features);
2427
}
2528

29+
@Deprecated
2630
public String getCode() {
2731
return code;
2832
}
2933

34+
@Deprecated
3035
public void setCode(String code) {
3136
this.code = code;
3237
}
3338

39+
@Deprecated
3440
public int[][] getDurations() {
3541

3642
int[][] tempDurations = new int[durations.size()][durations.size()];
Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1 @@
1-
{
2-
"code": "Ok",
3-
"durations": [
4-
[
5-
0,
6-
2930.1,
7-
4784
8-
],
9-
[
10-
2952.8,
11-
0,
12-
5320.6
13-
],
14-
[
15-
4765.9,
16-
5275.5,
17-
0
18-
]
19-
]
20-
}
1+
{"code":"Ok","durations":[[0,3837.1,5177.2],[3883.4,0,5334],[5150.3,5288.1,0]]}

0 commit comments

Comments
 (0)