1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use geom::Polygon;
use map_model::{Area, AreaID, AreaType, Map};
use widgetry::{Color, EventCtx, Fill, GeomBatch, GfxCtx, Line, Text};
use crate::colors::ColorScheme;
use crate::render::{DrawOptions, Renderable};
use crate::{AppLike, ID};
pub struct DrawArea {
pub id: AreaID,
}
impl DrawArea {
pub fn new(
ctx: &EventCtx,
area: &Area,
cs: &ColorScheme,
all_areas: &mut GeomBatch,
) -> DrawArea {
all_areas.push(DrawArea::fill(area.area_type, cs), area.polygon.clone());
if false {
if let Some(name) = area.osm_tags.get("name") {
all_areas.append(
Text::from(Line(name).fg(Color::BLACK))
.render_autocropped(ctx)
.scale(1.0)
.centered_on(area.polygon.polylabel())
.set_z_offset(-0.1),
);
}
}
DrawArea { id: area.id }
}
pub fn fill(area_type: AreaType, cs: &ColorScheme) -> Fill {
match area_type {
AreaType::Park => cs.grass.clone(),
AreaType::Water => cs.water.clone(),
AreaType::Island => cs.map_background.clone(),
AreaType::MedianStrip => cs.median_strip.clone(),
}
}
}
impl Renderable for DrawArea {
fn get_id(&self) -> ID {
ID::Area(self.id)
}
fn draw(&self, _: &mut GfxCtx, _: &dyn AppLike, _: &DrawOptions) {}
fn get_outline(&self, map: &Map) -> Polygon {
map.get_a(self.id).polygon.clone()
}
}