diff --git a/book/src/dev/README.md b/book/src/dev/README.md index 89baf09371..1a8a20b141 100644 --- a/book/src/dev/README.md +++ b/book/src/dev/README.md @@ -92,6 +92,7 @@ You can rerun specific stages of the importer: `convert_osm`, you need `./import.sh --raw --map`. - If you're modifying `map_model` but not the OSM -> RawMap conversion, then you just need `./import.sh --map`. +- If you're modifying the demand model for Seattle, you can add `--scenario` to regenerate. - By default, all maps are regenerated. You can also specify a single map: `./import.sh --map downtown`. - By default, Seattle is assumed as the city. You have to specify otherwise: diff --git a/map_model/src/edits/perma.rs b/map_model/src/edits/perma.rs index 7f4cb6c2e5..72e6c7f065 100644 --- a/map_model/src/edits/perma.rs +++ b/map_model/src/edits/perma.rs @@ -116,12 +116,12 @@ impl PermanentMapEdits { let id = map.find_i_by_osm_id(i)?; Ok(EditCmd::ChangeIntersection { i: id, - new: new - .from_permanent(id, map) - .ok_or(format!("new ChangeIntersection of {} invalid", i))?, - old: old - .from_permanent(id, map) - .ok_or(format!("old ChangeIntersection of {} invalid", i))?, + new: new.from_permanent(id, map).map_err(|err| { + format!("new ChangeIntersection of {} invalid: {}", i, err) + })?, + old: old.from_permanent(id, map).map_err(|err| { + format!("old ChangeIntersection of {} invalid: {}", i, err) + })?, }) } PermanentEditCmd::ChangeRouteSchedule { @@ -165,29 +165,35 @@ impl EditIntersection { } impl PermanentEditIntersection { - fn from_permanent(self, i: IntersectionID, map: &Map) -> Option { + fn from_permanent(self, i: IntersectionID, map: &Map) -> Result { match self { PermanentEditIntersection::StopSign { must_stop } => { let mut translated_must_stop = BTreeMap::new(); for (r, stop) in must_stop { - translated_must_stop.insert(map.find_r_by_osm_id(r).ok()?, stop); + translated_must_stop.insert(map.find_r_by_osm_id(r)?, stop); } // Make sure the roads exactly match up let mut ss = ControlStopSign::new(map, i); if translated_must_stop.len() != ss.roads.len() { - return None; + return Err(format!( + "Stop sign has {} roads now, but {} from edits", + ss.roads.len(), + translated_must_stop.len() + )); } for (r, stop) in translated_must_stop { - ss.roads.get_mut(&r)?.must_stop = stop; + if let Some(road) = ss.roads.get_mut(&r) { + road.must_stop = stop; + } else { + return Err(format!("{} doesn't connect to {}", i, r)); + } } - Some(EditIntersection::StopSign(ss)) + Ok(EditIntersection::StopSign(ss)) } - PermanentEditIntersection::TrafficSignal(ts) => { - Some(EditIntersection::TrafficSignal(ts)) - } - PermanentEditIntersection::Closed => Some(EditIntersection::Closed), + PermanentEditIntersection::TrafficSignal(ts) => Ok(EditIntersection::TrafficSignal(ts)), + PermanentEditIntersection::Closed => Ok(EditIntersection::Closed), } } }