importer/
map_config.rs

1use abstio::{CityName, MapName};
2use geom::Distance;
3use map_model::DrivingSide;
4
5/// Given the name of a map, configure its import.
6///
7/// Note this was once expressed as config files for every city. That was less maintainable; most
8/// places used default values that were copied around.
9// Slightly more verbose logic feels easier to read
10#[allow(clippy::match_like_matches_macro)]
11pub fn config_for_map(name: &MapName) -> convert_osm::Options {
12    convert_osm::Options {
13        map_config: osm2streets::MapConfig {
14            // osm2streets will set this anyway, it doesn't matter here
15            driving_side: DrivingSide::Right,
16            country_code: String::new(),
17            bikes_can_use_bus_lanes: name.city.country != "pl",
18            inferred_sidewalks: name.city.country != "pl",
19            street_parking_spot_length: if name.city == CityName::new("ca", "montreal") {
20                Distance::meters(6.5)
21            } else {
22                Distance::meters(8.0)
23            },
24            turn_on_red: name.city.country == "us" && name.city.city != "nyc",
25            include_railroads: match name.city.city.as_ref() {
26                "phoenix" | "seattle" | "tucson" => false,
27                _ => {
28                    if name.map == "hammersmith_and_fulham" {
29                        // TODO Some movement geometry bug here
30                        false
31                    } else {
32                        true
33                    }
34                }
35            },
36        },
37        filter_crosswalks: false,
38        onstreet_parking: match name.city.city.as_ref() {
39            "seattle" => {
40                convert_osm::OnstreetParking::Blockface(name.city.input_path("blockface.bin"))
41            }
42            _ => convert_osm::OnstreetParking::JustOSM,
43        },
44        public_offstreet_parking: if name.city == CityName::seattle() {
45            convert_osm::PublicOffstreetParking::Gis(name.city.input_path("offstreet_parking.bin"))
46        } else {
47            convert_osm::PublicOffstreetParking::None
48        },
49        private_offstreet_parking: if name.city == CityName::seattle() {
50            convert_osm::PrivateOffstreetParking::FixedPerBldg(
51                // TODO Utter guesses or in response to gridlock
52                match name.map.as_ref() {
53                    "downtown" => 5,
54                    "lakeslice" => 5,
55                    "qa" => 5,
56                    "south_seattle" => 5,
57                    "wallingford" => 5,
58                    _ => 1,
59                },
60            )
61        } else {
62            convert_osm::PrivateOffstreetParking::FixedPerBldg(3)
63        },
64        // Unused currently
65        extra_buildings: None,
66        // https://www.transit.land is a great place to find the static GTFS URLs
67        gtfs_url: if name == &MapName::new("us", "seattle", "arboretum") {
68            Some("http://metro.kingcounty.gov/GTFS/google_transit.zip".to_string())
69        } else if name.city == CityName::new("us", "san_francisco") {
70            None
71            // Crashing the traffic sim, so disabled
72            //Some("https://gtfs.sfmta.com/transitdata/google_transit.zip".to_string())
73        } else if name == &MapName::new("br", "sao_paulo", "aricanduva") {
74            Some("https://github.com/transitland/gtfs-archives-not-hosted-elsewhere/blob/master/sao-paulo-sptrans.zip?raw=true".to_string())
75        } else if name.city == CityName::new("fr", "brest") {
76            Some("https://ratpdev-mosaic-prod-bucket-raw.s3-eu-west-1.amazonaws.com/11/exports/1/gtfs.zip".to_string())
77        } else {
78            None
79        },
80        // We only have a few elevation sources working
81        elevation_geotiff: if name.city == CityName::new("us", "seattle") {
82            Some("data/input/shared/elevation/king_county_2016_lidar.tif".to_string())
83        } else if name.city.country == "gb" {
84            Some("data/input/shared/elevation/UK-dem-50m-4326.tif".to_string())
85        } else if name.city.country == "pt" {
86            Some("data/input/shared/elevation/LisboaIST_10m_4326.tif".to_string())
87        } else {
88            None
89        },
90    }
91}