Skip to content

Commit

Permalink
Adds AreaStop layer to new debug frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
eibakke committed Jan 22, 2024
1 parent 34f53c4 commit a136f95
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client-next/src/components/MapView/MapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function MapView({
}}
// it's unfortunate that you have to list these layers here.
// maybe there is a way around it: https://github.com/visgl/react-map-gl/discussions/2343
interactiveLayerIds={['regular-stop', 'vertex', 'edge', 'link']}
interactiveLayerIds={['regular-stop', 'area-stop', 'vertex', 'edge', 'link']}
onClick={showFeaturePropPopup}
// put lat/long in URL and pan to it on page reload
hash={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class DebugStyleSpec {

static StyleSpec build(
VectorSourceLayer regularStops,
VectorSourceLayer areaStops,
VectorSourceLayer edges,
VectorSourceLayer vertices
) {
Expand Down Expand Up @@ -112,6 +113,15 @@ static StyleSpec build(
.minZoom(15)
.maxZoom(MAX_ZOOM)
.intiallyHidden(),
StyleBuilder
.ofId("area-stop")
.typeFill()
.vectorSourceLayer(areaStops)
.fillColor(GREEN)
.fillOpacity(0.5f)
.fillOutlineColor(BLACK)
.minZoom(6)
.maxZoom(MAX_ZOOM),
StyleBuilder
.ofId("regular-stop")
.typeCircle()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.opentripplanner.apis.vectortiles;

import static org.opentripplanner.apis.vectortiles.model.LayerType.AreaStop;
import static org.opentripplanner.apis.vectortiles.model.LayerType.Edge;
import static org.opentripplanner.apis.vectortiles.model.LayerType.GeofencingZones;
import static org.opentripplanner.apis.vectortiles.model.LayerType.RegularStop;
Expand Down Expand Up @@ -47,7 +48,7 @@
public class GraphInspectorVectorTileResource {

private static final LayerParams REGULAR_STOPS = new LayerParams("regularStops", RegularStop);
private static final LayerParams AREA_STOPS = new LayerParams("areaStops", LayerType.AreaStop);
private static final LayerParams AREA_STOPS = new LayerParams("areaStops", AreaStop);
private static final LayerParams GEOFENCING_ZONES = new LayerParams(
"geofencingZones",
GeofencingZones
Expand Down Expand Up @@ -140,6 +141,7 @@ public StyleSpec getTileJson(@Context UriInfo uri, @Context HttpHeaders headers)

return DebugStyleSpec.build(
REGULAR_STOPS.toVectorSourceLayer(stopsSource),
AREA_STOPS.toVectorSourceLayer(stopsSource),
EDGES.toVectorSourceLayer(streetSource),
VERTICES.toVectorSourceLayer(streetSource)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public enum LayerType {
Circle,
Line,
Raster,
Fill,
}

private StyleBuilder(String id) {
Expand Down Expand Up @@ -88,6 +89,11 @@ public StyleBuilder typeLine() {
return this;
}

public StyleBuilder typeFill() {
type(LayerType.Fill);
return this;
}

private StyleBuilder type(LayerType type) {
props.put(TYPE, type.name().toLowerCase());
return this;
Expand Down Expand Up @@ -132,6 +138,21 @@ public StyleBuilder lineWidth(ZoomDependentNumber zoomStops) {
return this;
}

public StyleBuilder fillColor(String color) {
paint.put("fill-color", validateColor(color));
return this;
}

public StyleBuilder fillOpacity(float opacity) {
paint.put("fill-opacity", opacity);
return this;
}

public StyleBuilder fillOutlineColor(String color) {
paint.put("fill-outline-color", validateColor(color));
return this;
}

/**
* Hide this layer when the debug client starts. It can be made visible in the UI later.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ class DebugStyleSpecTest {
@Test
void spec() {
var vectorSource = new VectorSource("vectorSource", "https://example.com");
var stops = new VectorSourceLayer(vectorSource, "stops");
var regularStops = new VectorSourceLayer(vectorSource, "stops");
var areaStops = new VectorSourceLayer(vectorSource, "stops");
var edges = new VectorSourceLayer(vectorSource, "edges");
var vertices = new VectorSourceLayer(vectorSource, "vertices");
var spec = DebugStyleSpec.build(stops, edges, vertices);
var spec = DebugStyleSpec.build(regularStops, areaStops, edges, vertices);

var json = ObjectMappers.ignoringExtraFields().valueToTree(spec);
var expectation = RESOURCES.fileToString("style.json");
Expand Down
13 changes: 13 additions & 0 deletions src/test/resources/org/opentripplanner/apis/vectortiles/style.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,19 @@
"visibility" : "none"
}
},
{
"id" : "area-stop",
"type" : "fill",
"source" : "vectorSource",
"source-layer" : "stops",
"minzoom" : 6,
"maxzoom" : 23,
"paint" : {
"fill-color" : "#22DD9E",
"fill-opacity" : 0.5,
"fill-outline-color" : "#140d0e"
}
},
{
"id" : "regular-stop",
"type" : "circle",
Expand Down

0 comments on commit a136f95

Please sign in to comment.