osm_to_railjson: Create fake UIC and name for op#15744
osm_to_railjson: Create fake UIC and name for op#15744SaumonDesMers wants to merge 2 commits intodevfrom
Conversation
f42f9ab to
2c9dcc0
Compare
emersion
left a comment
There was a problem hiding this comment.
I would prefer to fix OSRD to not require UIC, instead of faking one.
| static mut UIC_COUNTER: u32 = 0; | ||
| unsafe { | ||
| UIC_COUNTER += 1; | ||
| 11_00000 + UIC_COUNTER | ||
| } |
There was a problem hiding this comment.
No. You cannot use unsafe like this (in a multithreaded context, this would be a data race. It's uncertain we would notice if the context becomes multithreaded).
static UIC_COUNTER: AtomicU32 = AtomicU32::new(0);
11_00000 + UIC_COUNTER.fetch_add(1, Ordering::Relaxed);
flomonster
left a comment
There was a problem hiding this comment.
Why do we need to generate an UIC code when not found?
|
Currently, the Identifier extension is mandatory in the front (i.e. it crashes when it's not present). And to my understanding, there is no way to identify an op, other than the Identifier. So without a serious rework of the front and/or the data model (which I believe will come), generating a fake Identifier is the only easy way to fix this. When generating an Identifier, we have to generate a name and an UIC code (they are not optional). We could maybe use an empty string and an UIC code of 0, but I'm sure how other part of the code base will react to non-unique Identifier. All of this is a temporary fix, and I will add comments in this sens. |
|
I didn't recall that the In the meantime, I don't see a better way to go forward. Please add a TODO explaining that the fake UIC should be dropped. |
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>
2c9dcc0 to
3b88ad2
Compare
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.
close #15692