mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-09-19 06:37:15 +03:00
Call osmium, not osmconvert
This commit is contained in:
parent
cf6fe6ce4d
commit
01f7277127
@ -66,8 +66,8 @@ enum Command {
|
||||
#[structopt(long, default_value = "42")]
|
||||
rng_seed: u64,
|
||||
},
|
||||
/// Clips an OSM file to a boundary. This is a simple Rust port of `osmconvert large_map.osm
|
||||
/// -B=clipping.poly --complete-ways -o=smaller_map.osm`.
|
||||
/// Clips an OSM file to a boundary. This is a simple Rust port of `osmium extract large_map.osm
|
||||
/// -p clipping.poly -o smaller_map.osm`.
|
||||
ClipOSM {
|
||||
/// The path to the input .osm.pbf file
|
||||
#[structopt(long)]
|
||||
|
@ -3,7 +3,7 @@ use serde::Deserialize;
|
||||
#[derive(Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct ImporterConfiguration {
|
||||
pub osmconvert: String,
|
||||
pub osmium: String,
|
||||
pub unzip: String,
|
||||
pub gunzip: String,
|
||||
pub gunzip_args: String,
|
||||
@ -12,7 +12,7 @@ pub struct ImporterConfiguration {
|
||||
impl Default for ImporterConfiguration {
|
||||
fn default() -> ImporterConfiguration {
|
||||
ImporterConfiguration {
|
||||
osmconvert: String::from("osmconvert"),
|
||||
osmium: String::from("osmium"),
|
||||
unzip: String::from("unzip"),
|
||||
gunzip: String::from("gunzip"),
|
||||
gunzip_args: String::from(""),
|
||||
|
@ -83,16 +83,9 @@ pub async fn download_kml(
|
||||
fs_err::rename(tmp, output.replace(".bin", ".kml")).unwrap();
|
||||
}
|
||||
|
||||
/// Uses osmconvert to clip the input .osm (or .pbf) against a polygon and produce some output.
|
||||
/// Skips if the output exists.
|
||||
fn osmconvert(
|
||||
input: String,
|
||||
clipping_polygon: String,
|
||||
output: String,
|
||||
config: &ImporterConfiguration,
|
||||
) {
|
||||
let clipping_polygon = clipping_polygon;
|
||||
|
||||
/// Uses osmium to clip the input .osm (or .pbf) against a polygon and produce some output. Skips
|
||||
/// if the output exists.
|
||||
fn osmium(input: String, clipping_polygon: String, output: String, config: &ImporterConfiguration) {
|
||||
if Path::new(&output).exists() {
|
||||
println!("- {} already exists", output);
|
||||
return;
|
||||
@ -103,12 +96,18 @@ fn osmconvert(
|
||||
|
||||
println!("- Clipping {} to {}", input, clipping_polygon);
|
||||
|
||||
// --strategy complete_ways is default
|
||||
must_run_cmd(
|
||||
Command::new(&config.osmconvert)
|
||||
Command::new(&config.osmium)
|
||||
.arg("extract")
|
||||
.arg("-p")
|
||||
.arg(clipping_polygon)
|
||||
.arg(input)
|
||||
.arg(format!("-B={}", clipping_polygon))
|
||||
.arg("--complete-ways")
|
||||
.arg(format!("-o={}", output)),
|
||||
.arg("-o")
|
||||
.arg(output)
|
||||
.arg("-f")
|
||||
// Smaller files without author, timestamp, version
|
||||
.arg("osm,add_metadata=false"),
|
||||
);
|
||||
}
|
||||
|
||||
@ -145,7 +144,7 @@ pub async fn osm_to_raw(
|
||||
));
|
||||
download(config, local_osm_file.clone(), &osm_url).await;
|
||||
|
||||
osmconvert(
|
||||
osmium(
|
||||
local_osm_file,
|
||||
boundary_polygon.clone(),
|
||||
name.city.input_path(format!("osm/{}.osm", name.map)),
|
||||
|
Loading…
Reference in New Issue
Block a user