disabled: import and render pedestrian traffic islands. include them in

search results.
This commit is contained in:
Dustin Carlino 2019-11-14 10:54:11 -08:00
parent 53bbf4e272
commit 98ef31fa24
5 changed files with 32 additions and 31 deletions

View File

@ -329,6 +329,17 @@ fn get_area_type(tags: &BTreeMap<String, String>) -> Option<AreaType> {
if tags.get("natural") == Some(&"water".to_string()) { if tags.get("natural") == Some(&"water".to_string()) {
return Some(AreaType::Water); return Some(AreaType::Water);
} }
// TODO These just cover up poorly inferred road geometry now. Figure out how to use these.
if false {
if tags.get("traffic_calming") == Some(&"island".to_string()) {
return Some(AreaType::PedestrianIsland);
}
if tags.get("highway") == Some(&"pedestrian".to_string())
&& tags.get("area") == Some(&"yes".to_string())
{
return Some(AreaType::PedestrianIsland);
}
}
None None
} }

View File

@ -336,6 +336,15 @@ fn search_osm(wiz: &mut Wizard, ctx: &mut EventCtx, ui: &mut UI) -> Option<Trans
batch.push(color, b.polygon.clone()); batch.push(color, b.polygon.clone());
} }
} }
for a in map.all_areas() {
if a.osm_tags
.iter()
.any(|(k, v)| format!("{} = {}", k, v).contains(&filter))
{
ids.insert(ID::Area(a.id));
batch.push(color, a.polygon.clone());
}
}
let results = SearchResults { let results = SearchResults {
query: filter, query: filter,

View File

@ -1,6 +1,6 @@
use crate::helpers::ID; use crate::helpers::ID;
use crate::render::{DrawCtx, DrawOptions, Renderable}; use crate::render::{DrawCtx, DrawOptions, Renderable};
use ezgui::{EventCtx, GeomBatch, GfxCtx}; use ezgui::{Color, EventCtx, GeomBatch, GfxCtx};
use geom::Polygon; use geom::Polygon;
use map_model::{Area, AreaID, AreaType, Map}; use map_model::{Area, AreaID, AreaType, Map};
@ -9,26 +9,13 @@ pub struct DrawArea {
} }
impl DrawArea { impl DrawArea {
pub fn new( pub fn new(area: &Area, ctx: &EventCtx, all_areas: &mut GeomBatch) -> DrawArea {
area: &Area, let color = match area.area_type {
ctx: &EventCtx, AreaType::Park => ctx.canvas.texture("assets/grass_texture.png"),
all_park_areas: &mut GeomBatch, AreaType::Water => ctx.canvas.texture("assets/water_texture.png"),
all_water_areas: &mut GeomBatch, AreaType::PedestrianIsland => Color::grey(0.3),
) -> DrawArea { };
match area.area_type { all_areas.push(color, area.polygon.clone());
AreaType::Park => {
all_park_areas.push(
ctx.canvas.texture("assets/grass_texture.png"),
area.polygon.clone(),
);
}
AreaType::Water => {
all_water_areas.push(
ctx.canvas.texture("assets/water_texture.png"),
area.polygon.clone(),
);
}
}
DrawArea { id: area.id } DrawArea { id: area.id }
} }
} }

View File

@ -209,21 +209,14 @@ impl DrawMap {
} }
let mut areas: Vec<DrawArea> = Vec::new(); let mut areas: Vec<DrawArea> = Vec::new();
let mut all_park_areas = GeomBatch::new(); let mut all_areas = GeomBatch::new();
let mut all_water_areas = GeomBatch::new();
timer.start_iter("make DrawAreas", map.all_areas().len()); timer.start_iter("make DrawAreas", map.all_areas().len());
for a in map.all_areas() { for a in map.all_areas() {
timer.next(); timer.next();
areas.push(DrawArea::new( areas.push(DrawArea::new(a, ctx, &mut all_areas));
a,
ctx,
&mut all_park_areas,
&mut all_water_areas,
));
} }
timer.start("upload all areas"); timer.start("upload all areas");
all_park_areas.append(all_water_areas); let draw_all_areas = ctx.prerender.upload(all_areas);
let draw_all_areas = ctx.prerender.upload(all_park_areas);
timer.stop("upload all areas"); timer.stop("upload all areas");
let boundary_polygon = ctx.prerender.upload_borrowed(vec![( let boundary_polygon = ctx.prerender.upload_borrowed(vec![(

View File

@ -18,6 +18,7 @@ impl fmt::Display for AreaID {
pub enum AreaType { pub enum AreaType {
Park, Park,
Water, Water,
PedestrianIsland,
} }
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]