Skip to content

Commit 04cde89

Browse files
authored
Revert "Support waypoints per route (#1503)" (#1506)
* Revert "Support waypoints per route (#1503)" This reverts commit 796f12d. * changelog v6.9.0
1 parent 02ae0e1 commit 04cde89

13 files changed

Lines changed: 8 additions & 223 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Mapbox welcomes participation and contributions from everyone.
44

55
### main
6+
- Removed `RouteOptions#waypointsPerRoute()` and `RouteOption.Builders#waypointsPerRoute()` methods. [#1506](https://github.com/mapbox/mapbox-java/pull/1506)
7+
- Removed `DirectionsRoute#waypoints` and made non-deprecated `DirectionsResponse#waypoints`. [#1506](https://github.com/mapbox/mapbox-java/pull/1506)
68

79
### v6.9.0-beta.2 - November 03, 2022
810
- Added `RouteOptions#waypointsPerRoute()` and `RouteOption.Builders#waypointsPerRoute()` methods. [#1503](https://github.com/mapbox/mapbox-java/pull/1503)

samples/src/main/java/com/mapbox/samples/BasicDirectionsWaypointsPerRoute.java

Lines changed: 0 additions & 50 deletions
This file was deleted.

services-directions-models/src/main/java/com/mapbox/api/directions/v5/models/DirectionsResponse.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,10 @@ public static Builder builder() {
6666
* List of {@link DirectionsWaypoint} objects. Each {@code waypoint} is an input coordinate
6767
* snapped to the road and path network. The {@code waypoint} appear in the list in the order of
6868
* the input coordinates.
69-
* @deprecated the waypoints are returned in the root of the response only if
70-
* {@link RouteOptions#waypointsPerRoute()} is false. Otherwise they are returned in
71-
* {@link DirectionsRoute#waypoints()}. You can continue to use this and it will work as-is.
72-
* However, it's recommended to use the new approach to distinguish waypoints between routes
73-
* (for example, this is necessary when asking for an EV-optimized route with alternatives).
7469
*
7570
* @return list of {@link DirectionsWaypoint} objects ordered from start of route till the end
7671
* @since 1.0.0
7772
*/
78-
@Deprecated
7973
@Nullable
8074
public abstract List<DirectionsWaypoint> waypoints();
8175

@@ -269,18 +263,12 @@ public abstract static class Builder extends DirectionsJsonObject.Builder<Builde
269263
* List of {@link DirectionsWaypoint} objects. Each {@code waypoint} is an input coordinate
270264
* snapped to the road and path network. The {@code waypoint} appear in the list in the order of
271265
* the input coordinates.
272-
* @deprecated the waypoints are returned in the root of the response only if
273-
* {@link RouteOptions#waypointsPerRoute()} is false. Otherwise they are returned in
274-
* {@link DirectionsRoute#waypoints()}. You can continue to use this and it will work as-is.
275-
* However, it's recommended to use the new approach to distinguish waypoints between routes
276-
* (for example, this is necessary when asking for an EV-optimized route with alternatives).
277266
*
278267
* @param waypoints list of {@link DirectionsWaypoint} objects ordered from start of route till
279268
* the end
280269
* @return this builder for chaining options together
281270
* @since 3.0.0
282271
*/
283-
@Deprecated
284272
public abstract Builder waypoints(@Nullable List<DirectionsWaypoint> waypoints);
285273

286274
/**

services-directions-models/src/main/java/com/mapbox/api/directions/v5/models/DirectionsRoute.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,6 @@ public static Builder builder() {
110110
@Nullable
111111
public abstract List<RouteLeg> legs();
112112

113-
/**
114-
* List of {@link DirectionsWaypoint} objects. Each {@code waypoint} is an input coordinate
115-
* snapped to the road and path network. The {@code waypoint} appear in the list in the order of
116-
* the input coordinates.
117-
* Waypoints are returned in the {@link DirectionsRoute} object only when
118-
* {@link RouteOptions#waypointsPerRoute()} is set to true. Otherwise they are returned
119-
* in the root: {@link DirectionsResponse#waypoints()}.
120-
*
121-
* @return list of {@link DirectionsWaypoint} objects ordered from start of route till the end
122-
*/
123-
@Nullable
124-
public abstract List<DirectionsWaypoint> waypoints();
125-
126113
/**
127114
* Holds onto the parameter information used when making the directions request. Useful for
128115
* re-requesting a directions route using the same information previously used.
@@ -314,21 +301,6 @@ public abstract static class Builder extends DirectionsJsonObject.Builder<Builde
314301
@NonNull
315302
public abstract Builder legs(@Nullable List<RouteLeg> legs);
316303

317-
/**
318-
* List of {@link DirectionsWaypoint} objects. Each {@code waypoint} is an input coordinate
319-
* snapped to the road and path network. The {@code waypoint} appear in the list in the order of
320-
* the input coordinates.
321-
* Waypoints are returned in the {@link DirectionsRoute} object only when
322-
* {@link RouteOptions#waypointsPerRoute()} is set to true. Otherwise they are returned
323-
* in the root: {@link DirectionsResponse#waypoints()}.
324-
*
325-
* @param waypoints list of {@link DirectionsWaypoint} objects ordered from start of route
326-
* till the end
327-
* @return this builder for chaining options together
328-
*/
329-
@NonNull
330-
public abstract Builder waypoints(@Nullable List<DirectionsWaypoint> waypoints);
331-
332304
/**
333305
* Holds onto the parameter information used when making the directions request.
334306
*

services-directions-models/src/main/java/com/mapbox/api/directions/v5/models/RouteOptions.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -688,18 +688,6 @@ public List<Point> waypointTargetsList() {
688688
return ParseUtils.parseToPoints(waypointTargets());
689689
}
690690

691-
/**
692-
* If true, the waypoints array is returned within the route object, else its returned
693-
* at the root of the response body. Defaults to false if unspecified.
694-
* Setting `waypoints_per_route` to true is necessary when asking for an EV-optimized
695-
* route with alternatives, since each alternative route may produce separate
696-
* sets of waypoints (charging stations).
697-
* @return boolean representing the waypoints_per_route value
698-
*/
699-
@SerializedName("waypoints_per_route")
700-
@Nullable
701-
public abstract Boolean waypointsPerRoute();
702-
703691
/**
704692
* A scale from -1 to 1, where -1 biases the route against alleys
705693
* and 1 biases the route toward alleys. If null, default is 0, which is neutral.
@@ -1043,7 +1031,6 @@ public URL toUrl(@NonNull String accessToken) {
10431031
appendQueryParameter(sb, "max_width", maxWidth());
10441032
appendQueryParameter(sb, "max_weight", maxWeight());
10451033
appendQueryParameter(sb, "compute_toll_cost", computeTollCost());
1046-
appendQueryParameter(sb, "waypoints_per_route", waypointsPerRoute());
10471034
appendQueryParameter(sb, "metadata", metadata());
10481035

10491036
Map<String, SerializableJsonElement> unrecognized = unrecognized();
@@ -2044,19 +2031,6 @@ public Builder snappingIncludeStaticClosuresList(
20442031
@SuppressWarnings("checkstyle:javadocmethod")
20452032
public abstract Builder computeTollCost(@Nullable Boolean computeTollCost);
20462033

2047-
/**
2048-
* If true, the waypoints array is returned within the route object, else its returned
2049-
* at the root of the response body. Defaults to false if unspecified.
2050-
* Setting `waypoints_per_route` to true is necessary when asking for an EV-optimized
2051-
* route with alternatives, since each alternative route may produce separate
2052-
* sets of waypoints (charging stations).
2053-
*
2054-
* @param waypointsPerRoute boolean representing the `waypoints_per_route` value
2055-
* @return this builder
2056-
*/
2057-
@NonNull
2058-
public abstract Builder waypointsPerRoute(@Nullable Boolean waypointsPerRoute);
2059-
20602034
/**
20612035
* Whether the response should contain metadata holding versioning information.
20622036
* <p>

services-directions-models/src/test/java/com/mapbox/api/directions/v5/models/DirectionsRouteTest.java

Lines changed: 5 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
import java.io.IOException;
1111
import java.util.ArrayList;
12-
import java.util.Arrays;
13-
import java.util.List;
14-
1512
import org.hamcrest.junit.ExpectedException;
1613
import org.junit.Rule;
1714
import org.junit.Test;
@@ -133,7 +130,9 @@ public void directionsRoute_hasTollCosts() throws IOException {
133130
String uuid = "123";
134131
DirectionsRoute route = DirectionsRoute.fromJson(json, options, uuid);
135132

136-
assertEquals(2, route.tollCosts().size());
133+
DirectionsRoute newRoute = route.toBuilder().routeIndex("0").build();
134+
135+
assertEquals(2, newRoute.tollCosts().size());
137136
}
138137

139138
@Test
@@ -149,72 +148,8 @@ public void directionsRoute_noTollCosts() throws IOException {
149148
String uuid = "123";
150149
DirectionsRoute route = DirectionsRoute.fromJson(json, options, uuid);
151150

152-
assertNull(route.tollCosts());
153-
}
154-
155-
@Test
156-
public void directionsRoute_hasWaypoints() throws IOException {
157-
String json = loadJsonFixture("directions_v5_with_waypoints.json");
158-
RouteOptions options = RouteOptions.builder()
159-
.profile(DirectionsCriteria.PROFILE_DRIVING_TRAFFIC)
160-
.coordinatesList(new ArrayList<Point>() {{
161-
add(Point.fromLngLat(1.0, 1.0));
162-
add(Point.fromLngLat(2.0, 2.0));
163-
}})
164-
.waypointsPerRoute(true)
165-
.build();
166-
String uuid = "123";
167-
DirectionsRoute route = DirectionsRoute.fromJson(json, options, uuid);
168-
169-
assertEquals(2, route.waypoints().size());
170-
}
171-
172-
@Test
173-
public void directionsRouteBuilder_hasWaypoints() {
174-
List<DirectionsWaypoint> waypoints = Arrays.asList(
175-
DirectionsWaypoint.builder()
176-
.name("name1")
177-
.rawLocation(new double[] { 5.6, 7.8 })
178-
.build(),
179-
DirectionsWaypoint.builder()
180-
.name("name2")
181-
.rawLocation(new double[] { 1.2, 3.4 })
182-
.build()
183-
);
184-
DirectionsRoute route = DirectionsRoute.builder()
185-
.duration(12.12)
186-
.distance(34.34)
187-
.waypoints(waypoints)
188-
.build();
189-
190-
assertEquals(waypoints, route.waypoints());
191-
}
192-
193-
194-
@Test
195-
public void directionsRoute_noWaypoints() throws IOException {
196-
String json = loadJsonFixture("directions_v5-with-closure_precision_6.json");
197-
RouteOptions options = RouteOptions.builder()
198-
.profile(DirectionsCriteria.PROFILE_DRIVING_TRAFFIC)
199-
.coordinatesList(new ArrayList<Point>() {{
200-
add(Point.fromLngLat(1.0, 1.0));
201-
add(Point.fromLngLat(2.0, 2.0));
202-
}})
203-
.waypointsPerRoute(true)
204-
.build();
205-
String uuid = "123";
206-
DirectionsRoute route = DirectionsRoute.fromJson(json, options, uuid);
207-
208-
assertNull(route.waypoints());
209-
}
210-
211-
@Test
212-
public void directionsRouteBuilder_noWaypoints() {
213-
DirectionsRoute route = DirectionsRoute.builder()
214-
.duration(12.12)
215-
.distance(34.34)
216-
.build();
151+
DirectionsRoute newRoute = route.toBuilder().routeIndex("0").build();
217152

218-
assertNull(route.waypoints());
153+
assertNull(newRoute.tollCosts());
219154
}
220155
}

services-directions-models/src/test/java/com/mapbox/api/directions/v5/models/RouteOptionsTest.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class RouteOptionsTest extends TestUtils {
3737
*/
3838
private static final String ROUTE_OPTIONS_JSON = "route_options_v5.json";
3939
private static final String ROUTE_OPTIONS_URL =
40-
"https://api.mapbox.com/directions/v5/mapbox/driving/-122.4003312,37.7736941;-122.4187529,37.7689715;-122.4255172,37.7775835?access_token=pk.token&geometries=polyline6&alternatives=false&overview=full&radiuses=%3Bunlimited%3B5.1&steps=true&avoid_maneuver_radius=200.0&bearings=0%2C90%3B90%2C0%3B&layers=-42%3B%3B0&continue_straight=false&annotations=congestion%2Cdistance%2Cduration&language=ru&roundabout_exits=false&voice_instructions=true&banner_instructions=true&voice_units=metric&exclude=toll%2Cferry%2Cpoint%2811.0+-22.0%29&include=hot%2Chov2&approaches=%3Bcurb%3B&waypoints=0%3B1%3B2&waypoint_names=%3BSerangoon+Garden+Market+%26+Food+Centre%3BFunky+%26nAmE*&waypoint_targets=%3B12.2%2C21.2%3B&enable_refresh=true&walking_speed=5.11&walkway_bias=-0.2&alley_bias=0.75&snapping_include_closures=%3Bfalse%3Btrue&snapping_include_static_closures=true%3B%3Bfalse&arrive_by=2021-01-01%27T%2701%3A01&depart_at=2021-02-02%27T%2702%3A02&max_height=1.5&max_width=1.4&max_weight=2.9&compute_toll_cost=true&waypoints_per_route=true&metadata=true";
40+
"https://api.mapbox.com/directions/v5/mapbox/driving/-122.4003312,37.7736941;-122.4187529,37.7689715;-122.4255172,37.7775835?access_token=pk.token&geometries=polyline6&alternatives=false&overview=full&radiuses=%3Bunlimited%3B5.1&steps=true&avoid_maneuver_radius=200.0&bearings=0%2C90%3B90%2C0%3B&layers=-42%3B%3B0&continue_straight=false&annotations=congestion%2Cdistance%2Cduration&language=ru&roundabout_exits=false&voice_instructions=true&banner_instructions=true&voice_units=metric&exclude=toll%2Cferry%2Cpoint%2811.0+-22.0%29&include=hot%2Chov2&approaches=%3Bcurb%3B&waypoints=0%3B1%3B2&waypoint_names=%3BSerangoon+Garden+Market+%26+Food+Centre%3BFunky+%26nAmE*&waypoint_targets=%3B12.2%2C21.2%3B&enable_refresh=true&walking_speed=5.11&walkway_bias=-0.2&alley_bias=0.75&snapping_include_closures=%3Bfalse%3Btrue&snapping_include_static_closures=true%3B%3Bfalse&arrive_by=2021-01-01%27T%2701%3A01&depart_at=2021-02-02%27T%2702%3A02&max_height=1.5&max_width=1.4&max_weight=2.9&compute_toll_cost=true&metadata=true";
4141
private static final String ACCESS_TOKEN = "pk.token";
4242

4343
private final String optionsJson = loadJsonFixture(ROUTE_OPTIONS_JSON);
@@ -349,27 +349,13 @@ public void computeTollCostIsValid_fromJson() {
349349
assertEquals(true, options.computeTollCost());
350350
}
351351

352-
@Test
353-
public void waypointsPerRouteAreValid_fromJson() {
354-
RouteOptions routeOptions = RouteOptions.fromJson(optionsJson);
355-
356-
assertEquals(true, routeOptions.waypointsPerRoute());
357-
}
358-
359352
@Test
360353
public void defaultTollCost() {
361354
RouteOptions options = defaultRouteOptions();
362355

363356
assertNull(options.computeTollCost());
364357
}
365358

366-
@Test
367-
public void defaultWaypointsPerRoute() {
368-
RouteOptions options = defaultRouteOptions();
369-
370-
assertNull(options.waypointsPerRoute());
371-
}
372-
373359
@Test
374360
public void routeOptions_toJson() {
375361
RouteOptions options = routeOptions();
@@ -1060,7 +1046,6 @@ private RouteOptions routeOptions() {
10601046
.enableRefresh(true)
10611047
.metadata(true)
10621048
.computeTollCost(true)
1063-
.waypointsPerRoute(true)
10641049
.build();
10651050
}
10661051

@@ -1167,7 +1152,6 @@ private RouteOptions routeOptionsList() {
11671152
.enableRefresh(true)
11681153
.metadata(true)
11691154
.computeTollCost(true)
1170-
.waypointsPerRoute(true)
11711155
.build();
11721156
}
11731157
}

services-directions-models/src/test/resources/directions_v5_with_waypoints.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

services-directions-models/src/test/resources/route_options_v5.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,5 @@
3636
"max_weight": 2.9,
3737
"enable_refresh": true,
3838
"metadata": true,
39-
"waypoints_per_route": true,
4039
"compute_toll_cost": true
4140
}

0 commit comments

Comments
 (0)