Skip to content

Commit 6e6110a

Browse files
fix via waypoints apis naming (#961)
1 parent f99a072 commit 6e6110a

4 files changed

Lines changed: 32 additions & 31 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public interface DirectionsService {
4646
* @param voiceUnits voice units
4747
* @param exclude exclude tolls, motorways or more along your route
4848
* @param approaches which side of the road to approach a waypoint
49-
* @param waypoints which input coordinates should be treated as waypoints
49+
* @param viaWayPoints which input coordinates should be treated as via waypoints
5050
* @param waypointNames custom names for waypoints used for the arrival instruction
5151
* @param waypointTargets list of coordinate pairs for drop-off locations
5252
* @return the {@link DirectionsResponse} in a Call wrapper
@@ -74,7 +74,7 @@ Call<DirectionsResponse> getCall(
7474
@Query("voice_units") String voiceUnits,
7575
@Query("exclude") String exclude,
7676
@Query("approaches") String approaches,
77-
@Query("waypoints") String waypoints,
77+
@Query("waypoints") String viaWayPoints,
7878
@Query("waypoint_names") String waypointNames,
7979
@Query("waypoint_targets") String waypointTargets
8080
);

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected Call<DirectionsResponse> initializeCall() {
9292
voiceUnits(),
9393
exclude(),
9494
approaches(),
95-
waypoints(),
95+
viaWayPoints(),
9696
waypointNames(),
9797
waypointTargets());
9898
}
@@ -362,7 +362,7 @@ private static String formatWaypointTargets(Point[] waypointTargets) {
362362
abstract String approaches();
363363

364364
@Nullable
365-
abstract String waypoints();
365+
abstract String viaWayPoints();
366366

367367
@Nullable
368368
abstract String waypointNames();
@@ -424,7 +424,7 @@ public abstract static class Builder {
424424
private Point destination;
425425
private Point origin;
426426
private String[] approaches;
427-
private Integer[] waypoints;
427+
private Integer[] viaWayPoints;
428428
private String[] waypointNames;
429429
private Point[] waypointTargets;
430430

@@ -794,24 +794,24 @@ public Builder addApproaches(String... approaches) {
794794
abstract Builder approaches(@Nullable String approaches);
795795

796796
/**
797-
* Optionally, set which input coordinates should be treated as waypoints.
797+
* Optionally, set which input coordinates should be treated as via way points.
798798
* <p>
799799
* Most useful in combination with steps=true and requests based on traces
800800
* with high sample rates. Can be an index corresponding to any of the input coordinates,
801801
* but must contain the first ( 0 ) and last coordinates' index separated by ; .
802802
* {@link #steps()}
803803
* </p>
804804
*
805-
* @param waypoints integer array of coordinate indices to be used as waypoints
805+
* @param viaWayPoints integer array of coordinate indices to be used as via way points
806806
* @return this builder for chaining options together
807807
* @since 4.4.0
808808
*/
809-
public Builder addWaypoints(@Nullable @IntRange(from = 0) Integer... waypoints) {
810-
this.waypoints = waypoints;
809+
public Builder addViaWayPoints(@Nullable @IntRange(from = 0) Integer... viaWayPoints) {
810+
this.viaWayPoints = viaWayPoints;
811811
return this;
812812
}
813813

814-
abstract Builder waypoints(@Nullable String waypoints);
814+
abstract Builder viaWayPoints(@Nullable String viaWayPoints);
815815

816816
/**
817817
* Custom names for waypoints used for the arrival instruction,
@@ -871,20 +871,21 @@ public MapboxDirections build() {
871871
+ " directions API request.");
872872
}
873873

874-
if (waypoints != null) {
875-
if (waypoints.length < 2) {
874+
if (viaWayPoints != null) {
875+
if (viaWayPoints.length < 2) {
876876
throw new ServicesException(
877-
"Waypoints must be a list of at least two indexes separated by ';'");
877+
"Via way points must be a list of at least two indexes separated by ';'");
878878
}
879-
if (waypoints[0] != 0 || waypoints[waypoints.length - 1] != coordinates.size() - 1) {
879+
if (viaWayPoints[0] != 0
880+
|| viaWayPoints[viaWayPoints.length - 1] != coordinates.size() - 1) {
880881
throw new ServicesException(
881-
"Waypoints must contain indices of the first and last coordinates"
882+
"Via way points must contain indices of the first and last coordinates"
882883
);
883884
}
884-
for (int i = 1; i < waypoints.length - 1; i++) {
885-
if (waypoints[i] < 0 || waypoints[i] >= coordinates.size()) {
885+
for (int i = 1; i < viaWayPoints.length - 1; i++) {
886+
if (viaWayPoints[i] < 0 || viaWayPoints[i] >= coordinates.size()) {
886887
throw new ServicesException(
887-
"Waypoints index too large (no corresponding coordinate)");
888+
"Via way points index too large (no corresponding coordinate)");
888889
}
889890
}
890891
}
@@ -923,7 +924,7 @@ public MapboxDirections build() {
923924
bearing(TextUtils.formatBearing(bearings));
924925
annotation(TextUtils.join(",", annotations));
925926
radius(TextUtils.formatRadiuses(radiuses));
926-
waypoints(TextUtils.join(";", waypoints));
927+
viaWayPoints(TextUtils.join(";", viaWayPoints));
927928

928929
MapboxDirections directions = autoBuild();
929930

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,20 +268,20 @@ public static Builder builder() {
268268
public abstract String approaches();
269269

270270
/**
271-
* Indicates which input coordinates should be treated as waypoints.
271+
* Indicates which input coordinates should be treated as via way points.
272272
* <p>
273273
* Most useful in combination with steps=true and requests based on traces
274274
* with high sample rates. Can be an index corresponding to any of the input coordinates,
275275
* but must contain the first ( 0 ) and last coordinates' index separated by ; .
276276
* {@link #steps()}
277277
* </p>
278278
*
279-
* @return a string representing indices to be used as waypoints
279+
* @return a string representing indices to be used as via way points
280280
* @since 4.4.0
281281
*/
282-
282+
@SerializedName("waypoints")
283283
@Nullable
284-
public abstract String waypoints();
284+
public abstract String viaWayPoints();
285285

286286
/**
287287
* Custom names for waypoints used for the arrival instruction in banners and voice instructions,
@@ -558,15 +558,15 @@ public abstract Builder overview(
558558
public abstract Builder approaches(String approaches);
559559

560560
/**
561-
* The same waypoints the user originally made when the request was made.
561+
* The same via way points the user originally made when the request was made.
562562
*
563-
* @param indices to be used as waypoints
563+
* @param indices to be used as via way points
564564
* @return this builder for chaining options together
565565
* @since 4.4.0
566566
*/
567567

568568
@Nullable
569-
public abstract Builder waypoints(@Nullable String indices);
569+
public abstract Builder viaWayPoints(@Nullable String indices);
570570

571571
/**
572572
* The same waypoint names the user originally made when the request was made.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public void waypoints_doesGetFormattedInUrlCorrectly() throws Exception {
236236
.destination(Point.fromLngLat(13.4930, 9.958))
237237
.addWaypoint(Point.fromLngLat(4.56, 7.89))
238238
.origin(Point.fromLngLat(1.234, 2.345))
239-
.addWaypoints(0,2)
239+
.addViaWayPoints(0, 2)
240240
.accessToken(ACCESS_TOKEN)
241241
.build();
242242
String semicolon = "%3B";
@@ -673,7 +673,7 @@ public void build_exceptionThrownWhenLessThanTwoWaypointsProvided() {
673673
MapboxDirections.builder()
674674
.origin(Point.fromLngLat(2.0, 2.0))
675675
.destination(Point.fromLngLat(4.0, 4.0))
676-
.addWaypoints(0)
676+
.addViaWayPoints(0)
677677
.baseUrl("https://foobar.com")
678678
.accessToken(ACCESS_TOKEN)
679679
.build();
@@ -685,7 +685,7 @@ public void build_exceptionThrownWhenWaypointsDoNotStartWith0() {
685685
.origin(Point.fromLngLat(2.0, 2.0))
686686
.addWaypoint(Point.fromLngLat(3.0, 3.0))
687687
.destination(Point.fromLngLat(4.0, 4.0))
688-
.addWaypoints(1, 2)
688+
.addViaWayPoints(1, 2)
689689
.baseUrl("https://foobar.com")
690690
.accessToken(ACCESS_TOKEN)
691691
.build();
@@ -697,7 +697,7 @@ public void build_exceptionThrownWhenWaypointDoNotEndWithLast() {
697697
.origin(Point.fromLngLat(2.0, 2.0))
698698
.addWaypoint(Point.fromLngLat(3.0, 3.0))
699699
.destination(Point.fromLngLat(4.0, 4.0))
700-
.addWaypoints(0, 1)
700+
.addViaWayPoints(0, 1)
701701
.baseUrl("https://foobar.com")
702702
.accessToken(ACCESS_TOKEN)
703703
.build();
@@ -709,7 +709,7 @@ public void build_exceptionThrownWhenMiddleWaypointsAreWrong() {
709709
.origin(Point.fromLngLat(2.0, 2.0))
710710
.addWaypoint(Point.fromLngLat(3.0, 3.0))
711711
.destination(Point.fromLngLat(4.0, 4.0))
712-
.addWaypoints(0, 3, 2)
712+
.addViaWayPoints(0, 3, 2)
713713
.baseUrl("https://foobar.com")
714714
.accessToken(ACCESS_TOKEN)
715715
.build();

0 commit comments

Comments
 (0)