Skip to content

Commit

Permalink
Add an option to highlight edited roads. #70
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Jan 11, 2025
1 parent 3ebb740 commit 6c36e97
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions backend/src/neighbourhood.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ impl Neighbourhood {
"direction_edited",
map.directions[&r] != Direction::from_osm(&road.tags),
);
f.set_property(
"edited",
map.directions[&r] != Direction::from_osm(&road.tags)
|| map.modal_filters.get(&r) != map.original_modal_filters.get(&r),
);
f.set_property("road", r.0);
if let Some(color) = derived.render_cells.colors_per_road.get(&r) {
f.set_property("cell_color", *color);
Expand Down
3 changes: 3 additions & 0 deletions web/src/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<select bind:value={$roadStyle}>
<option value="shortcuts">Show worst shortcuts</option>
<option value="cells">Show the cell</option>
<option value="edits">
Show edited roads (either filter or direction)
</option>
</select>
</label>

Expand Down
6 changes: 5 additions & 1 deletion web/src/layers/InteriorRoadLayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@
export let onClickLine = (f: Feature, pt: LngLat) => {};
function roadLineColor(
style: "shortcuts" | "cells",
style: "shortcuts" | "cells" | "edits",
maxShortcuts: number,
): ExpressionSpecification {
if (style == "cells") {
return ["get", "color"];
}
if (style == "edits") {
return ["case", ["get", "edited"], "grey", "white"];
}
if (maxShortcuts <= 2) {
return hoverStateFilter("white", "blue");
}
Expand Down
3 changes: 2 additions & 1 deletion web/src/stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export let maptilerBasemap: Writable<string> = writable("streets-v2");
export let filterType: Writable<string> = writable("walk_cycle_only");
export let animateShortcuts = writable(false);
export let editPerimeterRoads = writable(false);
export let roadStyle: Writable<"shortcuts" | "cells"> = writable("shortcuts");
export let roadStyle: Writable<"shortcuts" | "cells" | "edits"> =
writable("shortcuts");
export let thickRoadsForShortcuts = writable(false);

export function autosave() {
Expand Down
1 change: 1 addition & 0 deletions web/src/wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export interface RenderNeighbourhoodOutput {
shortcuts: number;
direction: "forwards" | "backwards" | "both";
direction_edited: boolean;
edited: boolean;
road: number;
cell_color: "disconnected" | number;
// Populated by setCellColors, not in the Rust backend
Expand Down

0 comments on commit 6c36e97

Please sign in to comment.