Skip to content

Commit c807d61

Browse files
author
Guardiola31337
committed
fix waypoints apis naming for map matching and directions services - from waypoints to waypoint indices
1 parent aba088c commit c807d61

File tree

5 files changed

+63
-61
lines changed

5 files changed

+63
-61
lines changed

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

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,38 @@ public interface DirectionsService {
1919
* Constructs the html call using the information passed in through the
2020
* {@link MapboxDirections.Builder}.
2121
*
22-
* @param userAgent the user agent
23-
* @param user the user
24-
* @param profile the profile directions should use
25-
* @param coordinates the coordinates the route should follow
26-
* @param accessToken Mapbox access token
27-
* @param alternatives define whether you want to receive more then one route
28-
* @param geometries route geometry
29-
* @param overview route full, simplified, etc.
30-
* @param radiuses start at the most efficient point within the radius
31-
* @param steps define if you'd like the route steps
32-
* @param bearings used to filter the road segment the waypoint will be placed on by
33-
* direction and dictates the angle of approach
34-
* @param continueStraight define whether the route should continue straight even if the
35-
* route will be slower
36-
* @param annotations an annotations object that contains additional details about each
37-
* line segment along the route geometry. Each entry in an
38-
* annotations field corresponds to a coordinate along the route
39-
* geometry
40-
* @param language language of returned turn-by-turn text instructions
41-
* @param roundaboutExits Add extra step when roundabouts occur with additional information
42-
* for the user
43-
* @param voiceInstructions request that the response contain voice instruction information,
44-
* useful for navigation
45-
* @param bannerInstructions request that the response contain banner instruction information,
46-
* useful for navigation
47-
* @param voiceUnits voice units
48-
* @param exclude exclude tolls, motorways or more along your route
49-
* @param approaches which side of the road to approach a waypoint
50-
* @param silentWaypointIndices which input coordinates should be treated as silent waypoints
51-
* @param waypointNames custom names for waypoints used for the arrival instruction
52-
* @param waypointTargets list of coordinate pairs for drop-off locations
22+
* @param userAgent the user agent
23+
* @param user the user
24+
* @param profile the profile directions should use
25+
* @param coordinates the coordinates the route should follow
26+
* @param accessToken Mapbox access token
27+
* @param alternatives define whether you want to receive more then one route
28+
* @param geometries route geometry
29+
* @param overview route full, simplified, etc.
30+
* @param radiuses start at the most efficient point within the radius
31+
* @param steps define if you'd like the route steps
32+
* @param bearings used to filter the road segment the waypoint will be placed on by
33+
* direction and dictates the angle of approach
34+
* @param continueStraight define whether the route should continue straight even if the
35+
* route will be slower
36+
* @param annotations an annotations object that contains additional details about each
37+
* line segment along the route geometry. Each entry in an
38+
* annotations field corresponds to a coordinate along the route
39+
* geometry
40+
* @param language language of returned turn-by-turn text instructions
41+
* @param roundaboutExits Add extra step when roundabouts occur with additional information
42+
* for the user
43+
* @param voiceInstructions request that the response contain voice instruction information,
44+
* useful for navigation
45+
* @param bannerInstructions request that the response contain banner instruction information,
46+
* useful for navigation
47+
* @param voiceUnits voice units
48+
* @param exclude exclude tolls, motorways or more along your route
49+
* @param approaches which side of the road to approach a waypoint
50+
* @param waypointIndices which input coordinates should be treated as waypoints/separate legs.
51+
* Note: coordinate indices not added here act as silent waypoints
52+
* @param waypointNames custom names for waypoints used for the arrival instruction
53+
* @param waypointTargets list of coordinate pairs for drop-off locations
5354
* @return the {@link DirectionsResponse} in a Call wrapper
5455
* @since 1.0.0
5556
*/
@@ -75,7 +76,7 @@ Call<DirectionsResponse> getCall(
7576
@Query("voice_units") String voiceUnits,
7677
@Query("exclude") String exclude,
7778
@Query("approaches") String approaches,
78-
@Query("waypoints") String silentWaypointIndices,
79+
@Query("waypoints") String waypointIndices,
7980
@Query("waypoint_names") String waypointNames,
8081
@Query("waypoint_targets") String waypointTargets
8182
);

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

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected Call<DirectionsResponse> initializeCall() {
9292
voiceUnits(),
9393
exclude(),
9494
approaches(),
95-
silentWaypointIndices(),
95+
waypointIndices(),
9696
waypointNames(),
9797
waypointTargets());
9898
}
@@ -235,7 +235,7 @@ private List<DirectionsRoute> generateRouteOptions(Response<DirectionsResponse>
235235
RouteOptions.builder()
236236
.profile(profile())
237237
.coordinates(coordinates())
238-
.waypointIndices(silentWaypointIndices())
238+
.waypointIndices(waypointIndices())
239239
.waypointNames(waypointNames())
240240
.waypointTargets(waypointTargets())
241241
.continueStraight(continueStraight())
@@ -363,7 +363,7 @@ private static String formatWaypointTargets(Point[] waypointTargets) {
363363
abstract String approaches();
364364

365365
@Nullable
366-
abstract String silentWaypointIndices();
366+
abstract String waypointIndices();
367367

368368
@Nullable
369369
abstract String waypointNames();
@@ -425,7 +425,7 @@ public abstract static class Builder {
425425
private Point destination;
426426
private Point origin;
427427
private String[] approaches;
428-
private Integer[] silentWaypointIndices;
428+
private Integer[] waypointIndices;
429429
private String[] waypointNames;
430430
private Point[] waypointTargets;
431431

@@ -795,26 +795,25 @@ public Builder addApproaches(String... approaches) {
795795
abstract Builder approaches(@Nullable String approaches);
796796

797797
/**
798-
* Optionally, set which input coordinates should be treated as silent waypoints.
798+
* Optionally, set which input coordinates should be treated as waypoints / separate legs.
799+
* Note: coordinate indices not added here act as silent waypoints
799800
* <p>
800801
* Most useful in combination with steps=true and requests based on traces
801802
* with high sample rates. Can be an index corresponding to any of the input coordinates,
802803
* but must contain the first ( 0 ) and last coordinates' index separated by ; .
803804
* {@link #steps()}
804805
* </p>
805806
*
806-
* @param silentWaypointIndices integer array of coordinate indices to be used as
807-
* silent waypoints
807+
* @param waypointIndices integer array of coordinate indices to be used as waypoints
808808
* @return this builder for chaining options together
809809
* @since 4.4.0
810810
*/
811-
public Builder addSilentWaypointIndices(@Nullable @IntRange(from = 0)
812-
Integer... silentWaypointIndices) {
813-
this.silentWaypointIndices = silentWaypointIndices;
811+
public Builder addWaypointIndices(@Nullable @IntRange(from = 0) Integer... waypointIndices) {
812+
this.waypointIndices = waypointIndices;
814813
return this;
815814
}
816815

817-
abstract Builder silentWaypointIndices(@Nullable String silentWaypointIndices);
816+
abstract Builder waypointIndices(@Nullable String waypointIndices);
818817

819818
/**
820819
* Custom names for waypoints used for the arrival instruction,
@@ -874,22 +873,21 @@ public MapboxDirections build() {
874873
+ " directions API request.");
875874
}
876875

877-
if (silentWaypointIndices != null) {
878-
if (silentWaypointIndices.length < 2) {
876+
if (waypointIndices != null) {
877+
if (waypointIndices.length < 2) {
879878
throw new ServicesException(
880-
"Silent waypoints must be a list of at least two indexes separated by ';'");
879+
"Waypoints must be a list of at least two indexes separated by ';'");
881880
}
882-
if (silentWaypointIndices[0] != 0
883-
|| silentWaypointIndices[silentWaypointIndices.length - 1]
881+
if (waypointIndices[0] != 0 || waypointIndices[waypointIndices.length - 1]
884882
!= coordinates.size() - 1) {
885883
throw new ServicesException(
886-
"Silent waypoints must contain indices of the first and last coordinates"
884+
"Waypoints must contain indices of the first and last coordinates"
887885
);
888886
}
889-
for (int i = 1; i < silentWaypointIndices.length - 1; i++) {
890-
if (silentWaypointIndices[i] < 0 || silentWaypointIndices[i] >= coordinates.size()) {
887+
for (int i = 1; i < waypointIndices.length - 1; i++) {
888+
if (waypointIndices[i] < 0 || waypointIndices[i] >= coordinates.size()) {
891889
throw new ServicesException(
892-
"Silent waypoints index too large (no corresponding coordinate)");
890+
"Waypoints index too large (no corresponding coordinate)");
893891
}
894892
}
895893
}
@@ -924,7 +922,7 @@ public MapboxDirections build() {
924922
bearing(TextUtils.formatBearing(bearings));
925923
annotation(TextUtils.join(",", annotations));
926924
radius(TextUtils.formatRadiuses(radiuses));
927-
silentWaypointIndices(TextUtils.join(";", silentWaypointIndices));
925+
waypointIndices(TextUtils.join(";", waypointIndices));
928926

929927
MapboxDirections directions = autoBuild();
930928

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() {
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-
.addSilentWaypointIndices(0, 2)
239+
.addWaypointIndices(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-
.addSilentWaypointIndices(0)
676+
.addWaypointIndices(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-
.addSilentWaypointIndices(1, 2)
688+
.addWaypointIndices(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-
.addSilentWaypointIndices(0, 1)
700+
.addWaypointIndices(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-
.addSilentWaypointIndices(0, 3, 2)
712+
.addWaypointIndices(0, 3, 2)
713713
.baseUrl("https://foobar.com")
714714
.accessToken(ACCESS_TOKEN)
715715
.build();

services-matching/src/main/java/com/mapbox/api/matching/v5/MapMatchingService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public interface MapMatchingService {
5959
* @param voiceInstructions whether or not to return
6060
* marked-up text for voice guidance along the route.
6161
* @param voiceUnits voice units
62-
* @param waypointIndices which input coordinates should be treated as waypoints.
62+
* @param waypointIndices which input coordinates should be treated as waypoints/separate legs.
63+
* Note: coordinate indices not added here act as silent waypoints
6364
* @param waypointNames custom names for waypoints used for the arrival instruction.
6465
* @param approaches which side of the road to approach a waypoint.
6566
* @return the MapMatchingResponse in a Call wrapper
@@ -130,7 +131,8 @@ Call<MapMatchingResponse> getCall(
130131
* @param voiceInstructions whether or not to return
131132
* marked-up text for voice guidance along the route.
132133
* @param voiceUnits voice units
133-
* @param waypointIndices which input coordinates should be treated as waypoints.
134+
* @param waypointIndices which input coordinates should be treated as waypoints/separate legs.
135+
* Note: coordinate indices not added here act as silent waypoints
134136
* @param waypointNames custom names for waypoints used for the arrival instruction.
135137
* @param approaches which side of the road to approach a waypoint.
136138
* @return the MapMatchingResponse in a Call wrapper

services-matching/src/main/java/com/mapbox/api/matching/v5/MapboxMapMatching.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,8 @@ public Builder waypoints(@Nullable @IntRange(from = 0) Integer... waypoints) {
492492
}
493493

494494
/**
495-
* Optionally, set which input coordinates should be treated as waypoints.
495+
* Optionally, set which input coordinates should be treated as waypoints / separate legs.
496+
* Note: coordinate indices not added here act as silent waypoints
496497
* <p>
497498
* Most useful in combination with steps=true and requests based on traces
498499
* with high sample rates. Can be an index corresponding to any of the input coordinates,

0 commit comments

Comments
 (0)