diff --git a/backend/src/lib.rs b/backend/src/lib.rs index bd90e06..dda0d9d 100644 --- a/backend/src/lib.rs +++ b/backend/src/lib.rs @@ -55,8 +55,9 @@ impl MapModel { }; let mut timer = Timer::new("build graph", progress_cb); let mut amenities = Amenities::new(); + let modify_roads = |_roads: &mut Vec| {}; let graph = if is_osm { - Graph::new(input_bytes, gtfs, &mut amenities, &mut timer) + Graph::new(input_bytes, gtfs, &mut amenities, modify_roads, &mut timer) .await .map_err(err_to_js)? } else { diff --git a/graph/src/scrape.rs b/graph/src/scrape.rs index e3b1795..167bc9d 100644 --- a/graph/src/scrape.rs +++ b/graph/src/scrape.rs @@ -13,11 +13,14 @@ use crate::{ }; impl Graph { - /// Call with bytes of an osm.pbf or osm.xml string - pub async fn new( + /// input_bytes: Bytes of an osm.pbf or osm.xml string + /// osm_reader: To scrape OSM elements + /// modify_roads: Runs before any routing structures are calculated. Use to modify access per mode. + pub async fn new), R: utils::osm2graph::OsmReader>( input_bytes: &[u8], gtfs_source: GtfsSource, - reader: &mut R, + osm_reader: &mut R, + modify_roads: F, timer: &mut Timer, ) -> Result { timer.step("parse OSM and split graph"); @@ -28,7 +31,7 @@ impl Graph { |tags| { tags.has("highway") && !tags.is("highway", "proposed") && !tags.is("area", "yes") }, - reader, + osm_reader, )?; timer.step("calculate road attributes"); @@ -69,6 +72,8 @@ impl Graph { }) .collect(); + modify_roads(&mut roads); + timer.push("build closest_road"); let closest_road = EnumMap::from_fn(|mode| { timer.step(format!("for {mode:?}"));