Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

editoast: extract osm_to_railjson in separate binary #10215

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion editoast/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 editoast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ license = "LGPL-3.0"

[workspace.dependencies]
chrono = { version = "0.4.39", default-features = false, features = ["serde"] }
clap = { version = "4.5.23", features = ["derive", "env"] }
derivative = "2.2.0"
diesel = { version = "2.2", default-features = false, features = [
"32-column-tables",
Expand Down Expand Up @@ -158,7 +159,6 @@ opentelemetry-otlp = { version = "0.27.0", default-features = false, features =
opentelemetry-semantic-conventions.workspace = true
opentelemetry_sdk.workspace = true
ordered-float = { version = "4.6.0", features = ["serde"] }
osm_to_railjson = { path = "./osm_to_railjson" }
paste.workspace = true
pathfinding = "4.13.0"
postgis_diesel.workspace = true
Expand Down
1 change: 1 addition & 0 deletions editoast/osm_to_railjson/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version.workspace = true
edition.workspace = true

[dependencies]
clap.workspace = true
editoast_schemas.workspace = true
geo-types = "0.7.14"
geos.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion editoast/osm_to_railjson/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Example for Germany:
2. Launch conversion (release build of editoast and conversion can be long):
```sh
cd ../../editoast
cargo run --release -- osm-to-railjson <path/to/germany-latest.osm.pbf> <path/to/germany_railjson.json>
cargo run --release -p osm_to_railjson -- <path/to/germany-latest.osm.pbf> <path/to/germany_railjson.json>
```
3. Load railjson (also possible through [a script](../../scripts/load-railjson-infra.sh) or OSRD's web interface):
```sh
Expand Down
17 changes: 17 additions & 0 deletions editoast/osm_to_railjson/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use clap::Parser;
use std::path::PathBuf;

#[derive(Parser)]
#[command(about, long_about = "Extracts a railjson from OpenStreetMap data")]
pub struct OsmToRailjsonArgs {
/// Input file in the OSM PBF format
pub osm_pbf_in: PathBuf,
/// Output file in Railjson format
pub railjson_out: PathBuf,
}

fn main() {
let args = OsmToRailjsonArgs::parse();
osm_to_railjson::osm_to_railjson(args.osm_pbf_in, args.railjson_out)
.expect("Could not convert osm to railjson");
}
11 changes: 0 additions & 11 deletions editoast/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ mod valkey_config;
use std::env;
use std::path::PathBuf;

use clap::Args;
use clap::Parser;
use clap::Subcommand;
use clap::ValueEnum;
Expand Down Expand Up @@ -77,7 +76,6 @@ pub enum Commands {
ElectricalProfiles(electrical_profiles_commands::ElectricalProfilesCommands),
ImportRollingStock(ImportRollingStockArgs),
ImportTowedRollingStock(ImportRollingStockArgs),
OsmToRailjson(OsmToRailjsonArgs),
#[command(about, long_about = "Prints the OpenApi of the service")]
Openapi,
#[command(subcommand, about, long_about = "Search engine related commands")]
Expand All @@ -102,15 +100,6 @@ pub enum Commands {
Healthcheck(CoreArgs),
}

#[derive(Args, Debug)]
#[command(about, long_about = "Extracts a railjson from OpenStreetMap data")]
pub struct OsmToRailjsonArgs {
/// Input file in the OSM PBF format
pub osm_pbf_in: PathBuf,
/// Output file in Railjson format
pub railjson_out: PathBuf,
}

/// Prints the OpenApi to stdout
pub fn print_openapi() {
let openapi = OpenApiRoot::build_openapi();
Expand Down
3 changes: 0 additions & 3 deletions editoast/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ async fn run() -> Result<(), Box<dyn Error + Send + Sync>> {
Commands::ImportTowedRollingStock(args) => {
import_towed_rolling_stock(args, db_pool.into()).await
}
Commands::OsmToRailjson(args) => {
osm_to_railjson::osm_to_railjson(args.osm_pbf_in, args.railjson_out)
}
Commands::Openapi => {
print_openapi();
Ok(())
Expand Down
Loading