11package com .mapbox .api .matching .v5 ;
22
33import android .support .annotation .FloatRange ;
4+ import android .support .annotation .IntRange ;
45import android .support .annotation .NonNull ;
56import android .support .annotation .Nullable ;
67import com .google .auto .value .AutoValue ;
@@ -97,7 +98,11 @@ public Call<MapMatchingResponse> getCall() {
9798 timestamps (),
9899 annotations (),
99100 language (),
100- tidy ()
101+ tidy (),
102+ roundaboutExits (),
103+ bannerInstructions (),
104+ voiceInstructions (),
105+ waypoints ()
101106 );
102107
103108 return call ;
@@ -190,6 +195,19 @@ public Call<MapMatchingResponse> cloneCall() {
190195 @ Nullable
191196 abstract String language ();
192197
198+ @ Nullable
199+ abstract Boolean roundaboutExits ();
200+
201+ @ Nullable
202+ abstract Boolean bannerInstructions ();
203+
204+ @ Nullable
205+ abstract Boolean voiceInstructions ();
206+
207+ @ Nullable
208+ abstract String waypoints ();
209+
210+
193211 @ NonNull
194212 abstract String baseUrl ();
195213
@@ -220,6 +238,7 @@ public abstract static class Builder {
220238 private String [] annotations ;
221239 private String [] timestamps ;
222240 private Double [] radiuses ;
241+ private Integer [] waypoints ;
223242
224243 /**
225244 * Required to call when this is being built. If no access token provided,
@@ -303,6 +322,28 @@ public Builder radiuses(@Nullable @FloatRange(from = 0) Double... radiuses) {
303322 // Required for matching with MapboxMapMatching radiuses() method.
304323 abstract Builder radiuses (@ Nullable String radiuses );
305324
325+
326+ /**
327+ * Optionally, set which input coordinates should be treated as waypoints.
328+ * <p>
329+ * Most useful in combination with steps=true and requests based on traces with high sample rates.
330+ * Can be an index corresponding to any of the input coordinates,
331+ * but must contain the first ( 0 ) and last coordinates' index separated by ; .
332+ * {@link #steps()}
333+ * </p>
334+ *
335+ * @param waypoints integer array of coordinate indices to be used as waypoints
336+ * @return this builder for chaining options together
337+ * @since 3.0.0
338+ */
339+ public Builder waypoints (@ Nullable @ IntRange (from = 0 ) Integer ... waypoints ) {
340+ this .waypoints = waypoints ;
341+ return this ;
342+ }
343+
344+ // Required for matching with MapboxMapMatching waypoints() method.
345+ abstract Builder waypoints (@ Nullable String waypoints );
346+
306347 /**
307348 * Setting this will determine whether to return steps and turn-by-turn instructions. Can be
308349 * set to either true or false to enable or disable respectively. null can also optionally be
@@ -327,6 +368,42 @@ public Builder radiuses(@Nullable @FloatRange(from = 0) Double... radiuses) {
327368 */
328369 public abstract Builder overview (@ Nullable @ OverviewCriteria String overview );
329370
371+ /**
372+ * Setting this will determine Whether or not to return banner objects associated with the `routeSteps`.
373+ * Should be used in conjunction with `steps`. Can be set to either true or false to enable or
374+ * disable respectively. null can also optionally be
375+ * passed in to set the default behavior to match what the API does by default.
376+ *
377+ * @param bannerInstructions true if you'd like step information
378+ * @return this builder for chaining options together
379+ * @since 3.0.0
380+ */
381+ public abstract Builder bannerInstructions (@ Nullable Boolean bannerInstructions );
382+
383+
384+ /**
385+ * Setting this will determine whether to return steps and turn-by-turn instructions. Can be
386+ * set to either true or false to enable or disable respectively. null can also optionally be
387+ * passed in to set the default behavior to match what the API does by default.
388+ *
389+ * @param voiceInstructions true if you'd like step information
390+ * @return this builder for chaining options together
391+ * @since 3.0.0
392+ */
393+ public abstract Builder voiceInstructions (@ Nullable Boolean voiceInstructions );
394+
395+
396+ /**
397+ * Setting this will determine whether to return steps and turn-by-turn instructions. Can be
398+ * set to either true or false to enable or disable respectively. null can also optionally be
399+ * passed in to set the default behavior to match what the API does by default.
400+ *
401+ * @param roundaboutExits true if you'd like step information
402+ * @return this builder for chaining options together
403+ * @since 3.0.0
404+ */
405+ public abstract Builder roundaboutExits (@ Nullable Boolean roundaboutExits );
406+
330407 /**
331408 * Whether or not to return additional metadata along the route. Possible values are:
332409 * {@link DirectionsCriteria#ANNOTATION_DISTANCE},
@@ -486,10 +563,29 @@ public MapboxMapMatching build() {
486563 "There must be as many timestamps as there are coordinates." );
487564 }
488565
566+ if (waypoints != null ) {
567+ if (waypoints .length < 2 ) {
568+ throw new ServicesException (
569+ "Waypoints must be a list of at least two indexes separated by ';'" );
570+ }
571+ if (waypoints [0 ] != 0 || waypoints [waypoints .length - 1 ] != coordinates .size () - 1 ) {
572+ throw new ServicesException (
573+ "Waypoints must contain indices of the first and last coordinates"
574+ );
575+ }
576+ for (int i = 1 ; i < waypoints .length -1 ; i ++) {
577+ if (waypoints [i ] < 0 || waypoints [i ] >= coordinates .size ()) {
578+ throw new ServicesException (
579+ "Waypoints index too large (no corresponding coordinate)" );
580+ }
581+ }
582+ }
583+
489584 coordinates (formatCoordinates (coordinates ));
490585 timestamps (TextUtils .join ("," , timestamps ));
491586 annotations (TextUtils .join ("," , annotations ));
492587 radiuses (TextUtils .join ("," , radiuses ));
588+ waypoints (TextUtils .join (";" , waypoints ));
493589
494590 // Generate build so that we can check that values are valid.
495591 MapboxMapMatching mapMatching = autoBuild ();
0 commit comments