Skip to content

Commit

Permalink
Use osm.pbf for the main import process
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Dec 31, 2023
1 parent 888643c commit 35bf958
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 18 deletions.
144 changes: 137 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/src/one_step_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub async fn run(
} else {
println!("Figuring out what Geofabrik file contains your boundary");
let (url, pbf) = importer::pick_geofabrik(geojson_path.clone()).await?;
osm = city.input_path(format!("osm/{}.osm", name));
osm = city.input_path(format!("osm/{}.osm.pbf", name));
fs_err::create_dir_all(std::path::Path::new(&pbf).parent().unwrap())
.expect("Creating parent dir failed");
fs_err::create_dir_all(std::path::Path::new(&osm).parent().unwrap())
Expand Down
4 changes: 2 additions & 2 deletions convert_osm/src/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ pub fn extract_osm(
opts: &Options,
timer: &mut Timer,
) -> Extract {
let osm_xml = fs_err::read_to_string(osm_input_path).unwrap();
let osm_input_bytes = fs_err::read(osm_input_path).unwrap();
let mut doc = streets_reader::osm_reader::Document::read(
&osm_xml,
&osm_input_bytes,
clip_pts.as_ref().map(|pts| GPSBounds::from(pts.clone())),
timer,
)
Expand Down
2 changes: 1 addition & 1 deletion importer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub async fn regenerate_everything(shard_num: usize, num_shards: usize) {
}
}

/// Transforms a .osm file to a map in one step.
/// Transforms a .osm.xml or .pbf file to a map in one step.
pub async fn oneshot(
osm_path: String,
clip: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion importer/src/soundcast/popdat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn import_parcels(
attributes.insert("parking".to_string(), offstreet_parking_spaces.to_string());
}
if let Some(b) = osm_building {
attributes.insert("osm_bldg".to_string(), b.inner().to_string());
attributes.insert("osm_bldg".to_string(), b.inner_id().to_string());
}
shapes.insert(
id,
Expand Down
10 changes: 5 additions & 5 deletions importer/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ pub async fn download_kml(
fs_err::rename(tmp, output.replace(".bin", ".kml")).unwrap();
}

/// Uses osmium to clip the input .osm (or .pbf) against a polygon and produce some output. Skips
/// if the output exists.
/// Uses osmium to clip the input .osm.xml or osm.pbf against a polygon and produce some output pbf
/// file. Skips if the output exists.
pub fn osmium(
input: String,
clipping_polygon: String,
Expand Down Expand Up @@ -114,7 +114,7 @@ pub fn osmium(
.arg(output)
.arg("-f")
// Smaller files without author, timestamp, version
.arg("osm,add_metadata=false"),
.arg("pbf,add_metadata=false"),
);
}

Expand Down Expand Up @@ -144,12 +144,12 @@ pub async fn osm_to_raw(
osmium(
local_osm_file,
boundary_polygon.clone(),
name.city.input_path(format!("osm/{}.osm", name.map)),
name.city.input_path(format!("osm/{}.osm.pbf", name.map)),
config,
);

let map = convert_osm::convert(
name.city.input_path(format!("osm/{}.osm", name.map)),
name.city.input_path(format!("osm/{}.osm.pbf", name.map)),
name.clone(),
Some(boundary_polygon),
opts,
Expand Down
2 changes: 1 addition & 1 deletion map_model/src/make/buildings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn make_all_buildings(

let id = BuildingID(results.len());

let mut rng = XorShiftRng::seed_from_u64(orig_id.inner() as u64);
let mut rng = XorShiftRng::seed_from_u64(orig_id.inner_id() as u64);
// TODO is it worth using height or building:height as an alternative if not tagged?
let levels = b
.osm_tags
Expand Down

0 comments on commit 35bf958

Please sign in to comment.