Skip to content

Commit 21a4873

Browse files
author
Łukasz Paczos
committed
expose intersection's geometry_index
1 parent 8683520 commit 21a4873

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,17 @@ public Point location() {
135135
@SerializedName("tunnel_name")
136136
public abstract String tunnelName();
137137

138+
/**
139+
* The zero-based index for the intersection.
140+
* This value can be used to apply the duration annotation that corresponds with the intersection.
141+
* Only available on the driving profile.
142+
*
143+
* @return index for the intersection
144+
*/
145+
@Nullable
146+
@SerializedName("geometry_index")
147+
public abstract Integer geometryIndex();
148+
138149
/**
139150
* Convert the current {@link StepIntersection} to its builder holding the currently assigned
140151
* values. This allows you to modify a single property and then rebuild the object resulting in
@@ -262,6 +273,17 @@ public abstract static class Builder {
262273
*/
263274
public abstract Builder tunnelName(@Nullable String tunnelName);
264275

276+
/**
277+
* The zero-based index for the intersection.
278+
* This value can be used to apply the duration annotation
279+
* that corresponds with the intersection.
280+
* Only available on the driving profile.
281+
*
282+
* @param geometryIndex index for the intersection
283+
* @return this builder for chaining options together
284+
*/
285+
public abstract Builder geometryIndex(@Nullable Integer geometryIndex);
286+
265287
/**
266288
* The rawLocation as a double array. Once the {@link StepIntersection} object's created,
267289
* this raw location gets converted into a {@link Point} object and is public exposed as such.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public void testToFromJson1() {
4444
.bearings(Arrays.asList(125))
4545
.rawLocation(new double[]{13.426579, 52.508068})
4646
.tunnelName("test tunnel")
47+
.geometryIndex(123)
4748
.build();
4849

4950
String jsonString = intersection.toJson();
@@ -74,10 +75,12 @@ public void testToFromJson2() {
7475
public void testFromJson() {
7576
String stepIntersectionJsonString = "{\"out\": 0, \"entry\": [true], \"bearings\": [ 125 ], "
7677
+ "\"tunnel_name\": \"test tunnel name\","
78+
+ "\"geometry_index\": 123,"
7779
+ "\"location\": [ 13.426579, 52.508068 ] }";
7880

7981
StepIntersection stepIntersection = StepIntersection.fromJson(stepIntersectionJsonString);
8082
Assert.assertEquals("test tunnel name", stepIntersection.tunnelName());
83+
Assert.assertEquals(123, stepIntersection.geometryIndex().intValue());
8184

8285
Point location = stepIntersection.location();
8386
Assert.assertEquals(13.426579, location.longitude(), 0.0001);

0 commit comments

Comments
 (0)