Skip to content

Commit 9ffd5ae

Browse files
authored
expose snapping_include_static_closures (#1469)
1 parent 0e9ea0e commit 9ffd5ae

8 files changed

Lines changed: 410 additions & 105 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Mapbox welcomes participation and contributions from everyone.
44

55
### main
6+
- Fixed an issue where the `RouteOptions#...List` parameters were not reset correctly (for example, `routeOptions.toBuilder().bearingsList(null).build()` did not reset bearings to null). [#1469](https://github.com/mapbox/mapbox-java/pull/1469)
7+
- Added `RouteOptions.snappingIncludeStaticClosures` and `RouteOptions.snappingIncludeStaticClosuresList`. [#1469](https://github.com/mapbox/mapbox-java/pull/1469)
68

79
### v6.7.0-beta.1 - Jul 22, 2022
810
- Added `Incident.affectedRoadNames`. [#1457](https://github.com/mapbox/mapbox-java/pull/1457)

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

Lines changed: 95 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,25 @@ public List<Point> waypointTargetsList() {
743743
@Nullable
744744
public abstract String snappingIncludeClosures();
745745

746+
/**
747+
* A semicolon-separated list of booleans affecting snapping of
748+
* waypoint locations to road segments.
749+
* If true, road segments statically closed, that is long-term, will be considered for snapping
750+
* (for example, road under construction).
751+
* If false, they will not be considered for snapping.
752+
* If provided, the number of snappingIncludeStaticClosures must be the same
753+
* as the number of waypoints.
754+
* However, you can skip a coordinate and show its position in the list with the ; separator.
755+
* If null, this parameter defaults to false.
756+
* <p>
757+
* Only available with the {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC}.
758+
*
759+
* @return a String representing a list of booleans
760+
*/
761+
@SerializedName("snapping_include_static_closures")
762+
@Nullable
763+
public abstract String snappingIncludeStaticClosures();
764+
746765
/**
747766
* A list of booleans affecting snapping of waypoint locations to road segments.
748767
* If true, road segments closed due to live-traffic closures will be considered for snapping.
@@ -761,6 +780,25 @@ public List<Boolean> snappingIncludeClosuresList() {
761780
return ParseUtils.parseToBooleans(snappingIncludeClosures());
762781
}
763782

783+
/**
784+
* A list of booleans affecting snapping of waypoint locations to road segments.
785+
* If true, road segments statically closed, that is long-term, will be considered for snapping
786+
* (for example, road under construction).
787+
* If false, they will not be considered for snapping.
788+
* If provided, the number of snappingIncludeStaticClosures must be the same
789+
* as the number of waypoints.
790+
* However, you can skip a coordinate and show its position in the list with the null.
791+
* If null, this parameter defaults to false.
792+
* <p>
793+
* Only available with the {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC}.
794+
*
795+
* @return a list of booleans
796+
*/
797+
@Nullable
798+
public List<Boolean> snappingIncludeStaticClosuresList() {
799+
return ParseUtils.parseToBooleans(snappingIncludeStaticClosures());
800+
}
801+
764802
/**
765803
* The desired arrival time, formatted as a timestamp in ISO-8601 format
766804
* in the local time at the route destination.
@@ -975,6 +1013,7 @@ public URL toUrl(@NonNull String accessToken) {
9751013
appendQueryParameter(sb, "walkway_bias", walkwayBias());
9761014
appendQueryParameter(sb, "alley_bias", alleyBias());
9771015
appendQueryParameter(sb, "snapping_include_closures", snappingIncludeClosures());
1016+
appendQueryParameter(sb, "snapping_include_static_closures", snappingIncludeStaticClosures());
9781017
appendQueryParameter(sb, "arrive_by", arriveBy());
9791018
appendQueryParameter(sb, "depart_at", departAt());
9801019
appendQueryParameter(sb, "max_height", maxHeight());
@@ -1136,9 +1175,10 @@ public abstract static class Builder extends DirectionsJsonObject.Builder<Builde
11361175
@NonNull
11371176
public Builder coordinatesList(@NonNull List<Point> coordinates) {
11381177
String result = FormatUtils.formatPointsList(coordinates);
1139-
if (result != null) {
1140-
coordinates(result);
1178+
if (result == null) {
1179+
result = "";
11411180
}
1181+
coordinates(result);
11421182
return this;
11431183
}
11441184

@@ -1202,9 +1242,7 @@ public Builder coordinatesList(@NonNull List<Point> coordinates) {
12021242
@NonNull
12031243
public Builder radiusesList(@Nullable List<Double> radiuses) {
12041244
String result = FormatUtils.formatRadiuses(radiuses);
1205-
if (result != null) {
1206-
radiuses(result);
1207-
}
1245+
radiuses(result);
12081246
return this;
12091247
}
12101248

@@ -1246,9 +1284,7 @@ public Builder radiusesList(@Nullable List<Double> radiuses) {
12461284
@NonNull
12471285
public Builder bearingsList(@Nullable List<Bearing> bearings) {
12481286
String result = FormatUtils.formatBearings(bearings);
1249-
if (result != null) {
1250-
bearings(result);
1251-
}
1287+
bearings(result);
12521288
return this;
12531289
}
12541290

@@ -1297,9 +1333,7 @@ public abstract Builder avoidManeuverRadius(
12971333
@NonNull
12981334
public Builder layersList(@Nullable List<Integer> layers) {
12991335
String result = FormatUtils.formatIntegers(layers);
1300-
if (result != null) {
1301-
layers(result);
1302-
}
1336+
layers(result);
13031337
return this;
13041338
}
13051339

@@ -1423,9 +1457,7 @@ public abstract Builder overview(
14231457
@NonNull
14241458
public Builder annotationsList(@Nullable List<String> annotations) {
14251459
String result = FormatUtils.join(",", annotations);
1426-
if (result != null) {
1427-
annotations(result);
1428-
}
1460+
annotations(result);
14291461
return this;
14301462
}
14311463

@@ -1512,9 +1544,7 @@ public Builder annotationsList(@Nullable List<String> annotations) {
15121544
@NonNull
15131545
public Builder excludeList(@Nullable List<String> exclude) {
15141546
String result = FormatUtils.join(",", exclude);
1515-
if (result != null) {
1516-
exclude(result);
1517-
}
1547+
exclude(result);
15181548
return this;
15191549
}
15201550

@@ -1583,9 +1613,7 @@ public Builder excludeObject(@Nullable Exclude exclude) {
15831613
@NonNull
15841614
public Builder includeList(@Nullable List<String> include) {
15851615
String result = FormatUtils.join(",", include);
1586-
if (result != null) {
1587-
include(result);
1588-
}
1616+
include(result);
15891617
return this;
15901618
}
15911619

@@ -1630,9 +1658,7 @@ public Builder includeList(@Nullable List<String> include) {
16301658
@NonNull
16311659
public Builder approachesList(@Nullable List<String> approaches) {
16321660
String result = FormatUtils.join(";", approaches);
1633-
if (result != null) {
1634-
approaches(result);
1635-
}
1661+
approaches(result);
16361662
return this;
16371663
}
16381664

@@ -1695,9 +1721,7 @@ public Builder approachesList(@Nullable List<String> approaches) {
16951721
@NonNull
16961722
public Builder waypointIndicesList(@Nullable List<Integer> indices) {
16971723
String result = FormatUtils.join(";", indices);
1698-
if (result != null) {
1699-
waypointIndices(result);
1700-
}
1724+
waypointIndices(result);
17011725
return this;
17021726
}
17031727

@@ -1733,9 +1757,7 @@ public Builder waypointIndicesList(@Nullable List<Integer> indices) {
17331757
@NonNull
17341758
public Builder waypointNamesList(@Nullable List<String> waypointNames) {
17351759
String result = FormatUtils.join(";", waypointNames);
1736-
if (result != null) {
1737-
waypointNames(result);
1738-
}
1760+
waypointNames(result);
17391761
return this;
17401762
}
17411763

@@ -1852,9 +1874,50 @@ public abstract Builder walkwayBias(
18521874
@NonNull
18531875
public Builder snappingIncludeClosuresList(@Nullable List<Boolean> snappingClosures) {
18541876
String result = FormatUtils.join(";", snappingClosures);
1855-
if (result != null) {
1856-
snappingIncludeClosures(result);
1857-
}
1877+
snappingIncludeClosures(result);
1878+
return this;
1879+
}
1880+
1881+
/**
1882+
* A semicolon-separated list of booleans affecting snapping of
1883+
* waypoint locations to road segments.
1884+
* If true, road segments statically closed, that is long-term, will be considered for snapping
1885+
* (for example, road under construction).
1886+
* If false, they will not be considered for snapping.
1887+
* If provided, the number of snappingIncludeStaticClosures must be the same
1888+
* as the number of waypoints.
1889+
* However, you can skip a coordinate and show its position in the list with the ; separator.
1890+
* If null, this parameter defaults to false.
1891+
* <p>
1892+
* Only available with the {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC}.
1893+
*
1894+
* @param snappingStaticClosures a String representing a list of booleans
1895+
* @return this builder for chaining options together
1896+
*/
1897+
@NonNull
1898+
public abstract Builder snappingIncludeStaticClosures(@Nullable String snappingStaticClosures);
1899+
1900+
/**
1901+
* A list of booleans affecting snapping of waypoint locations to road segments.
1902+
* If true, road segments statically closed, that is long-term, will be considered for snapping
1903+
* (for example, road under construction).
1904+
* If false, they will not be considered for snapping.
1905+
* If provided, the number of snappingIncludeStaticClosures must be the same
1906+
* as the number of waypoints.
1907+
* However, you can skip a coordinate and show its position in the list with the null.
1908+
* If null, this parameter defaults to false.
1909+
* <p>
1910+
* Only available with the {@link DirectionsCriteria#PROFILE_DRIVING_TRAFFIC}.
1911+
*
1912+
* @param snappingStaticClosures a list of booleans
1913+
* @return this builder for chaining options together
1914+
*/
1915+
@NonNull
1916+
public Builder snappingIncludeStaticClosuresList(
1917+
@Nullable List<Boolean> snappingStaticClosures
1918+
) {
1919+
String result = FormatUtils.join(";", snappingStaticClosures);
1920+
snappingIncludeStaticClosures(result);
18581921
return this;
18591922
}
18601923

0 commit comments

Comments
 (0)