Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose intersection's geometry_index #1181

Merged
merged 1 commit into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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