Skip to content

Commit

Permalink
Update vertex styles
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Jan 16, 2024
1 parent c9bbc7d commit f1a9be0
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 8 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 @@ -58,7 +58,7 @@ export function MapView({
// provided by the WorldEnvelopeService
if (map.getZoom() < 2) {
const source = map.getSource('stops') as VectorTileSource;
map.fitBounds(source.bounds, { maxDuration: 50, linear: true});
map.fitBounds(source.bounds, { maxDuration: 50, linear: true });
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ public class DebugStyleSpec {
private static final String MAGENTA = "#f21d52";
private static final String GREEN = "#22DD9E";
private static final String PURPLE = "#BC55F2";
private static final String BLACK = "#140d0e";
private static final int MAX_ZOOM = 23;
private static final ZoomDependentNumber LINE_WIDTH = new ZoomDependentNumber(
1.3f,
List.of(new ZoomStop(13, 0.5f), new ZoomStop(MAX_ZOOM, 10))
);
private static final String BLACK = "#140d0e";
private static final ZoomDependentNumber CIRCLE_STROKE = new ZoomDependentNumber(
1,
List.of(new ZoomStop(15, 0.2f), new ZoomStop(MAX_ZOOM, 3))
);

static StyleSpec build(
VectorSourceLayer regularStops,
Expand Down Expand Up @@ -100,13 +104,14 @@ static StyleSpec build(
.ofId("vertex")
.typeCircle()
.vectorSourceLayer(vertices)
.circleStroke(BLACK, 2)
.circleStroke(BLACK, CIRCLE_STROKE)
.circleRadius(
new ZoomDependentNumber(1, List.of(new ZoomStop(15, 1), new ZoomStop(MAX_ZOOM, 5)))
new ZoomDependentNumber(1, List.of(new ZoomStop(15, 1), new ZoomStop(MAX_ZOOM, 7)))
)
.circleColor(PURPLE)
.minZoom(15)
.maxZoom(MAX_ZOOM),
.maxZoom(MAX_ZOOM)
.intiallyHidden(),
StyleBuilder
.ofId("regular-stop")
.typeCircle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ public StyleBuilder circleStroke(String color, int width) {
return this;
}

public StyleBuilder circleStroke(String color, ZoomDependentNumber width) {
paint.put("circle-stroke-color", validateColor(color));
paint.put("circle-stroke-width", width.toJson());
return this;
}

public StyleBuilder circleRadius(ZoomDependentNumber radius) {
paint.put("circle-radius", radius.toJson());
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ void spec() {
var vectorSource = new VectorSource("vectorSource", "https://example.com");
var stops = new VectorSourceLayer(vectorSource, "stops");
var edges = new VectorSourceLayer(vectorSource, "edges");
var spec = DebugStyleSpec.build(stops, edges, VERTICES.toVectorSourceLayer(streetSource));
var vertices = new VectorSourceLayer(vectorSource, "vertices");
var spec = DebugStyleSpec.build(stops, edges, vertices);

var json = ObjectMappers.ignoringExtraFields().valueToTree(spec);
var expectation = RESOURCES.fileToString("style.json");
Expand Down
44 changes: 42 additions & 2 deletions src/test/resources/org/opentripplanner/apis/vectortiles/style.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{

"name" : "OTP Debug Tiles",
"sources" : {
"background" : {
Expand Down Expand Up @@ -101,6 +100,47 @@
"visibility" : "none"
}
},
{
"id" : "vertex",
"type" : "circle",
"source" : "vectorSource",
"source-layer" : "vertices",
"minzoom" : 15,
"maxzoom" : 23,
"paint" : {
"circle-stroke-color" : "#140d0e",
"circle-stroke-width" : {
"base" : 1.0,
"stops" : [
[
15,
0.2
],
[
23,
3.0
]
]
},
"circle-radius" : {
"base" : 1.0,
"stops" : [
[
15,
1.0
],
[
23,
7.0
]
]
},
"circle-color" : "#BC55F2"
},
"layout" : {
"visibility" : "none"
}
},
{
"id" : "regular-stop",
"type" : "circle",
Expand Down Expand Up @@ -129,4 +169,4 @@
}
],
"version" : 8
}
}

0 comments on commit f1a9be0

Please sign in to comment.