Skip to content

Commit

Permalink
Expose as a control from Street Explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Mar 10, 2023
1 parent fdec96d commit 64b3f18
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 9 additions & 2 deletions osm2streets-js/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use serde::{Deserialize, Serialize};
use wasm_bindgen::prelude::*;

use osm2streets::{
osm, DebugStreets, IntersectionID, LaneID, MapConfig, Placement, RoadID, StreetNetwork,
Transformation,
osm, DebugStreets, IntersectionID, LaneID, MapConfig, Placement, RoadID, Sidepath,
StreetNetwork, Transformation,
};

#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -256,6 +256,13 @@ impl JsStreetNetwork {
self.inner.collapse_intersection(i);
}
}

#[wasm_bindgen(js_name = zipSidepath)]
pub fn zip_sidepath(&mut self, road: usize) {
if let Some(sidepath) = Sidepath::new(&self.inner, RoadID(road)) {
sidepath.zip(&mut self.inner);
}
}
}

#[wasm_bindgen]
Expand Down
6 changes: 6 additions & 0 deletions street-explorer/js/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ export const makeLanePolygonLayer = (
rerenderNetwork(network, dynamicMovementLayer, map, maybeGroup);
})
);
buttons.appendChild(
makeButton("Zip sidepath", () => {
network.zipSidepath(feature.properties.road);
rerenderNetwork(network, dynamicMovementLayer, map, maybeGroup);
})
);
popup.appendChild(buttons);
}

Expand Down

0 comments on commit 64b3f18

Please sign in to comment.