Skip to content

Commit

Permalink
added railway crossings to step intersection
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasPaczos committed Mar 9, 2022
1 parent a80b4b9 commit 18d8941
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ public Point location() {
@SerializedName("tunnel_name")
public abstract String tunnelName();

/**
* Indicates whether there is a railway crossing at the intersection.
*
* @return whether there is a railway crossing at the intersection
*/
@Nullable
@SerializedName("railway_crossing")
public abstract Boolean railwayCrossing();

/**
* 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 @@ -258,6 +267,7 @@ public abstract static class Builder {
* @return this builder for chaining options together
* @since 3.0.0
*/
@NonNull
public abstract Builder bearings(@Nullable List<Integer> bearing);

/**
Expand All @@ -274,6 +284,7 @@ public abstract static class Builder {
* @return this builder for chaining options together
* @since 3.0.0
*/
@NonNull
public abstract Builder classes(@Nullable List<String> classes);

/**
Expand All @@ -286,6 +297,7 @@ public abstract static class Builder {
* @return this builder for chaining options together
* @since 3.0.0
*/
@NonNull
public abstract Builder entry(@Nullable List<Boolean> entry);

/**
Expand All @@ -299,6 +311,7 @@ public abstract static class Builder {
* @return this builder for chaining options together
* @since 3.0.0
*/
@NonNull
public abstract Builder in(@Nullable Integer in);

/**
Expand All @@ -310,6 +323,7 @@ public abstract static class Builder {
* @return this builder for chaining options together
* @since 3.0.0
*/
@NonNull
public abstract Builder out(@Nullable Integer out);

/**
Expand All @@ -322,6 +336,7 @@ public abstract static class Builder {
* @return this builder for chaining options together
* @since 3.0.0
*/
@NonNull
public abstract Builder lanes(@Nullable List<IntersectionLanes> lanes);

/**
Expand All @@ -333,6 +348,7 @@ public abstract static class Builder {
* @param geometryIndex index for the intersection
* @return this builder for chaining options together
*/
@NonNull
public abstract Builder geometryIndex(@Nullable Integer geometryIndex);

/**
Expand All @@ -343,7 +359,7 @@ public abstract static class Builder {
* @param isUrban indicating whether the road exiting the intersection is in an urban area
* @return this builder for chaining options together
*/
@Nullable
@NonNull
public abstract Builder isUrban(@Nullable Boolean isUrban);

/**
Expand All @@ -354,7 +370,7 @@ public abstract static class Builder {
* @param adminIndex zero-based index into the admin list on the route leg for this intersection
* @return this builder for chaining options together
*/
@Nullable
@NonNull
public abstract Builder adminIndex(@Nullable Integer adminIndex);

/**
Expand All @@ -364,7 +380,7 @@ public abstract static class Builder {
* @param restStop object containing information about passing rest stops along the route.
* @return this builder for chaining options together
*/
@Nullable
@NonNull
public abstract Builder restStop(@Nullable RestStop restStop);

/**
Expand All @@ -378,7 +394,7 @@ public abstract static class Builder {
* a toll collection point along the route.
* @return this builder for chaining options together
*/
@Nullable
@NonNull
public abstract Builder tollCollection(@Nullable TollCollection tollCollection);

/**
Expand All @@ -389,7 +405,7 @@ public abstract static class Builder {
* @param street an object containing detailed road information.
* @return this builder for chaining options together
*/
@Nullable
@NonNull
public abstract Builder mapboxStreetsV8(@Nullable MapboxStreetsV8 street);

/**
Expand All @@ -398,8 +414,18 @@ public abstract static class Builder {
* @param tunnelName name of the tunnel
* @return this builder for chaining options together
*/
@NonNull
public abstract Builder tunnelName(@Nullable String tunnelName);

/**
* Indicates whether there is a railway crossing at the intersection.
*
* @param railwayCrossing whether there is a railway crossing at the intersection.
* @return this builder for chaining options together
*/
@NonNull
public abstract Builder railwayCrossing(@Nullable Boolean railwayCrossing);

/**
* 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 All @@ -411,6 +437,7 @@ public abstract static class Builder {
* @return this builder for chaining options together
* @since 3.0.0
*/
@NonNull
public abstract Builder rawLocation(@NonNull double[] rawLocation);

/**
Expand All @@ -419,6 +446,7 @@ public abstract static class Builder {
* @return a new {@link StepIntersection} using the provided values in this builder
* @since 3.0.0
*/
@NonNull
public abstract StepIntersection build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public void testToFromJson2() {
assertEquals(intersection, intersectionFromJson);
}


@Test
public void testFromJson() {
String stepIntersectionJsonString = "{"
Expand All @@ -88,14 +87,16 @@ public void testFromJson() {
+ "\"geometry_index\": 123,"
+ "\"is_urban\": true,"
+ "\"mapbox_streets_v8\": {\"class\": \"street\"},"
+ "\"tunnel_name\": \"test tunnel name\""
+ "\"tunnel_name\": \"test tunnel name\","
+ "\"railway_crossing\": true"
+ "}";

StepIntersection stepIntersection = StepIntersection.fromJson(stepIntersectionJsonString);
assertEquals(123, stepIntersection.geometryIndex().intValue());
assertTrue(stepIntersection.isUrban());
assertEquals("street", stepIntersection.mapboxStreetsV8().roadClass());
assertEquals("test tunnel name", stepIntersection.tunnelName());
assertTrue(stepIntersection.railwayCrossing());

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

0 comments on commit 18d8941

Please sign in to comment.