Skip to content

Commit 3bed27a

Browse files
authored
RouteLegRefresh: added List<Closure> (#1489)
* RouteLegRefresh: added `List<Closure>`
1 parent 30d7171 commit 3bed27a

5 files changed

Lines changed: 51 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
Mapbox welcomes participation and contributions from everyone.
44

55
### main
6-
- Added `TurfSimplify#simplify` method to simplify `LineString` using Ramer-Douglas-Peucker algorithm. [1486](https://github.com/mapbox/mapbox-java/pull/1486)
6+
- Added `TurfSimplify#simplify` method to simplify `LineString` using Ramer-Douglas-Peucker algorithm. [#1486](https://github.com/mapbox/mapbox-java/pull/1486)
7+
- Added `List<Closure>` to `RouteLegRefresh` to make `DirectionsRoute#RouteLeg` refreshed with closures. [#1489](https://github.com/mapbox/mapbox-java/pull/1489)
78

89
### v6.8.0-beta.3 - September 1, 2022
910
- Added `subTypes` to `BannerComponents`. [#1485](https://github.com/mapbox/mapbox-java/pull/1485)

services-directions-refresh-models/src/main/java/com/mapbox/api/directionsrefresh/v1/models/RouteLegRefresh.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.google.gson.GsonBuilder;
88
import com.google.gson.TypeAdapter;
99
import com.mapbox.api.directions.v5.DirectionsAdapterFactory;
10+
import com.mapbox.api.directions.v5.models.Closure;
1011
import com.mapbox.api.directions.v5.models.DirectionsWaypoint;
1112
import com.mapbox.api.directions.v5.models.Incident;
1213
import com.mapbox.api.directions.v5.models.LegAnnotation;
@@ -47,6 +48,15 @@ public static Builder builder() {
4748
@Nullable
4849
public abstract LegAnnotation annotation();
4950

51+
52+
/**
53+
* A list of closures that occur on this leg.
54+
*
55+
* @return a list of {@link Closure}
56+
*/
57+
@Nullable
58+
public abstract List<Closure> closures();
59+
5060
/**
5161
* Convert the current {@link RouteLegRefresh} to its builder holding the currently assigned
5262
* values. This allows you to modify a single property and then rebuild the object resulting in
@@ -108,6 +118,15 @@ public abstract static class Builder {
108118
@NonNull
109119
public abstract Builder annotation(@Nullable LegAnnotation annotation);
110120

121+
/**
122+
* A list of closures that occur on this leg.
123+
*
124+
* @param closures a list of {@link Closure}
125+
* @return this builder for chaining options together
126+
*/
127+
@NonNull
128+
public abstract Builder closures(@Nullable List<Closure> closures);
129+
111130
/**
112131
* Build a new {@link RouteLegRefresh} object.
113132
*

services-directions-refresh-models/src/test/java/com.mapbox.api.directionsrefresh.v1.models/DirectionsRefreshResponseTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ public void testSerialization() throws IOException {
3737
assertNotNull(directionsRefreshResponse.route().legs().get(0));
3838
assertNotNull(directionsRefreshResponse.route().legs().get(0).annotation());
3939
assertTrue(directionsRefreshResponse.route().legs().get(0).annotation().congestion().size() > 0);
40-
assertTrue(directionsRefreshResponse.route().legs().get(0).incidents().size() > 0);
4140
assertTrue(directionsRefreshResponse.route().legs().get(0).annotation().trafficTendency().size() > 0);
41+
assertTrue(directionsRefreshResponse.route().legs().get(0).incidents().size() > 0);
42+
assertTrue(directionsRefreshResponse.route().legs().get(0).closures().size() > 0);
4243
}
4344

4445
@Test

services-directions-refresh-models/src/test/java/com.mapbox.api.directionsrefresh.v1.models/RouteLegRefreshTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static org.junit.Assert.assertNotNull;
55

66
import com.mapbox.api.directions.v5.DirectionsCriteria;
7+
import com.mapbox.api.directions.v5.models.Closure;
78
import com.mapbox.api.directions.v5.models.Congestion;
89
import com.mapbox.api.directions.v5.models.Incident;
910
import com.mapbox.api.directions.v5.models.LegAnnotation;
@@ -38,6 +39,14 @@ public void sanity() {
3839
.build()
3940
)
4041
)
42+
.closures(
43+
Arrays.asList(
44+
Closure.builder()
45+
.geometryIndexStart(1)
46+
.geometryIndexEnd(2)
47+
.build()
48+
)
49+
)
4150
.build();
4251
}
4352

@@ -111,6 +120,17 @@ public void fromJson() {
111120
.build()
112121
);
113122

123+
List<Closure> closures = Arrays.asList(
124+
Closure.builder()
125+
.geometryIndexStart(2)
126+
.geometryIndexEnd(4)
127+
.build(),
128+
Closure.builder()
129+
.geometryIndexStart(10)
130+
.geometryIndexEnd(20)
131+
.build()
132+
);
133+
114134
RouteLegRefresh routeLegRefresh = RouteLegRefresh.builder()
115135
.annotation(
116136
LegAnnotation.builder()
@@ -123,13 +143,15 @@ public void fromJson() {
123143
.build()
124144
)
125145
.incidents(incidents)
146+
.closures(closures)
126147
.build();
127148

128149
String json = routeLegRefresh.toJson();
129150
RouteLegRefresh fromJson = RouteLegRefresh.fromJson(json);
130151

131152
assertNotNull(routeLegRefresh.annotation());
132153
assertNotNull(routeLegRefresh.incidents());
154+
assertNotNull(routeLegRefresh.closures());
133155
assertEquals(routeLegRefresh, fromJson);
134156
}
135157

services-directions-refresh-models/src/test/resources/directions_refresh_v1.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
"route": {
44
"legs": [
55
{
6+
"closures": [
7+
{
8+
"geometry_index_end": 21,
9+
"geometry_index_start": 13
10+
}
11+
],
612
"incidents": [
713
{
814
"length": 288,

0 commit comments

Comments
 (0)