diff --git a/services-directions/src/main/java/com/mapbox/api/directions/v5/DirectionsService.java b/services-directions/src/main/java/com/mapbox/api/directions/v5/DirectionsService.java index 53d0e8d22..a76184947 100644 --- a/services-directions/src/main/java/com/mapbox/api/directions/v5/DirectionsService.java +++ b/services-directions/src/main/java/com/mapbox/api/directions/v5/DirectionsService.java @@ -46,7 +46,7 @@ public interface DirectionsService { * @param voiceUnits voice units * @param exclude exclude tolls, motorways or more along your route * @param approaches which side of the road to approach a waypoint - * @param waypoints which input coordinates should be treated as waypoints + * @param viaWayPoints which input coordinates should be treated as via waypoints * @param waypointNames custom names for waypoints used for the arrival instruction * @param waypointTargets list of coordinate pairs for drop-off locations * @return the {@link DirectionsResponse} in a Call wrapper @@ -74,7 +74,7 @@ Call getCall( @Query("voice_units") String voiceUnits, @Query("exclude") String exclude, @Query("approaches") String approaches, - @Query("waypoints") String waypoints, + @Query("waypoints") String viaWayPoints, @Query("waypoint_names") String waypointNames, @Query("waypoint_targets") String waypointTargets ); diff --git a/services-directions/src/main/java/com/mapbox/api/directions/v5/MapboxDirections.java b/services-directions/src/main/java/com/mapbox/api/directions/v5/MapboxDirections.java index a2e014663..bdb81d938 100644 --- a/services-directions/src/main/java/com/mapbox/api/directions/v5/MapboxDirections.java +++ b/services-directions/src/main/java/com/mapbox/api/directions/v5/MapboxDirections.java @@ -92,7 +92,7 @@ protected Call initializeCall() { voiceUnits(), exclude(), approaches(), - waypoints(), + viaWayPoints(), waypointNames(), waypointTargets()); } @@ -362,7 +362,7 @@ private static String formatWaypointTargets(Point[] waypointTargets) { abstract String approaches(); @Nullable - abstract String waypoints(); + abstract String viaWayPoints(); @Nullable abstract String waypointNames(); @@ -424,7 +424,7 @@ public abstract static class Builder { private Point destination; private Point origin; private String[] approaches; - private Integer[] waypoints; + private Integer[] viaWayPoints; private String[] waypointNames; private Point[] waypointTargets; @@ -794,7 +794,7 @@ public Builder addApproaches(String... approaches) { abstract Builder approaches(@Nullable String approaches); /** - * Optionally, set which input coordinates should be treated as waypoints. + * Optionally, set which input coordinates should be treated as via way points. *

* Most useful in combination with steps=true and requests based on traces * with high sample rates. Can be an index corresponding to any of the input coordinates, @@ -802,16 +802,16 @@ public Builder addApproaches(String... approaches) { * {@link #steps()} *

* - * @param waypoints integer array of coordinate indices to be used as waypoints + * @param viaWayPoints integer array of coordinate indices to be used as via way points * @return this builder for chaining options together * @since 4.4.0 */ - public Builder addWaypoints(@Nullable @IntRange(from = 0) Integer... waypoints) { - this.waypoints = waypoints; + public Builder addViaWayPoints(@Nullable @IntRange(from = 0) Integer... viaWayPoints) { + this.viaWayPoints = viaWayPoints; return this; } - abstract Builder waypoints(@Nullable String waypoints); + abstract Builder viaWayPoints(@Nullable String viaWayPoints); /** * Custom names for waypoints used for the arrival instruction, @@ -871,20 +871,21 @@ public MapboxDirections build() { + " directions API request."); } - if (waypoints != null) { - if (waypoints.length < 2) { + if (viaWayPoints != null) { + if (viaWayPoints.length < 2) { throw new ServicesException( - "Waypoints must be a list of at least two indexes separated by ';'"); + "Via way points must be a list of at least two indexes separated by ';'"); } - if (waypoints[0] != 0 || waypoints[waypoints.length - 1] != coordinates.size() - 1) { + if (viaWayPoints[0] != 0 + || viaWayPoints[viaWayPoints.length - 1] != coordinates.size() - 1) { throw new ServicesException( - "Waypoints must contain indices of the first and last coordinates" + "Via way points must contain indices of the first and last coordinates" ); } - for (int i = 1; i < waypoints.length - 1; i++) { - if (waypoints[i] < 0 || waypoints[i] >= coordinates.size()) { + for (int i = 1; i < viaWayPoints.length - 1; i++) { + if (viaWayPoints[i] < 0 || viaWayPoints[i] >= coordinates.size()) { throw new ServicesException( - "Waypoints index too large (no corresponding coordinate)"); + "Via way points index too large (no corresponding coordinate)"); } } } @@ -923,7 +924,7 @@ public MapboxDirections build() { bearing(TextUtils.formatBearing(bearings)); annotation(TextUtils.join(",", annotations)); radius(TextUtils.formatRadiuses(radiuses)); - waypoints(TextUtils.join(";", waypoints)); + viaWayPoints(TextUtils.join(";", viaWayPoints)); MapboxDirections directions = autoBuild(); diff --git a/services-directions/src/main/java/com/mapbox/api/directions/v5/models/RouteOptions.java b/services-directions/src/main/java/com/mapbox/api/directions/v5/models/RouteOptions.java index 35cf5a0c9..1ead3f367 100644 --- a/services-directions/src/main/java/com/mapbox/api/directions/v5/models/RouteOptions.java +++ b/services-directions/src/main/java/com/mapbox/api/directions/v5/models/RouteOptions.java @@ -268,7 +268,7 @@ public static Builder builder() { public abstract String approaches(); /** - * Indicates which input coordinates should be treated as waypoints. + * Indicates which input coordinates should be treated as via way points. *

* Most useful in combination with steps=true and requests based on traces * with high sample rates. Can be an index corresponding to any of the input coordinates, @@ -276,12 +276,12 @@ public static Builder builder() { * {@link #steps()} *

* - * @return a string representing indices to be used as waypoints + * @return a string representing indices to be used as via way points * @since 4.4.0 */ - + @SerializedName("waypoints") @Nullable - public abstract String waypoints(); + public abstract String viaWayPoints(); /** * Custom names for waypoints used for the arrival instruction in banners and voice instructions, @@ -558,15 +558,15 @@ public abstract Builder overview( public abstract Builder approaches(String approaches); /** - * The same waypoints the user originally made when the request was made. + * The same via way points the user originally made when the request was made. * - * @param indices to be used as waypoints + * @param indices to be used as via way points * @return this builder for chaining options together * @since 4.4.0 */ @Nullable - public abstract Builder waypoints(@Nullable String indices); + public abstract Builder viaWayPoints(@Nullable String indices); /** * The same waypoint names the user originally made when the request was made. diff --git a/services-directions/src/test/java/com/mapbox/api/directions/v5/MapboxDirectionsTest.java b/services-directions/src/test/java/com/mapbox/api/directions/v5/MapboxDirectionsTest.java index 710a986ae..b740bf400 100644 --- a/services-directions/src/test/java/com/mapbox/api/directions/v5/MapboxDirectionsTest.java +++ b/services-directions/src/test/java/com/mapbox/api/directions/v5/MapboxDirectionsTest.java @@ -236,7 +236,7 @@ public void waypoints_doesGetFormattedInUrlCorrectly() throws Exception { .destination(Point.fromLngLat(13.4930, 9.958)) .addWaypoint(Point.fromLngLat(4.56, 7.89)) .origin(Point.fromLngLat(1.234, 2.345)) - .addWaypoints(0,2) + .addViaWayPoints(0, 2) .accessToken(ACCESS_TOKEN) .build(); String semicolon = "%3B"; @@ -673,7 +673,7 @@ public void build_exceptionThrownWhenLessThanTwoWaypointsProvided() { MapboxDirections.builder() .origin(Point.fromLngLat(2.0, 2.0)) .destination(Point.fromLngLat(4.0, 4.0)) - .addWaypoints(0) + .addViaWayPoints(0) .baseUrl("https://foobar.com") .accessToken(ACCESS_TOKEN) .build(); @@ -685,7 +685,7 @@ public void build_exceptionThrownWhenWaypointsDoNotStartWith0() { .origin(Point.fromLngLat(2.0, 2.0)) .addWaypoint(Point.fromLngLat(3.0, 3.0)) .destination(Point.fromLngLat(4.0, 4.0)) - .addWaypoints(1, 2) + .addViaWayPoints(1, 2) .baseUrl("https://foobar.com") .accessToken(ACCESS_TOKEN) .build(); @@ -697,7 +697,7 @@ public void build_exceptionThrownWhenWaypointDoNotEndWithLast() { .origin(Point.fromLngLat(2.0, 2.0)) .addWaypoint(Point.fromLngLat(3.0, 3.0)) .destination(Point.fromLngLat(4.0, 4.0)) - .addWaypoints(0, 1) + .addViaWayPoints(0, 1) .baseUrl("https://foobar.com") .accessToken(ACCESS_TOKEN) .build(); @@ -709,7 +709,7 @@ public void build_exceptionThrownWhenMiddleWaypointsAreWrong() { .origin(Point.fromLngLat(2.0, 2.0)) .addWaypoint(Point.fromLngLat(3.0, 3.0)) .destination(Point.fromLngLat(4.0, 4.0)) - .addWaypoints(0, 3, 2) + .addViaWayPoints(0, 3, 2) .baseUrl("https://foobar.com") .accessToken(ACCESS_TOKEN) .build();