From f8d30c411fc06114247a5371cd80a8eef3f6e493 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Tue, 28 Jun 2022 15:55:07 -0500 Subject: [PATCH] Match amenities defined as areas in OSM to buildings within. This was already working for multipolygon relations, but for some reason not done for ways. This fixes lots of missing schools in Bristol. --- convert_osm/src/extract.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/convert_osm/src/extract.rs b/convert_osm/src/extract.rs index 21a3779514..394285bce1 100644 --- a/convert_osm/src/extract.rs +++ b/convert_osm/src/extract.rs @@ -94,6 +94,7 @@ pub fn extract_osm( let mut coastline_groups: Vec<(WayID, Vec)> = Vec::new(); let mut memorial_areas: Vec = Vec::new(); + let mut amenity_areas: Vec<(Polygon, Amenity)> = Vec::new(); timer.start_iter("processing OSM ways", doc.ways.len()); for (id, way) in &mut doc.ways { timer.next(); @@ -162,6 +163,13 @@ pub fn extract_osm( }); } else if way.tags.is("historic", "memorial") { memorial_areas.push(polygon); + } else if way.tags.contains_key("amenity") { + let amenity = Amenity { + names: NamePerLanguage::new(&way.tags).unwrap_or_else(NamePerLanguage::unnamed), + amenity_type: way.tags.get("amenity").unwrap().clone(), + osm_tags: way.tags.clone(), + }; + amenity_areas.push((polygon, amenity)); } } @@ -174,8 +182,6 @@ pub fn extract_osm( let boundary = map.boundary_polygon.clone().into_ring(); - let mut amenity_areas: Vec<(Polygon, Amenity)> = Vec::new(); - // TODO Fill this out in a separate loop to keep a mutable borrow short. Maybe do this in // reader, or stop doing this entirely. for (id, rel) in &mut doc.relations {