Skip to content

Commit 7da47df

Browse files
author
Cameron Mace
authored
added congestion annotation (mapbox#469)
* added annotation congestion * reverted version number
1 parent d290095 commit 7da47df

3 files changed

Lines changed: 66 additions & 3 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ public class DirectionsCriteria {
110110
*/
111111
public static final String ANNOTATION_SPEED = "speed";
112112

113+
/**
114+
* The congestion, provided as a String, between each pair of coordinates
115+
*
116+
* @since 2.2.0
117+
*/
118+
public static final String ANNOTATION_CONGESTION = "congestion";
119+
113120
/**
114121
* Server responds with no errors.
115122
*

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,9 @@ public T setContinueStraight(Boolean continueStraight) {
344344

345345
/**
346346
* Whether or not to return additional metadata along the route. Possible values are:
347-
* {@link DirectionsCriteria#ANNOTATION_DISTANCE}, {@link DirectionsCriteria#ANNOTATION_DURATION}, and
348-
* {@link DirectionsCriteria#ANNOTATION_SPEED}. Several annotation can be used by separating them with {@code ,}.
347+
* {@link DirectionsCriteria#ANNOTATION_DISTANCE}, {@link DirectionsCriteria#ANNOTATION_DURATION},
348+
* {@link DirectionsCriteria#ANNOTATION_DURATION} and {@link DirectionsCriteria#ANNOTATION_CONGESTION}. Several
349+
* annotation can be used by separating them with {@code ,}.
349350
*
350351
* @param annotation String referencing one of the annotation direction criteria's.
351352
* @return Builder
@@ -648,7 +649,8 @@ public MapboxDirections build() throws ServicesException {
648649
for (String annotationEntry : annotation) {
649650
if (!annotationEntry.equals(DirectionsCriteria.ANNOTATION_DISTANCE)
650651
&& !annotationEntry.equals(DirectionsCriteria.ANNOTATION_DURATION)
651-
&& !annotationEntry.equals(DirectionsCriteria.ANNOTATION_SPEED)) {
652+
&& !annotationEntry.equals(DirectionsCriteria.ANNOTATION_SPEED)
653+
&& !annotationEntry.equals(DirectionsCriteria.ANNOTATION_CONGESTION)) {
652654
throw new ServicesException(
653655
"Annotation value must be one of the constant values found inside DirectionsCriteria");
654656
}

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class LegAnnotation {
1111
private double[] distance;
1212
private double[] duration;
1313
private double[] speed;
14+
private String[] congestion;
1415

1516
public LegAnnotation() {
1617
}
@@ -25,6 +26,17 @@ public double[] getDistance() {
2526
return distance;
2627
}
2728

29+
/**
30+
* Set the duration, in seconds, between each pair of coordinates.
31+
*
32+
* @param distance a double array with each entry being a duration value between two of the routeLeg geometry
33+
* coordinates.
34+
* @since 2.2.0
35+
*/
36+
public void setDistance(double[] distance) {
37+
this.distance = distance;
38+
}
39+
2840
/**
2941
* The duration, in seconds, between each pair of coordinates.
3042
*
@@ -35,6 +47,17 @@ public double[] getDuration() {
3547
return duration;
3648
}
3749

50+
/**
51+
* Set the duration, in seconds, between each pair of coordinates.
52+
*
53+
* @param duration a double array with each entry being a duration value between two of the routeLeg geometry
54+
* coordinates.
55+
* @since 2.2.0
56+
*/
57+
public void setDuration(double[] duration) {
58+
this.duration = duration;
59+
}
60+
3861
/**
3962
* The speed, in meters per second, between each pair of coordinates.
4063
*
@@ -44,4 +67,35 @@ public double[] getDuration() {
4467
public double[] getSpeed() {
4568
return speed;
4669
}
70+
71+
/**
72+
* Set the speed, in meters per second, between each pair of coordinates.
73+
*
74+
* @param speed a double array with each entry being a speed value between two of the routeLeg geometry coordinates.
75+
* @since 2.2.0
76+
*/
77+
public void setSpeed(double[] speed) {
78+
this.speed = speed;
79+
}
80+
81+
/**
82+
* The congestion between each pair of coordinates.
83+
*
84+
* @return a String array with each entry being a congestion value between two of the routeLeg geometry coordinates.
85+
* @since 2.2.0
86+
*/
87+
public String[] getCongestion() {
88+
return congestion;
89+
}
90+
91+
/**
92+
* Set the congestion between each pair of coordinates.
93+
*
94+
* @param congestion a String array with each entry being a congestion value between two of the routeLeg geometry
95+
* coordinates.
96+
* @since 2.2.0
97+
*/
98+
public void setCongestion(String[] congestion) {
99+
this.congestion = congestion;
100+
}
47101
}

0 commit comments

Comments
 (0)