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 @@ -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
Expand Down Expand Up @@ -74,7 +74,7 @@ Call<DirectionsResponse> 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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected Call<DirectionsResponse> initializeCall() {
voiceUnits(),
exclude(),
approaches(),
waypoints(),
viaWayPoints(),
waypointNames(),
waypointTargets());
}
Expand Down Expand Up @@ -362,7 +362,7 @@ private static String formatWaypointTargets(Point[] waypointTargets) {
abstract String approaches();

@Nullable
abstract String waypoints();
abstract String viaWayPoints();

@Nullable
abstract String waypointNames();
Expand Down Expand Up @@ -424,7 +424,7 @@ public abstract static class Builder {
private Point destination;
private Point origin;
private String[] approaches;
private Integer[] waypoints;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was correct as-was. Should be waypoints as one word, no capital P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're correct. Will update in a follow-up PR. Thanks for flagging 🙇

private Integer[] viaWayPoints;
private String[] waypointNames;
private Point[] waypointTargets;

Expand Down Expand Up @@ -794,24 +794,24 @@ 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.
* <p>
* 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,
* but must contain the first ( 0 ) and last coordinates' index separated by ; .
* {@link #steps()}
* </p>
*
* @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,
Expand Down Expand Up @@ -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)");
}
}
}
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,20 +268,20 @@ 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.
* <p>
* 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,
* but must contain the first ( 0 ) and last coordinates' index separated by ; .
* {@link #steps()}
* </p>
*
* @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,
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down