Commit
"rise / run" calculation used the trimmed road center-lines, which don't match up with the elevation at each original intersection point. Also handle infinity in the output and reduce the resolution of the query from every 1m to every 5m. Regenerate all maps due to the map format change. Try bringing in elevation data for all of Seattle using the LIDAR source, since the data quality assessed in eldang/elevation_lookups#12 seems to be similar, and LIDAR is way faster than contours.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ pub fn add_data(map: &mut RawMap, timer: &mut Timer) -> Result<()> { | |
)) | ||
.arg("-t") | ||
// TODO Upload this to Docker Hub, so it's easier to distribute | ||
.arg("elevation_lookups") | ||
.arg("elevation_lookups_lidar") | ||
.arg("python3") | ||
.arg("main.py") | ||
.arg("query"), | ||
|
@@ -78,7 +78,8 @@ fn generate_input(map: &RawMap) -> Result<Vec<OriginalRoad>> { | |
while dist <= pl.length() { | ||
let (pt, _) = pl.dist_along(dist).unwrap(); | ||
pts.push(pt); | ||
dist += Distance::meters(1.0); | ||
// Smaller gives more detail, but is slower. | ||
dist += Distance::meters(5.0); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dabreegster
Author
Collaborator
|
||
} | ||
// Always ask for the intersection | ||
if *pts.last().unwrap() != pl.last_pt() { | ||
|
@@ -103,21 +104,50 @@ fn scrape_output(map: &mut RawMap, ids: Vec<OriginalRoad>) -> Result<()> { | |
.lines() | ||
.zip(ids) | ||
{ | ||
cnt += 1; | ||
let line = line?; | ||
let mut values = Vec::new(); | ||
for x in line.split('\t') { | ||
values.push(Distance::meters(x.parse::<f64>()?)); | ||
let x = x.parse::<f64>()?; | ||
if !x.is_finite() { | ||
// TODO Warn | ||
continue; | ||
} | ||
values.push(Distance::meters(x)); | ||
} | ||
if values.len() != 4 { | ||
bail!("Elevation output line \"{}\" doesn't have 4 numbers", line); | ||
error!("Elevation output line \"{}\" doesn't have 4 numbers", line); | ||
continue; | ||
} | ||
// TODO Also put total_climb and total_descent on the roads | ||
map.intersections.get_mut(&id.i1).unwrap().elevation = values[0]; | ||
map.intersections.get_mut(&id.i2).unwrap().elevation = values[1]; | ||
cnt += 1; | ||
} | ||
if cnt != num_ids { | ||
bail!("Output had {} lines, but we made {} queries", cnt, num_ids); | ||
} | ||
|
||
// Calculate the incline for each road here, before the road gets trimmed for intersection | ||
// geometry. If we did this after trimming, we'd miss some of the horizontal distance. | ||
for (id, road) in &mut map.roads { | ||
let rise = map.intersections[&id.i2].elevation - map.intersections[&id.i1].elevation; | ||
let run = PolyLine::unchecked_new(road.center_points.clone()).length(); | ||
if !(rise / run).is_finite() { | ||
// TODO Warn? | ||
continue; | ||
} | ||
road.percent_incline = rise / run; | ||
// Per https://wiki.openstreetmap.org/wiki/Key:incline#Common_.26_extreme_inclines, we | ||
// shouldn't often see values outside a certain range. Adjust this when we import | ||
// somewhere exceeding this... | ||
if road.percent_incline.abs() > 0.3 { | ||
error!( | ||
"{} is unexpectedly steep! Incline is {}%", | ||
id, | ||
road.percent_incline * 100.0 | ||
); | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |
I'm curious about comparing results with different spacings. The Puget Sound LIDAR data has 1m pixels, but when I look at it visually I only tend to see clear breaks at scales of 10m or more so I suspect they've applied some smoothing to avoid noise from things like vehicles on the roadway. There's a good chance that you'll see close to no difference at all with sample spacing anywhere between 1m and 10m. And if the smoothing wasn't applied, sampling too frequently might actually increase noise more than signal.