duplicate OSM ids in tag maps universally, to simplify some other places

This commit is contained in:
Dustin Carlino 2019-09-17 15:37:11 -07:00
parent ed29a208e4
commit 1e4f36dec1
4 changed files with 12 additions and 15 deletions

View File

@ -75,7 +75,8 @@ pub fn extract_osm(
continue; continue;
} }
let pts = map.gps_bounds.forcibly_convert(&gps_pts); let pts = map.gps_bounds.forcibly_convert(&gps_pts);
let tags = tags_to_map(&way.tags); let mut tags = tags_to_map(&way.tags);
tags.insert("abst:osm_way_id".to_string(), way.id.to_string());
if is_road(&tags) { if is_road(&tags) {
roads.push(raw_data::Road { roads.push(raw_data::Road {
osm_way_id: way.id, osm_way_id: way.id,
@ -126,7 +127,8 @@ pub fn extract_osm(
timer.start_iter("processing OSM relations", doc.relations.len()); timer.start_iter("processing OSM relations", doc.relations.len());
for rel in doc.relations.values() { for rel in doc.relations.values() {
timer.next(); timer.next();
let tags = tags_to_map(&rel.tags); let mut tags = tags_to_map(&rel.tags);
tags.insert("abst:osm_rel_id".to_string(), rel.id.to_string());
if let Some(at) = get_area_type(&tags) { if let Some(at) = get_area_type(&tags) {
if tags.get("type") == Some(&"multipolygon".to_string()) { if tags.get("type") == Some(&"multipolygon".to_string()) {
let mut ok = true; let mut ok = true;

View File

@ -462,7 +462,6 @@ fn search_osm(wiz: &mut Wizard, ctx: &mut EventCtx, ui: &mut UI) -> Option<Trans
if r.osm_tags if r.osm_tags
.iter() .iter()
.any(|(k, v)| format!("{} = {}", k, v).contains(&filter)) .any(|(k, v)| format!("{} = {}", k, v).contains(&filter))
|| format!("{}", r.osm_way_id).contains(&filter)
{ {
for l in r.all_lanes() { for l in r.all_lanes() {
ids.insert(ID::Lane(l)); ids.insert(ID::Lane(l));
@ -474,7 +473,6 @@ fn search_osm(wiz: &mut Wizard, ctx: &mut EventCtx, ui: &mut UI) -> Option<Trans
if b.osm_tags if b.osm_tags
.iter() .iter()
.any(|(k, v)| format!("{} = {}", k, v).contains(&filter)) .any(|(k, v)| format!("{} = {}", k, v).contains(&filter))
|| format!("{}", b.osm_way_id).contains(&filter)
{ {
ids.insert(ID::Building(b.id)); ids.insert(ID::Building(b.id));
batch.push(color, b.polygon.clone()); batch.push(color, b.polygon.clone());

View File

@ -163,7 +163,6 @@ fn tooltip_lines(id: ID, g: &mut GfxCtx, ctx: &PerMapUI) -> Text {
Line(format!("{} is ", l.id)), Line(format!("{} is ", l.id)),
Line(r.get_name()).fg(Color::CYAN), Line(r.get_name()).fg(Color::CYAN),
]); ]);
txt.add(Line(format!("From OSM way {}", r.osm_way_id)));
txt.add(Line(format!( txt.add(Line(format!(
"Parent {} (originally {}) points to {}", "Parent {} (originally {}) points to {}",
r.id, r.stable_id, r.dst_i r.id, r.stable_id, r.dst_i
@ -216,10 +215,7 @@ fn tooltip_lines(id: ID, g: &mut GfxCtx, ctx: &PerMapUI) -> Text {
} }
ID::Building(id) => { ID::Building(id) => {
let b = map.get_b(id); let b = map.get_b(id);
txt.add(Line(format!( txt.add(Line(format!("Building #{:?}", id)));
"Building #{:?} (from OSM way {})",
id, b.osm_way_id
)));
txt.add(Line(format!( txt.add(Line(format!(
"Dist along sidewalk: {}", "Dist along sidewalk: {}",
b.front_path.sidewalk.dist_along() b.front_path.sidewalk.dist_along()
@ -252,7 +248,7 @@ fn tooltip_lines(id: ID, g: &mut GfxCtx, ctx: &PerMapUI) -> Text {
} }
ID::Area(id) => { ID::Area(id) => {
let a = map.get_a(id); let a = map.get_a(id);
txt.add(Line(format!("{} (from OSM {})", id, a.osm_id))); txt.add(Line(format!("{}", id)));
styled_kv(&mut txt, &a.osm_tags); styled_kv(&mut txt, &a.osm_tags);
} }
ID::Trip(_) => {} ID::Trip(_) => {}

View File

@ -313,6 +313,10 @@ impl Model {
); );
osm_tags.insert("abst:endpt_fwd".to_string(), "true".to_string()); osm_tags.insert("abst:endpt_fwd".to_string(), "true".to_string());
osm_tags.insert("abst:endpt_back".to_string(), "true".to_string()); osm_tags.insert("abst:endpt_back".to_string(), "true".to_string());
osm_tags.insert(
"abst:osm_way_id".to_string(),
SYNTHETIC_OSM_WAY_ID.to_string(),
);
let center_points = vec![ let center_points = vec![
self.map.intersections[&i1].point, self.map.intersections[&i1].point,
self.map.intersections[&i2].point, self.map.intersections[&i2].point,
@ -423,11 +427,8 @@ impl Model {
self.map.roads[&id].get_spec().to_string() self.map.roads[&id].get_spec().to_string()
} }
pub fn get_tags(&self, id: StableRoadID) -> BTreeMap<String, String> { pub fn get_tags(&self, id: StableRoadID) -> &BTreeMap<String, String> {
let r = &self.map.roads[&id]; &self.map.roads[&id].osm_tags
let mut tags = r.osm_tags.clone();
tags.insert("abst:osm_way_id".to_string(), r.osm_way_id.to_string());
tags
} }
fn lanes(&self, id: StableRoadID) -> Vec<Object<ID>> { fn lanes(&self, id: StableRoadID) -> Vec<Object<ID>> {