Skip to content

Commit 50997b7

Browse files
author
Łukasz Paczos
committed
expose active and validIndications lane information
1 parent bc21013 commit 50997b7

2 files changed

Lines changed: 83 additions & 4 deletions

File tree

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.mapbox.api.directions.v5.models;
22

33
import androidx.annotation.Nullable;
4+
45
import com.google.auto.value.AutoValue;
56
import com.google.gson.Gson;
67
import com.google.gson.GsonBuilder;
78
import com.google.gson.TypeAdapter;
9+
import com.google.gson.annotations.SerializedName;
810
import com.mapbox.api.directions.v5.DirectionsAdapterFactory;
911

1012
import java.util.List;
@@ -39,6 +41,35 @@ public static Builder builder() {
3941
@Nullable
4042
public abstract Boolean valid();
4143

44+
/**
45+
* Indicates whether this lane is a preferred lane (true) or not (false).
46+
* A preferred lane is a lane that is recommended if there are multiple lanes available.
47+
* For example, if guidance indicates that the driver must turn left at an intersection
48+
* and there are multiple left turn lanes, the left turn lane that will better prepare
49+
* the driver for the next maneuver will be marked as active.
50+
* Only available on the mapbox/driving profile.
51+
*
52+
* @return Indicates whether this lane is a preferred lane (true) or not (false).
53+
*/
54+
@Nullable
55+
public abstract Boolean active();
56+
57+
/**
58+
* When either valid or active is set to true, this property shows which of the lane indications
59+
* is applicable to the current route, when there is more than one. For example, if a lane allows
60+
* you to go left or straight but your current route is guiding you to the left,
61+
* then this value will be set to left.
62+
* See indications for possible values.
63+
* When both active and valid are false, this property will not be included in the response.
64+
* Only available on the mapbox/driving profile.
65+
*
66+
* @return Array of which of the lane indications is applicable to the current route,
67+
* when there is more than one
68+
*/
69+
@Nullable
70+
@SerializedName("valid_indication")
71+
public abstract List<String> validIndications();
72+
4273
/**
4374
* Array that can be made up of multiple signs such as {@code left}, {@code right}, etc.
4475
*
@@ -106,6 +137,25 @@ public abstract static class Builder {
106137
*/
107138
public abstract Builder valid(@Nullable Boolean valid);
108139

140+
/**
141+
* Indicates whether this lane is a preferred lane (true) or not (false).
142+
*
143+
* @param active Boolean value that indicates whether this lane is a preferred lane (true)
144+
* or not (false).
145+
* @return this builder for chaining options together
146+
*/
147+
public abstract Builder active(@Nullable Boolean active);
148+
149+
/**
150+
* Shows which of the lane indications is applicable to the current route,
151+
* when there is more than one.
152+
*
153+
* @param validIndications list of lane indications that are applicable to the current route,
154+
* when there is more than one.
155+
* @return this builder for chaining options together
156+
*/
157+
public abstract Builder validIndications(@Nullable List<String> validIndications);
158+
109159
/**
110160
* list that can be made up of multiple signs such as {@code left}, {@code right}, etc.
111161
*

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

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import java.util.ArrayList;
1010
import java.util.Arrays;
11+
import java.util.Collections;
1112

1213
public class IntersectionLanesTest extends TestUtils {
1314

@@ -21,25 +22,53 @@ public void sanity() throws Exception {
2122
}
2223

2324
@Test
24-
public void testSerializable() throws Exception {
25+
public void testSerializableRoundTripping() throws Exception {
2526
IntersectionLanes intersectionLanes = IntersectionLanes.builder()
26-
.indications(new ArrayList<String>())
2727
.valid(true)
28+
.active(true)
29+
.validIndications(Collections.singletonList("straight"))
30+
.indications(Arrays.asList("straight","slight left"))
2831
.build();
2932
byte[] serialized = TestUtils.serialize(intersectionLanes);
3033
assertEquals(intersectionLanes, deserialize(serialized, IntersectionLanes.class));
3134
}
3235

3336
@Test
34-
public void testToFromJson() {
37+
public void testJsonRoundTripping() {
3538
IntersectionLanes intersectionLanes = IntersectionLanes.builder()
36-
.indications(Arrays.asList("straight","slight left"))
3739
.valid(true)
40+
.active(true)
41+
.validIndications(Collections.singletonList("straight"))
42+
.indications(Arrays.asList("straight","slight left"))
3843
.build();
3944

4045
String jsonString = intersectionLanes.toJson();
4146
IntersectionLanes intersectionLanesFromJson = IntersectionLanes.fromJson(jsonString);
4247

4348
assertEquals(intersectionLanes, intersectionLanesFromJson);
4449
}
50+
51+
@Test
52+
public void testFromJson_active() {
53+
IntersectionLanes intersectionLanes = IntersectionLanes.builder()
54+
.active(true)
55+
.build();
56+
57+
String jsonString = "{\"active\":true}";
58+
IntersectionLanes intersectionLanesFromJson = IntersectionLanes.fromJson(jsonString);
59+
60+
assertEquals(intersectionLanes, intersectionLanesFromJson);
61+
}
62+
63+
@Test
64+
public void testFromJson_validIndications() {
65+
IntersectionLanes intersectionLanes = IntersectionLanes.builder()
66+
.validIndications(Collections.singletonList("straight"))
67+
.build();
68+
69+
String jsonString = "{\"valid_indication\":[\"straight\"]}";
70+
IntersectionLanes intersectionLanesFromJson = IntersectionLanes.fromJson(jsonString);
71+
72+
assertEquals(intersectionLanes, intersectionLanesFromJson);
73+
}
4574
}

0 commit comments

Comments
 (0)