Skip to content

Commit

Permalink
Focus the separate OSM sidewalk tool on double-tagged sidewalks
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Aug 18, 2024
1 parent 428a7bb commit 9fa6639
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
6 changes: 5 additions & 1 deletion backend/src/fix_osm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rstar::{RTree, RTreeObject};

use crate::MapModel;

pub fn find_separate_sidewalks(map: &MapModel) -> GeoJson {
pub fn find_separate_sidewalks(map: &MapModel, duplicates_only: bool) -> GeoJson {
let footways = RTree::bulk_load(
map.roads
.iter()
Expand All @@ -24,6 +24,10 @@ pub fn find_separate_sidewalks(map: &MapModel) -> GeoJson {
continue;
}

if duplicates_only && !r.tags.is_any("sidewalk", vec!["left", "right", "both"]) {
continue;
}

// Along this road, if we project away, do we hit a footway?
for line in crate::heatmap::make_perpendicular_offsets(&r.linestring, 25.0, 15.0) {
for footway in footways.locate_in_envelope_intersecting(&line.envelope()) {
Expand Down
6 changes: 3 additions & 3 deletions backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ impl MapModel {
}

#[wasm_bindgen(js_name = findSeparateSidewalks)]
pub fn find_separate_sidewalks(&self) -> Result<String, JsValue> {
let out =
serde_json::to_string(&fix_osm::find_separate_sidewalks(self)).map_err(err_to_js)?;
pub fn find_separate_sidewalks(&self, duplicates_only: bool) -> Result<String, JsValue> {
let out = serde_json::to_string(&fix_osm::find_separate_sidewalks(self, duplicates_only))
.map_err(err_to_js)?;
Ok(out)
}

Expand Down
11 changes: 10 additions & 1 deletion web/src/OsmSeparateSidewalksMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import { Popup } from "svelte-utils/map";
import { model } from "./stores";
import NavBar from "./NavBar.svelte";
let duplicateSidewalks = true;
</script>

<SplitComponent>
Expand All @@ -16,10 +18,17 @@
OSM, then (if appropriate) add <b>sidewalk=separate</b> (or a <b>:left</b>
/ <b>:right</b> variant).
</p>

<label>
<input type="checkbox" bind:checked={duplicateSidewalks} />
Only show roads with a <b>sidewalk=left,right,both</b> tag
</label>
</div>
<div slot="map">
<GeoJSON
data={JSON.parse(notNull($model).findSeparateSidewalks())}
data={JSON.parse(
notNull($model).findSeparateSidewalks(duplicateSidewalks),
)}
generateId
>
<LineLayer
Expand Down

0 comments on commit 9fa6639

Please sign in to comment.