some instructions to import a new .osm. don't require a clipping

polygon. small tweaks to map construction to make Austin work.
This commit is contained in:
Dustin Carlino 2019-07-14 14:16:50 +01:00
parent 6d559a2a54
commit 453204129c
5 changed files with 49 additions and 4 deletions

View File

@ -19,6 +19,7 @@ Watching overall traffic patterns and zooming into a few slow areas:
- [Map model](docs/articles/map/article.md)
- [Traffic simulation](docs/articles/trafficsim/article.md)
- [Rust implementation notes](docs/articles/rust/article.md)
- [Running A/B Street in a new city](docs/new_city.md)
- [Features (outdated)](docs/articles/features/article.md)
## Features

View File

@ -5,7 +5,7 @@ mod remove_disconnected;
mod split_ways;
use abstutil::Timer;
use geom::{Distance, FindClosest, LonLat, PolyLine, Pt2D};
use geom::{Distance, FindClosest, GPSBounds, LonLat, PolyLine, Pt2D};
use kml::ExtraShapes;
use map_model::{raw_data, IntersectionType, LANE_THICKNESS};
use std::fs::File;
@ -37,8 +37,8 @@ pub struct Flags {
#[structopt(long = "neighborhoods", default_value = "")]
pub neighborhoods: String,
/// Osmosis clipping polgon
#[structopt(long = "clip")]
/// Osmosis clipping polgon. Optional.
#[structopt(long = "clip", default_value = "")]
pub clip: String,
/// Output .bin path
@ -52,7 +52,15 @@ pub struct Flags {
pub fn convert(flags: &Flags, timer: &mut abstutil::Timer) -> raw_data::Map {
let mut map = split_ways::split_up_roads(osm::osm_to_raw_roads(&flags.osm, timer), timer);
map.boundary_polygon = read_osmosis_polygon(&flags.clip);
if !flags.clip.is_empty() {
map.boundary_polygon = read_osmosis_polygon(&flags.clip);
} else {
// Default to a rectangle covering everything.
map.compute_gps_bounds();
map.boundary_polygon = map.gps_bounds.get_corners();
map.boundary_polygon.push(map.boundary_polygon[0]);
map.gps_bounds = GPSBounds::new();
}
clip::clip_map(&mut map, timer);
remove_disconnected::remove_disconnected_roads(&mut map, timer);

29
docs/new_city.md Normal file
View File

@ -0,0 +1,29 @@
# Importing a new city into A/B Street
My current priority is to make Seattle work very well, but if you want to try
out A/B Street in another place, you can follow this guide. Please file a Github
issue or email <dabreegster@gmail.com> if you hit any problems.
First make sure you can compile everything [from source](INSTRUCTIONS.md). Put
some `.osm` (pre-clipped to whatever area you want via Osmosis or something
else) into `data/input`. Then run:
```
cd convert_osm
cargo run --release -- \
--osm=../data/input/your_city.osm \
--output=../data/raw_maps/your_city.bin
cd ../precompute
cargo run --release -- ../data/raw_maps/your_city.bin
```
You should now be able to load the map using the option from the main game menu,
or by running `cd editor; cargo run --release ../data/maps/your_city.osm`.
## Future work
There are Seattleisms baked into the code.
- `import.sh` should be generalized.
- The driving side of the road is hard-coded to the right. Look for "driving on
the left" in `map_model/src/make/half_map.rs`.

View File

@ -124,6 +124,12 @@ fn generalized_trim_back(
(pl1.clone(), pl2.clone())
};
// TODO This only happens in Austin so far, haven't dove into why.
if use_pl1 == use_pl2 {
timer.warn(format!("{} and {} wind up with the same polyline", r1, r2));
continue;
}
if let Some((hit, angle)) = use_pl1.intersection(&use_pl2) {
// Find where the perpendicular hits the original road line
let perp = Line::new(

View File

@ -396,6 +396,7 @@ impl Road {
"unclassified" => 0,
"road" => 0,
"crossing" => 0,
_ => panic!("Unknown OSM highway {}", highway),
}
} else {