From 583ec6c57da07dc77188e15f613a3858a91a7beb Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 13 Mar 2026 16:47:14 +0100 Subject: [PATCH 1/2] osm_to_railjson: create fake UIC and name for op Generate a fake UIC code for operational points that don't have one. We use the UIC code 11 which is not used anywhere. And we generate a fake name from the UIC code. Signed-off-by: Simon --- editoast/osm_to_railjson/src/utils.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/editoast/osm_to_railjson/src/utils.rs b/editoast/osm_to_railjson/src/utils.rs index db480d86f2d..6a24ec85fdb 100644 --- a/editoast/osm_to_railjson/src/utils.rs +++ b/editoast/osm_to_railjson/src/utils.rs @@ -545,13 +545,25 @@ fn identifier( None } }) - .unwrap_or_default(); + .unwrap_or_else(|| { + // Generate a fake UIC with code 11 + static mut UIC_COUNTER: u32 = 0; + unsafe { + UIC_COUNTER += 1; + 11_00000 + UIC_COUNTER + } + }); tags.get("name") .map(|name| OperationalPointIdentifierExtension { name: name.as_str().into(), uic, }) + .or(Some(OperationalPointIdentifierExtension { + // Generate a fake name from the UIC + name: format!("op_{}", uic).into(), + uic, + })) } #[cfg(test)] From 3b88ad27ce9720ef0fd971021df2ed99bde61037 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 16 Mar 2026 15:44:02 +0100 Subject: [PATCH 2/2] fixup! osm_to_railjson: create fake UIC and name for op --- editoast/osm_to_railjson/src/utils.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/editoast/osm_to_railjson/src/utils.rs b/editoast/osm_to_railjson/src/utils.rs index 6a24ec85fdb..38dd8e73112 100644 --- a/editoast/osm_to_railjson/src/utils.rs +++ b/editoast/osm_to_railjson/src/utils.rs @@ -29,6 +29,8 @@ use schemas::primitives::Identifier; use schemas::primitives::NonBlankString; use std::collections::HashMap; use std::str::FromStr; +use std::sync::atomic::AtomicU32; +use std::sync::atomic::Ordering; use tracing::error; use tracing::warn; @@ -533,6 +535,10 @@ pub fn operational_points( .collect() } +// TODO: the generation of fake UIC and name is here as a temporary solution. +// The front crashes when this function return None. +// This function will probably be changed when the data model will change. +// The necessity of a fake UIC and name should be re-evaluated at that time. fn identifier( tags: &osm4routing::osmpbfreader::Tags, ) -> Option { @@ -547,11 +553,8 @@ fn identifier( }) .unwrap_or_else(|| { // Generate a fake UIC with code 11 - static mut UIC_COUNTER: u32 = 0; - unsafe { - UIC_COUNTER += 1; - 11_00000 + UIC_COUNTER - } + static UIC_COUNTER: AtomicU32 = AtomicU32::new(0); + 11_00000 + UIC_COUNTER.fetch_add(1, Ordering::Relaxed) }); tags.get("name")