handle linear waterway areas

This commit is contained in:
Dustin Carlino 2018-09-16 15:20:28 -07:00
parent 304b4e929e
commit dba3893ee5
5 changed files with 23 additions and 22 deletions

View File

@ -78,12 +78,6 @@ pub fn osm_to_raw_roads(osm_path: &str) -> raw_data::Map {
});
} else if let Some(at) = get_area_type(&way.tags) {
// TODO need to handle inner/outer relations from OSM
// TODO waterway with non-closed points is a polyline creek... draw with some amount of
// thickness
if pts.len() < 3 || pts[0] != *pts.last().unwrap() {
println!("Skipping area {:?} with weird points", way.tags);
continue;
}
map.areas.push(raw_data::Area {
area_type: at,
osm_way_id: way.id,

View File

@ -25,16 +25,14 @@ impl Hider {
}
let item = match selected {
// TODO why not be able to hide anything?
Some(id) => match id {
ID::Intersection(_) => id.clone(),
ID::Lane(_) => id.clone(),
ID::Building(_) => id.clone(),
ID::ExtraShape(_) => id.clone(),
_ => {
return false;
}
},
// No real use case for hiding moving stuff
Some(ID::Car(_)) => {
return false;
}
Some(ID::Pedestrian(_)) => {
return false;
}
Some(id) => id.clone(),
_ => {
return false;
}

View File

@ -17,7 +17,7 @@ impl DrawArea {
pub fn new(area: &Area) -> DrawArea {
DrawArea {
id: area.id,
fill_polygon: Polygon::new(&area.points),
fill_polygon: area.get_polygon(),
color: match area.area_type {
AreaType::Park => Colors::ParkArea,
AreaType::Swamp => Colors::SwampArea,

View File

@ -31,7 +31,7 @@ fi
COMMON="--elevation=$ELEVATION --traffic_signals=$TRAFFIC_SIGNALS --parcels=../data/seattle_parcels.abst --gtfs=$GTFS"
cd convert_osm
time cargo run -- --osm=$SMALL_OSM $COMMON --output=../data/small.abst
#time cargo run --release -- --osm=$MEDIUM_OSM $COMMON --output=../data/medium.abst
#time cargo run --release -- --osm=$LARGE_OSM $COMMON --output=../data/large.abst
#time cargo run --release -- --osm=$HUGE_OSM $COMMON --output=../data/huge.abst
time cargo run --release -- --osm=$SMALL_OSM $COMMON --output=../data/small.abst
time cargo run --release -- --osm=$MEDIUM_OSM $COMMON --output=../data/medium.abst
time cargo run --release -- --osm=$LARGE_OSM $COMMON --output=../data/large.abst
time cargo run --release -- --osm=$HUGE_OSM $COMMON --output=../data/huge.abst

View File

@ -1,5 +1,6 @@
use abstutil;
use geom::{PolyLine, Pt2D};
use geom::{PolyLine, Polygon, Pt2D};
use geometry::LANE_THICKNESS;
use std::collections::BTreeMap;
use std::fmt;
@ -24,6 +25,7 @@ pub enum AreaType {
pub struct Area {
pub id: AreaID,
pub area_type: AreaType,
// Might be a closed loop or not -- waterways can be linear.
pub points: Vec<Pt2D>,
pub osm_tags: BTreeMap<String, String>,
pub osm_way_id: i64,
@ -40,4 +42,11 @@ impl Area {
println!("{}", abstutil::to_json(self));
println!("{}", PolyLine::new(self.points.clone()));
}
pub fn get_polygon(&self) -> Polygon {
if self.points[0] == *self.points.last().unwrap() {
return Polygon::new(&self.points);
}
PolyLine::new(self.points.clone()).make_polygons_blindly(LANE_THICKNESS)
}
}