Skip to content

Commit

Permalink
expose intersection's geometry_index
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasPaczos committed Sep 11, 2020
1 parent 8683520 commit 21a4873
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ public Point location() {
@SerializedName("tunnel_name")
public abstract String tunnelName();

/**
* The zero-based index for the intersection.
* This value can be used to apply the duration annotation that corresponds with the intersection.
* Only available on the driving profile.
*
* @return index for the intersection
*/
@Nullable
@SerializedName("geometry_index")
public abstract Integer geometryIndex();

/**
* Convert the current {@link StepIntersection} to its builder holding the currently assigned
* values. This allows you to modify a single property and then rebuild the object resulting in
Expand Down Expand Up @@ -262,6 +273,17 @@ public abstract static class Builder {
*/
public abstract Builder tunnelName(@Nullable String tunnelName);

/**
* The zero-based index for the intersection.
* This value can be used to apply the duration annotation
* that corresponds with the intersection.
* Only available on the driving profile.
*
* @param geometryIndex index for the intersection
* @return this builder for chaining options together
*/
public abstract Builder geometryIndex(@Nullable Integer geometryIndex);

/**
* The rawLocation as a double array. Once the {@link StepIntersection} object's created,
* this raw location gets converted into a {@link Point} object and is public exposed as such.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void testToFromJson1() {
.bearings(Arrays.asList(125))
.rawLocation(new double[]{13.426579, 52.508068})
.tunnelName("test tunnel")
.geometryIndex(123)
.build();

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

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

Point location = stepIntersection.location();
Assert.assertEquals(13.426579, location.longitude(), 0.0001);
Expand Down

0 comments on commit 21a4873

Please sign in to comment.