Skip to content

Commit f42f9ab

Browse files
committed
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 <sim.gaubert.sg@gmail.com>
1 parent 564382a commit f42f9ab

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

editoast/osm_to_railjson/src/utils.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,25 @@ fn identifier(
545545
None
546546
}
547547
})
548-
.unwrap_or_default();
548+
.unwrap_or_else(|| {
549+
// Generate a fake UIC with code 11
550+
static mut UIC_COUNTER: u32 = 0;
551+
unsafe {
552+
UIC_COUNTER += 1;
553+
11_00000 + UIC_COUNTER
554+
}
555+
});
549556

550557
tags.get("name")
551558
.map(|name| OperationalPointIdentifierExtension {
552559
name: name.as_str().into(),
553560
uic,
554561
})
562+
.or(Some(OperationalPointIdentifierExtension {
563+
// Generate a fake name from the UIC
564+
name: format!("op_{}", uic).into(),
565+
uic,
566+
}))
555567
}
556568

557569
#[cfg(test)]

0 commit comments

Comments
 (0)