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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
use serde::{Deserialize, Serialize};
use abstio::MapName;
use map_model::raw::RawMap;
use crate::configuration::ImporterConfiguration;
use crate::utils::{download, osmconvert};
#[derive(Serialize, Deserialize)]
pub struct GenericCityImporter {
pub osm_url: String,
pub map_config: map_model::MapConfig,
pub onstreet_parking: convert_osm::OnstreetParking,
pub public_offstreet_parking: convert_osm::PublicOffstreetParking,
pub private_offstreet_parking: convert_osm::PrivateOffstreetParking,
pub include_railroads: bool,
pub extra_buildings: Option<String>,
pub filter_crosswalks: bool,
}
impl GenericCityImporter {
pub async fn osm_to_raw(
&self,
name: MapName,
timer: &mut abstutil::Timer<'_>,
config: &ImporterConfiguration,
) -> RawMap {
let local_osm_file = if self.osm_url.starts_with("http") {
let file = name.city.input_path(format!(
"osm/{}",
std::path::Path::new(&self.osm_url)
.file_name()
.unwrap()
.to_os_string()
.into_string()
.unwrap()
));
download(config, file.clone(), &self.osm_url).await;
file
} else {
self.osm_url.clone()
};
osmconvert(
local_osm_file,
format!(
"importer/config/{}/{}/{}.poly",
name.city.country, name.city.city, name.map
),
name.city.input_path(format!("osm/{}.osm", name.map)),
config,
);
let map = convert_osm::convert(
convert_osm::Options {
osm_input: name.city.input_path(format!("osm/{}.osm", name.map)),
name: name.clone(),
clip: Some(format!(
"importer/config/{}/{}/{}.poly",
name.city.country, name.city.city, name.map
)),
map_config: self.map_config.clone(),
onstreet_parking: self.onstreet_parking.clone(),
public_offstreet_parking: self.public_offstreet_parking.clone(),
private_offstreet_parking: self.private_offstreet_parking.clone(),
include_railroads: self.include_railroads,
extra_buildings: self.extra_buildings.clone(),
skip_local_roads: name == MapName::new("us", "phoenix", "loop101"),
filter_crosswalks: self.filter_crosswalks,
},
timer,
);
map.save();
map
}
}