Skip to content

Commit 76777ff

Browse files
committed
add congestion numeric support to leg annotation
1 parent 1c80b0e commit 76777ff

3 files changed

Lines changed: 34 additions & 3 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public final class DirectionsCriteria {
125125
* in the route leg.
126126
* This annotation is only available for the {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC}.
127127
*/
128-
public static final String ANNOTATION_CONGESTION_NUMERIC = "congestion_NUMERIC";
128+
public static final String ANNOTATION_CONGESTION_NUMERIC = "congestion_numeric";
129129

130130
/**
131131
* The maximum speed limit between the coordinates of a segment.

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.google.gson.Gson;
66
import com.google.gson.GsonBuilder;
77
import com.google.gson.TypeAdapter;
8+
import com.google.gson.annotations.SerializedName;
89
import com.mapbox.api.directions.v5.DirectionsAdapterFactory;
910

1011
import java.util.List;
@@ -81,6 +82,16 @@ public static Builder builder() {
8182
@Nullable
8283
public abstract List<String> congestion();
8384

85+
/**
86+
* The congestion between each pair of coordinates.
87+
*
88+
* @return a list of Integers with each entry being a congestion value between two of the
89+
* routeLeg geometry coordinates
90+
*/
91+
@Nullable
92+
@SerializedName("congestion_numeric")
93+
public abstract List<Integer> congestionNumeric();
94+
8495
/**
8596
* Convert the current {@link LegAnnotation} to its builder holding the currently assigned
8697
* values. This allows you to modify a single property and then rebuild the object resulting in
@@ -176,6 +187,15 @@ public abstract static class Builder {
176187
*/
177188
public abstract Builder congestion(@Nullable List<String> congestion);
178189

190+
/**
191+
* The congestion between each pair of coordinates.
192+
*
193+
* @param congestionNumeric a list of Integers with each entry being a congestion value between
194+
* two of the routeLeg geometry coordinates
195+
* @return this builder for chaining options together
196+
*/
197+
public abstract Builder congestionNumeric(@Nullable List<Integer> congestionNumeric);
198+
179199
/**
180200
* Build a new {@link LegAnnotation} object.
181201
*

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class LegAnnotationTest extends TestUtils {
1515
@Test
1616
public void sanity() throws Exception {
1717
LegAnnotation annotation = LegAnnotation.builder()
18+
.congestionNumeric(new ArrayList<Integer>())
1819
.congestion(new ArrayList<String>())
1920
.distance(new ArrayList<Double>())
2021
.duration(new ArrayList<Double>())
@@ -30,6 +31,7 @@ public void testSerializable() throws Exception {
3031
distance.add(40d);
3132
distance.add(60d);
3233
LegAnnotation annotation = LegAnnotation.builder()
34+
.congestionNumeric(new ArrayList<Integer>())
3335
.congestion(new ArrayList<String>())
3436
.distance(distance)
3537
.duration(new ArrayList<Double>())
@@ -73,7 +75,6 @@ public void testToFromJson1() {
7375
4.2,
7476
4.2);
7577

76-
7778
List<String> congestionList = Arrays.asList(
7879
"low",
7980
"moderate",
@@ -84,8 +85,18 @@ public void testToFromJson1() {
8485
"heavy",
8586
"heavy");
8687

88+
List<Integer> congestionNumericList = Arrays.asList(
89+
0,
90+
4,
91+
4,
92+
4,
93+
null,
94+
0,
95+
0,
96+
0);
97+
8798
LegAnnotation annotation = LegAnnotation.builder()
88-
.congestion(new ArrayList<String>())
99+
.congestionNumeric(congestionNumericList)
89100
.distance(distanceList)
90101
.duration(durationList)
91102
.speed(speedList)

0 commit comments

Comments
 (0)