Skip to content

Commit

Permalink
vector tile: use ALL for permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
flaktack committed Nov 7, 2024
1 parent f6c04e0 commit 14cef7c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,11 @@ private static List<StyleBuilder> traversalPermissions(VectorSourceLayer edges)
.vectorSourceLayer(edges)
.group(PERMISSIONS_GROUP)
.typeLine()
.filterValueInProperty(streetTraversalPermission.name(), "permission")
.filterValueInProperty(
"permission",
streetTraversalPermission.name(),
StreetTraversalPermission.ALL.name()
)
.lineCap("butt")
.lineColorMatch("permission", permissionColors(), BLACK)
.lineWidth(LINE_WIDTH)
Expand Down Expand Up @@ -279,7 +283,11 @@ private static List<StyleBuilder> noThruTraffic(VectorSourceLayer edges) {
.vectorSourceLayer(edges)
.group(NO_THRU_TRAFFIC_GROUP)
.typeLine()
.filterValueInProperty(streetTraversalPermission.name(), "noThruTraffic")
.filterValueInProperty(
"noThruTraffic",
streetTraversalPermission.name(),
StreetTraversalPermission.ALL.name()
)
.lineCap("butt")
.lineColorMatch("noThruTraffic", permissionColors(), BLACK)
.lineWidth(LINE_WIDTH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
Expand All @@ -11,7 +12,6 @@
import java.util.stream.Stream;
import org.opentripplanner.apis.vectortiles.model.ZoomDependentNumber.ZoomStop;
import org.opentripplanner.framework.json.ObjectMappers;
import org.opentripplanner.street.model.StreetTraversalPermission;
import org.opentripplanner.street.model.edge.Edge;
import org.opentripplanner.street.model.vertex.Vertex;
import org.opentripplanner.utils.collection.ListUtils;
Expand Down Expand Up @@ -250,14 +250,6 @@ public final StyleBuilder edgeFilter(Class<? extends Edge>... classToFilter) {
return filterClasses(classToFilter);
}

/**
* Filter the entities by their "permission" property.
*/
public final StyleBuilder permissionsFilter(StreetTraversalPermission p) {
filter = List.of("==", "permission", p.name());
return this;
}

/**
* Only apply the style to the given vertices.
*/
Expand All @@ -266,8 +258,13 @@ public final StyleBuilder vertexFilter(Class<? extends Vertex>... classToFilter)
return filterClasses(classToFilter);
}

public StyleBuilder filterValueInProperty(String value, String propertyName) {
filter = List.of("in", value, List.of("string", List.of("get", propertyName)));
public StyleBuilder filterValueInProperty(String propertyName, String... values) {
var newFilter = new ArrayList<>();
newFilter.add("any");
for (String value : values) {
newFilter.add(List.of("in", value, List.of("string", List.of("get", propertyName))));
}
filter = newFilter;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ private static List<KeyValue> mapStreetEdge(StreetEdge se) {
}

public static String streetPermissionAsString(StreetTraversalPermission permission) {
return (
permission == StreetTraversalPermission.ALL
? "PEDESTRIAN_AND_BICYCLE_AND_CAR"
: permission.toString()
).replace("_AND_", " ");
return permission.name().replace("_AND_", " ");
}

private static String noThruTrafficAsString(StreetEdge se) {
Expand Down

0 comments on commit 14cef7c

Please sign in to comment.