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
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 elevation: Option<String>,
pub include_railroads: bool,
}
impl GenericCityImporter {
pub 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 = format!(
"input/{}/osm/{}",
name.city,
std::path::Path::new(&self.osm_url)
.file_name()
.unwrap()
.to_os_string()
.into_string()
.unwrap()
);
download(config, &file, &self.osm_url);
file
} else {
self.osm_url.clone()
};
osmconvert(
&local_osm_file,
format!("importer/config/{}/{}.poly", name.city, name.map),
format!("input/{}/osm/{}.osm", name.city, name.map),
config,
);
let map = convert_osm::convert(
convert_osm::Options {
osm_input: abstio::path(format!("input/{}/osm/{}.osm", name.city, name.map)),
name: name.clone(),
clip: Some(format!("importer/config/{}/{}.poly", name.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(),
elevation: self.elevation.clone(),
include_railroads: self.include_railroads,
},
timer,
);
map.save();
map
}
}