mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-24 15:02:59 +03:00
Prepare the new map importer to work in the release. [rebuild]
This commit is contained in:
parent
c0e49f815f
commit
359960c1db
6
.github/workflows/main.yml
vendored
6
.github/workflows/main.yml
vendored
@ -58,10 +58,8 @@ jobs:
|
||||
working-directory: parking_mapper
|
||||
run: cargo build --release ${features}
|
||||
|
||||
- name: Build importer
|
||||
run: cargo build --release --bin importer
|
||||
- name: Build headless
|
||||
run: cargo build --release --bin headless
|
||||
- name: Build other tools
|
||||
run: cargo build --release --bin importer --bin one_step_import --bin geojson_to_osmosis --bin pick_geofabrik --bin clip_osm
|
||||
|
||||
- name: Download system data
|
||||
run: cargo run --release --bin updater -- --quiet
|
||||
|
@ -9,29 +9,31 @@ use abstutil::{must_run_cmd, CmdArgs};
|
||||
|
||||
/// Import a one-shot A/B Street map in a single command. Takes a GeoJSON file with a boundary as
|
||||
/// input. Automatically fetches the OSM data, clips it, and runs the importer.
|
||||
/// TODO It currently overwrites a few fixed output files and doesn't clean them up.
|
||||
fn main() -> Result<()> {
|
||||
let mut args = CmdArgs::new();
|
||||
let geojson_path = args.required_free();
|
||||
let drive_on_left = args.enabled("--drive_on_left");
|
||||
args.done();
|
||||
|
||||
// TODO Assume we're running from git and all the tools are built in the appropriate directory.
|
||||
let bin_dir = if Path::new("target").exists() {
|
||||
"./target"
|
||||
} else if Path::new("../target").exists() {
|
||||
"../target"
|
||||
} else if Path::new("../../target").exists() {
|
||||
"../../target"
|
||||
} else {
|
||||
panic!("Can't find target/ directory");
|
||||
};
|
||||
// Handle running from a binary release or from git. If the latter and the user hasn't built
|
||||
// the tools, they'll get an error.
|
||||
let bin_dir = vec![
|
||||
"./target/release",
|
||||
"../target/release",
|
||||
"../../target/release",
|
||||
"./tools",
|
||||
"../tools",
|
||||
]
|
||||
.into_iter()
|
||||
.find(|x| Path::new(x).exists())
|
||||
.expect("Can't find target/ or tools/ directory");
|
||||
println!("Found other executables at {}", bin_dir);
|
||||
|
||||
// Convert to a boundary polygon. This tool reads from STDIN.
|
||||
{
|
||||
println!("Converting GeoJSON to Osmosis boundary");
|
||||
let geojson = abstio::slurp_file(geojson_path)?;
|
||||
let mut cmd = Command::new(format!("{}/debug/geojson_to_osmosis", bin_dir))
|
||||
let mut cmd = Command::new(format!("{}/geojson_to_osmosis", bin_dir))
|
||||
.stdin(Stdio::piped())
|
||||
.spawn()?;
|
||||
let stdin = cmd.stdin.as_mut().unwrap();
|
||||
@ -42,7 +44,7 @@ fn main() -> Result<()> {
|
||||
// What file should we download?
|
||||
let url = {
|
||||
println!("Figuring out what Geofabrik file contains your boundary");
|
||||
let out = Command::new(format!("{}/debug/pick_geofabrik", bin_dir))
|
||||
let out = Command::new(format!("{}/pick_geofabrik", bin_dir))
|
||||
.arg("boundary0.poly")
|
||||
.output()?;
|
||||
assert!(out.status.success());
|
||||
@ -74,7 +76,7 @@ fn main() -> Result<()> {
|
||||
// Clip it
|
||||
println!("Clipping osm.pbf file to your boundary");
|
||||
must_run_cmd(
|
||||
Command::new(format!("{}/release/clip_osm", bin_dir))
|
||||
Command::new(format!("{}/clip_osm", bin_dir))
|
||||
.arg(format!("--pbf={}", pbf))
|
||||
.arg("--clip=boundary0.poly")
|
||||
.arg(format!("--out={}", osm)),
|
||||
@ -82,7 +84,7 @@ fn main() -> Result<()> {
|
||||
|
||||
// Import!
|
||||
{
|
||||
let mut cmd = Command::new(format!("{}/release/importer", bin_dir));
|
||||
let mut cmd = Command::new(format!("{}/importer", bin_dir));
|
||||
cmd.arg(format!("--oneshot={}", osm));
|
||||
cmd.arg("--oneshot_clip=boundary0.poly");
|
||||
if drive_on_left {
|
||||
|
@ -28,7 +28,7 @@ impl<A: AppLike + 'static> RunCommand<A> {
|
||||
pub fn new(
|
||||
ctx: &mut EventCtx,
|
||||
_: &A,
|
||||
args: Vec<&str>,
|
||||
args: Vec<String>,
|
||||
on_load: Box<dyn FnOnce(&mut EventCtx, &mut A, bool, Vec<String>) -> Transition<A>>,
|
||||
) -> Box<dyn State<A>> {
|
||||
info!("RunCommand: {}", args.join(" "));
|
||||
|
@ -82,9 +82,22 @@ impl<A: AppLike + 'static> State<A> for ImportCity<A> {
|
||||
Transition::Keep
|
||||
}
|
||||
"Import the area from your clipboard" => {
|
||||
let mut args = vec!["../target/debug/one_step_import", "boundary.geojson"];
|
||||
let bin_dir = vec![
|
||||
"./target/release",
|
||||
"../target/release",
|
||||
"../../target/release",
|
||||
"./tools",
|
||||
"../tools",
|
||||
]
|
||||
.into_iter()
|
||||
.find(|x| std::path::Path::new(x).exists())
|
||||
.unwrap_or("./target/release");
|
||||
let mut args = vec![
|
||||
format!("{}/one_step_import", bin_dir),
|
||||
"boundary.geojson".to_string(),
|
||||
];
|
||||
if !self.panel.is_checked("driving side") {
|
||||
args.push("--drive_on_left");
|
||||
args.push("--drive_on_left".to_string());
|
||||
}
|
||||
match grab_geojson_from_clipboard() {
|
||||
Ok(()) => Transition::Push(crate::tools::command::RunCommand::new(
|
||||
|
@ -38,10 +38,15 @@ cp release/$runner release/INSTRUCTIONS.txt $output
|
||||
mkdir $output/game
|
||||
cp target/release/game${suffix} $output/game
|
||||
|
||||
for name in fifteen_min osm_viewer parking_mapper santa importer; do
|
||||
for name in fifteen_min osm_viewer parking_mapper santa; do
|
||||
cp target/release/${name}${suffix} $output;
|
||||
done
|
||||
|
||||
mkdir $output/tools
|
||||
for name in importer one_step_import geojson_to_osmosis pick_geofabrik clip_osm; do
|
||||
cp target/release/${name}${suffix} $output/tools;
|
||||
done
|
||||
|
||||
mkdir $output/data
|
||||
cp -Rv data/system $output/data/system
|
||||
cp data/MANIFEST.json $output/data
|
||||
|
Loading…
Reference in New Issue
Block a user