Skip to content

Commit

Permalink
Toggle layers to see snapped routes vs input
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Sep 13, 2024
1 parent 66e7f07 commit 7c9efe7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
9 changes: 4 additions & 5 deletions backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,10 @@ impl MapModel {
self.graph
.mercator
.to_mercator_in_place(&mut input.geometry);
routes.push(
self.graph
.snap_route(&input.geometry, mode)
.map_err(err_to_js)?,
);
match self.graph.snap_route(&input.geometry, mode) {
Ok(route) => routes.push(route),
Err(err) => log::warn!("Couldn't snap a route: {err}"),
}
}

let start_time = NaiveTime::parse_from_str(&req.start_time, "%H:%M").map_err(err_to_js)?;
Expand Down
18 changes: 18 additions & 0 deletions web/src/UploadRouteMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
let output: FeatureCollection | null = null;
let totalPopulationInBuffer = 0;
let showInput = true;
let showOutput = true;
let fileInput: HTMLInputElement;
async function loadFile(e: Event) {
try {
Expand Down Expand Up @@ -78,6 +81,15 @@
<input bind:this={fileInput} on:change={loadFile} type="file" />
</label>

<label style:color="cyan">
<input type="checkbox" bind:checked={showInput} />
Show input
</label>
<label style:color="red">
<input type="checkbox" bind:checked={showOutput} />
Show snapped output
</label>

<PickTravelMode bind:travelMode={$travelMode} />

{#if input}
Expand All @@ -100,6 +112,9 @@
{#if input}
<GeoJSON data={input} generateId>
<LineLayer
layout={{
visibility: showInput ? "visible" : "none",
}}
paint={{
"line-width": 20,
"line-color": "cyan",
Expand All @@ -117,6 +132,9 @@
{:else}
<LineLayer
filter={["==", ["get", "kind"], "route"]}
layout={{
visibility: showOutput ? "visible" : "none",
}}
paint={{
"line-width": 20,
"line-color": "red",
Expand Down

0 comments on commit 7c9efe7

Please sign in to comment.