Skip to content

Commit c735fd4

Browse files
committed
NAVAND-836: add RouteOptions#suppressVoiceInstructionLocalNames
1 parent 9c95f57 commit c735fd4

7 files changed

Lines changed: 76 additions & 7 deletions

File tree

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,20 @@ public List<String> paymentMethodsList() {
932932
return ParseUtils.parseToStrings(paymentMethods(), ",");
933933
}
934934

935+
/*
936+
* If true, steps.voiceInstructions will omit any named maneuever points along the route
937+
* (e.g. street name, intersection name, JCT, IC) when the language parameter does not match
938+
* the default language(s) for that region. For example, if the `language` parameter is `de`
939+
* and a user is routing in France, a user would hear "turn left" instead of "turn
940+
* left onto Champs Elysee".
941+
*
942+
* @return boolean representing the `suppressVoiceInstructionLocalNames` value
943+
*/
944+
@SuppressWarnings("checkstyle:javadocmethod")
945+
@SerializedName("suppress_voice_instruction_local_names")
946+
@Nullable
947+
public abstract Boolean suppressVoiceInstructionLocalNames();
948+
935949
/**
936950
* Gson type adapter for parsing Gson to this class.
937951
*
@@ -1069,6 +1083,11 @@ public URL toUrl(@NonNull String accessToken) {
10691083
appendQueryParameter(sb, "waypoints_per_route", waypointsPerRoute());
10701084
appendQueryParameter(sb, "metadata", metadata());
10711085
appendQueryParameter(sb, "payment_methods", paymentMethods());
1086+
appendQueryParameter(
1087+
sb,
1088+
"suppress_voice_instruction_local_names",
1089+
suppressVoiceInstructionLocalNames()
1090+
);
10721091

10731092
Map<String, SerializableJsonElement> unrecognized = unrecognized();
10741093
if (unrecognized != null) {
@@ -2091,6 +2110,23 @@ public Builder snappingIncludeStaticClosuresList(
20912110
@NonNull
20922111
public abstract Builder metadata(@Nullable Boolean metadata);
20932112

2113+
/*
2114+
* If true, steps.voiceInstructions will omit any named maneuever points along the route
2115+
* (e.g. street name, intersection name, JCT, IC) when the language parameter does not match
2116+
* the default language(s) for that region. For example, if the `language` parameter is `de`
2117+
* and a user is routing in France, a user would hear "turn left" instead of "turn
2118+
* left onto Champs Elysee".
2119+
*
2120+
* @param suppressVoiceInstructionLocalNames boolean representing
2121+
* the `suppressVoiceInstructionLocalNames` value
2122+
* @return this builder
2123+
*/
2124+
@SuppressWarnings("checkstyle:javadocmethod")
2125+
@NonNull
2126+
public abstract Builder suppressVoiceInstructionLocalNames(
2127+
@Nullable Boolean suppressVoiceInstructionLocalNames
2128+
);
2129+
20942130
/**
20952131
* Use this method to add request parameters,
20962132
* which are not present in the model yet but are supported on the Directions API,

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class RouteOptionsTest extends TestUtils {
3838
*/
3939
private static final String ROUTE_OPTIONS_JSON = "route_options_v5.json";
4040
private static final String ROUTE_OPTIONS_URL =
41-
"https://api.mapbox.com/directions/v5/mapbox/driving/-122.4003312,37.7736941;-122.4187529,37.7689715;-122.4255172,37.7775835?access_token=pk.token&geometries=polyline6&alternatives=false&overview=full&radiuses=%3Bunlimited%3B5.1&steps=true&avoid_maneuver_radius=200.0&bearings=0%2C90%3B90%2C0%3B&layers=-42%3B%3B0&continue_straight=false&annotations=congestion%2Cdistance%2Cduration&language=ru&roundabout_exits=false&voice_instructions=true&banner_instructions=true&voice_units=metric&exclude=toll%2Cferry%2Cpoint%2811.0+-22.0%29&include=hot%2Chov2&approaches=%3Bcurb%3B&waypoints=0%3B1%3B2&waypoint_names=%3BSerangoon+Garden+Market+%26+Food+Centre%3BFunky+%26nAmE*&waypoint_targets=%3B12.2%2C21.2%3B&enable_refresh=true&walking_speed=5.11&walkway_bias=-0.2&alley_bias=0.75&snapping_include_closures=%3Bfalse%3Btrue&snapping_include_static_closures=true%3B%3Bfalse&arrive_by=2021-01-01%27T%2701%3A01&depart_at=2021-02-02%27T%2702%3A02&max_height=1.5&max_width=1.4&max_weight=2.9&compute_toll_cost=true&waypoints_per_route=true&metadata=true&payment_methods=general";
41+
"https://api.mapbox.com/directions/v5/mapbox/driving/-122.4003312,37.7736941;-122.4187529,37.7689715;-122.4255172,37.7775835?access_token=pk.token&geometries=polyline6&alternatives=false&overview=full&radiuses=%3Bunlimited%3B5.1&steps=true&avoid_maneuver_radius=200.0&bearings=0%2C90%3B90%2C0%3B&layers=-42%3B%3B0&continue_straight=false&annotations=congestion%2Cdistance%2Cduration&language=ru&roundabout_exits=false&voice_instructions=true&banner_instructions=true&voice_units=metric&exclude=toll%2Cferry%2Cpoint%2811.0+-22.0%29&include=hot%2Chov2&approaches=%3Bcurb%3B&waypoints=0%3B1%3B2&waypoint_names=%3BSerangoon+Garden+Market+%26+Food+Centre%3BFunky+%26nAmE*&waypoint_targets=%3B12.2%2C21.2%3B&enable_refresh=true&walking_speed=5.11&walkway_bias=-0.2&alley_bias=0.75&snapping_include_closures=%3Bfalse%3Btrue&snapping_include_static_closures=true%3B%3Bfalse&arrive_by=2021-01-01%27T%2701%3A01&depart_at=2021-02-02%27T%2702%3A02&max_height=1.5&max_width=1.4&max_weight=2.9&compute_toll_cost=true&waypoints_per_route=true&metadata=true&payment_methods=general&suppress_voice_instruction_local_names=true";
4242
private static final String ACCESS_TOKEN = "pk.token";
4343

4444
private final String optionsJson = loadJsonFixture(ROUTE_OPTIONS_JSON);
@@ -350,6 +350,13 @@ public void computeTollCostIsValid_fromJson() {
350350
assertEquals(true, options.computeTollCost());
351351
}
352352

353+
@Test
354+
public void suppressVoiceInstructionLocalNamesIsValid_fromJson() {
355+
RouteOptions options = RouteOptions.fromJson(optionsJson);
356+
357+
assertEquals(true, options.suppressVoiceInstructionLocalNames());
358+
}
359+
353360
@Test
354361
public void waypointsPerRouteAreValid_fromJson() {
355362
RouteOptions routeOptions = RouteOptions.fromJson(optionsJson);
@@ -364,6 +371,13 @@ public void defaultTollCost() {
364371
assertNull(options.computeTollCost());
365372
}
366373

374+
@Test
375+
public void defaultSuppressVoiceInstructionLocalNames() {
376+
RouteOptions options = defaultRouteOptions();
377+
378+
assertNull(options.suppressVoiceInstructionLocalNames());
379+
}
380+
367381
@Test
368382
public void defaultWaypointsPerRoute() {
369383
RouteOptions options = defaultRouteOptions();
@@ -1102,6 +1116,7 @@ private RouteOptions routeOptions() {
11021116
.computeTollCost(true)
11031117
.waypointsPerRoute(true)
11041118
.paymentMethods(DirectionsCriteria.PAYMENT_METHOD_GENERAL)
1119+
.suppressVoiceInstructionLocalNames(true)
11051120
.build();
11061121
}
11071122

@@ -1209,6 +1224,7 @@ private RouteOptions routeOptionsList() {
12091224
.metadata(true)
12101225
.computeTollCost(true)
12111226
.waypointsPerRoute(true)
1227+
.suppressVoiceInstructionLocalNames(true)
12121228
.paymentMethodsList(Arrays.asList(DirectionsCriteria.PAYMENT_METHOD_GENERAL))
12131229
.build();
12141230
}

services-directions-models/src/test/resources/route_options_v5.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@
3838
"metadata": true,
3939
"waypoints_per_route": true,
4040
"compute_toll_cost": true,
41-
"payment_methods": "general"
41+
"payment_methods": "general",
42+
"suppress_voice_instruction_local_names": true
4243
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ Call<DirectionsResponse> getCall(
103103
@Query("compute_toll_cost") Boolean computeTollCost,
104104
@Query("waypoints_per_route") Boolean waypointsPerRoute,
105105
@Query("metadata") Boolean metadata,
106-
@Query("payment_methods") String paymentMethods
106+
@Query("payment_methods") String paymentMethods,
107+
@Query("suppress_voice_instruction_local_names") Boolean suppressVoiceInstructionLocalNames
107108
);
108109

109110
/**
@@ -193,6 +194,7 @@ Call<DirectionsResponse> postCall(
193194
@Field("compute_toll_cost") Boolean computeTollCost,
194195
@Field("waypoints_per_route") Boolean waypointsPerRoute,
195196
@Field("metadata") Boolean metadata,
196-
@Field("payment_methods") String paymentMethods
197+
@Field("payment_methods") String paymentMethods,
198+
@Field("suppress_voice_instruction_local_names") Boolean suppressVoiceInstructionLocalNames
197199
);
198200
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ private Call<DirectionsResponse> get() {
112112
routeOptions().computeTollCost(),
113113
routeOptions().waypointsPerRoute(),
114114
routeOptions().metadata(),
115-
routeOptions().paymentMethods()
115+
routeOptions().paymentMethods(),
116+
routeOptions().suppressVoiceInstructionLocalNames()
116117
);
117118
}
118119

@@ -158,7 +159,8 @@ private Call<DirectionsResponse> post() {
158159
routeOptions().computeTollCost(),
159160
routeOptions().waypointsPerRoute(),
160161
routeOptions().metadata(),
161-
routeOptions().paymentMethods()
162+
routeOptions().paymentMethods(),
163+
routeOptions().suppressVoiceInstructionLocalNames()
162164
);
163165
}
164166

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,17 @@ public void computeTollCost() throws Exception {
732732
mapboxDirections.cloneCall().request().url().queryParameter("compute_toll_cost"));
733733
}
734734

735+
@Test
736+
public void suppressVoiceInstructionLocalNames() throws Exception {
737+
MapboxDirections mapboxDirections = MapboxDirections.builder()
738+
.accessToken("token")
739+
.routeOptions(routeOptions.toBuilder().baseUrl(mockUrl.toString()).build())
740+
.build();
741+
742+
assertEquals("true",
743+
mapboxDirections.cloneCall().request().url().queryParameter("suppress_voice_instruction_local_names"));
744+
}
745+
735746
@Test
736747
public void waypointsPerRoute() throws Exception {
737748
MapboxDirections mapboxDirections = MapboxDirections.builder()

services-directions/src/test/resources/route_options_v5.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@
3838
"compute_toll_cost": true,
3939
"waypoints_per_route": true,
4040
"metadata": true,
41-
"payment_methods": "general,etcx"
41+
"payment_methods": "general,etcx",
42+
"suppress_voice_instruction_local_names": true
4243
}

0 commit comments

Comments
 (0)