diff --git a/examples/lisbon/config.json b/examples/lisbon/config.json index ac5bf41..ea25034 100644 --- a/examples/lisbon/config.json +++ b/examples/lisbon/config.json @@ -6,13 +6,30 @@ "destinations_path": "schools.geojson" }, "cost": { - "ByLTS": { - "lts1": 1.0, - "lts2": 1.5, - "lts3": 3.0, - "lts4": 5.0 + "OsmHighwayType": { + "cycleway": 8, + "footway": 20, + "living_street": 10, + "motorway": 30, + "motorway_link": 30, + "path": 10, + "pedestrian": 10, + "primary": 15, + "primary_link": 15, + "residential": 20, + "secondary": 12, + "secondary_link": 12, + "service": 10, + "steps": 40, + "tertiary": 11, + "tertiary_link": 11, + "track": 10, + "trunk": 30, + "trunk_link": 30, + "unclassified": 10 } }, "uptake": "Identity", - "lts": "BikeOttawa" + "lts": "BikeOttawa", + "elevation_geotiff": "LisboaIST_10m_4326.tif" } diff --git a/examples/lisbon/setup.py b/examples/lisbon/setup.py index 6d025a2..5c276d7 100644 --- a/examples/lisbon/setup.py +++ b/examples/lisbon/setup.py @@ -24,11 +24,9 @@ def makeOSM(): def makeElevation(): - # TODO LisboaCOPERNICUS_clip.tif doesn't have any errors, but no data seems to get scraped - # TODO LisboaIST_clip_r1.tif is apparently missing a TIF signature? download( - url="https://github.com/U-Shift/Declives-RedeViaria/raw/main/raster/LisboaCOPERNICUS_clip.tif", - outputFilename="input/LisboaCOPERNICUS_clip.tif", + url="https://assets.od2net.org/input/LisboaIST_10m_4326.tif", + outputFilename="input/LisboaIST_10m_4326.tif", ) @@ -52,6 +50,6 @@ def makeDestinations(): checkDependencies() run(["mkdir", "-p", "input"]) makeOSM() - #makeElevation() + makeElevation() makeOrigins() makeDestinations() diff --git a/od2net/src/network/create_from_osm.rs b/od2net/src/network/create_from_osm.rs index 4ab1ebf..0871273 100644 --- a/od2net/src/network/create_from_osm.rs +++ b/od2net/src/network/create_from_osm.rs @@ -84,12 +84,20 @@ impl Network { if let Some(bytes) = geotiff_bytes { timer.start("Calculate elevation for all edges"); let mut geotiff = GeoTiffElevation::new(Cursor::new(bytes)); + let mut succeeded = 0; let progress = utils::progress_bar_for_count(network.edges.len()); for (_, edge) in &mut network.edges { progress.inc(1); - edge.apply_elevation(&mut geotiff); + if edge.apply_elevation(&mut geotiff) { + succeeded += 1; + } } timer.stop(); + println!( + "Got elevation for {} / {} edges", + HumanCount(succeeded as u64), + HumanCount(network.edges.len() as u64) + ); } timer.start("Calculate cost for all edges"); diff --git a/od2net/src/network/mod.rs b/od2net/src/network/mod.rs index 93699f7..341cd8c 100644 --- a/od2net/src/network/mod.rs +++ b/od2net/src/network/mod.rs @@ -136,17 +136,20 @@ pub struct Edge { } impl Edge { - /// Sets `slope` and `slope_factor`. - pub fn apply_elevation(&mut self, geotiff: &mut GeoTiffElevation) { + /// Sets `slope` and `slope_factor` if true. If false, failed to get data. + pub fn apply_elevation( + &mut self, + geotiff: &mut GeoTiffElevation, + ) -> bool { let Some(slope) = self.get_slope(geotiff) else { - // Silently return if this fails - return; + return false; }; self.slope = Some(slope); self.slope_factor = Some(( calculate_slope_factor(slope, self.length_meters), calculate_slope_factor(-slope, self.length_meters), )); + true } fn get_slope(&self, geotiff: &mut GeoTiffElevation) -> Option { diff --git a/viewer/src/App.svelte b/viewer/src/App.svelte index 63e50ce..8c9235e 100644 --- a/viewer/src/App.svelte +++ b/viewer/src/App.svelte @@ -73,6 +73,7 @@ +