Skip to content

Commit ea24583

Browse files
Added DirectionsRoute#weightTypical indicating the weight of the route under typical conditions. (#1632)
1 parent cbce8e6 commit ea24583

4 files changed

Lines changed: 822 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Mapbox welcomes participation and contributions from everyone.
66
- Added `DirectionsRefreshResponse#fromJson(Reader)`, a static factory method that deserializes a `DirectionsRefreshResponse` from a `java.io.Reader`.
77
- Added `FlattenListOfPoints` to hold a list of points in a more memory-efficient way.
88
- Deprecate `LineString#coordinates()` and `Point#coordinates()`. It's encouraged to use the new `flattenCoordinates()` methods.
9+
- Added `DirectionsRoute#weightTypical` indicating the weight of the route under typical conditions.
910

1011

1112
### v7.9.0 - November 20, 2025

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ public static Builder builder() {
9393
@Nullable
9494
public abstract Double weight();
9595

96+
/**
97+
* When using the driving-traffic profile, this will be returned as a double value
98+
* indicating the weight of the selected route under typical conditions
99+
* (not taking into account live traffic).
100+
*/
101+
@Nullable
102+
@SerializedName("weight_typical")
103+
public abstract Double weightTypical();
104+
96105
/**
97106
* The name of the weight profile used while calculating during extraction phase. The default is
98107
* {@code routability} which is duration based, with additional penalties for less desirable
@@ -296,6 +305,16 @@ public abstract static class Builder extends DirectionsJsonObject.Builder<Builde
296305
@NonNull
297306
public abstract Builder weight(@Nullable Double weight);
298307

308+
/**
309+
* The weight of the selected route under typical conditions
310+
* (not taking into account live traffic).
311+
*
312+
* @param weightTypical the weight of the selected route under typical conditions
313+
* @return this builder for chaining options together
314+
*/
315+
@NonNull
316+
public abstract Builder weightTypical(@Nullable Double weightTypical);
317+
299318
/**
300319
* The name of the weight profile used while calculating during extraction phase. The default is
301320
* {@code routability} which is duration based, with additional penalties for less desirable

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,25 @@ public void directionsRoute_doesReturnVoiceLocale() throws Exception {
4949
DirectionsResponse response = DirectionsResponse.fromJson(json);
5050
DirectionsRoute route = response.routes().get(FIRST_ROUTE);
5151

52-
String voiceLanguage = route.voiceLanguage();
52+
assertEquals("en-US", route.voiceLanguage());
53+
}
54+
55+
@Test
56+
public void directionsRoute_doesReturnWeight() throws Exception {
57+
String json = loadJsonFixture(DIRECTIONS_V5_VOICE_BANNER_FIXTURE);
58+
DirectionsResponse response = DirectionsResponse.fromJson(json);
59+
DirectionsRoute route = response.routes().get(FIRST_ROUTE);
60+
61+
assertEquals((Double) 373.1, route.weight());
62+
}
63+
64+
@Test
65+
public void directionsRoute_doesReturnWeightTypical() throws Exception {
66+
String json = loadJsonFixture(DIRECTIONS_V5_VOICE_BANNER_FIXTURE);
67+
DirectionsResponse response = DirectionsResponse.fromJson(json);
68+
DirectionsRoute route = response.routes().get(FIRST_ROUTE);
5369

54-
assertEquals("en-US", voiceLanguage);
70+
assertEquals((Double) 321.5, route.weightTypical());
5571
}
5672

5773
@Test

0 commit comments

Comments
 (0)