Skip to content

Commit 7c6c5fb

Browse files
committed
fixup! editoast: pathfinding: add CI/CH codes to pathfinding response
1 parent 5ef96c5 commit 7c6c5fb

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

editoast/src/views/pathfinding/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,13 @@ impl Pathfinding {
382382
.id
383383
.as_ref()
384384
.map(|op_id| op_map.get(op_id).expect("unexpected OP id"));
385-
op.and_then(|op| op.extensions.identifier.as_ref())
386-
.map(|ident| {
387-
op_name = Some(ident.name.as_ref().to_owned());
388-
op_uic = Some(ident.uic);
389-
});
390-
op.and_then(|op| op.extensions.sncf.as_ref())
391-
.map(|sncf| op_ch = Some(sncf.ch.to_owned()));
385+
if let Some(ident) = op.and_then(|op| op.extensions.identifier.as_ref()) {
386+
op_name = Some(ident.name.as_ref().to_owned());
387+
op_uic = Some(ident.uic);
388+
}
389+
if let Some(sncf) = op.and_then(|op| op.extensions.sncf.as_ref()) {
390+
op_ch = Some(sncf.ch.to_owned())
391+
}
392392
let track = track_map
393393
.get(&waypoint.location.track_section.0)
394394
.expect("unexpected track id");

tests/tests/test_pathfinding.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"curves": [{"radius": 0.0, "position": 0.0}, {"radius": 0.0, "position": 45549.5653000392}],
5353
"steps": [
5454
{
55-
"ch": None,
5655
"id": None,
5756
"name": None,
5857
"location": {"track_section": "TA2", "offset": 837.033949007362},
@@ -61,10 +60,10 @@
6160
"suggestion": False,
6261
"geo": {"coordinates": [-0.387122554630656, 49.49979999999999], "type": "Point"},
6362
"sch": {"coordinates": [-0.387122554630656, 49.49979999999999], "type": "Point"},
63+
"ch": None,
6464
"uic": None,
6565
},
6666
{
67-
"ch": None,
6867
"id": "Mid_West_station",
6968
"name": "Mid_West_station",
7069
"location": {"track_section": "TC2", "offset": 450.0},
@@ -73,10 +72,10 @@
7372
"suggestion": True,
7473
"geo": {"coordinates": [-0.30369999999999997, 49.4999], "type": "Point"},
7574
"sch": {"coordinates": [-0.30369999999999997, 49.4999], "type": "Point"},
76-
"uic": None,
75+
"ch": "aa",
76+
"uic": 0,
7777
},
7878
{
79-
"ch": None,
8079
"id": "Mid_East_station",
8180
"name": "Mid_East_station",
8281
"location": {"track_section": "TD1", "offset": 14000.0},
@@ -85,10 +84,10 @@
8584
"suggestion": True,
8685
"geo": {"coordinates": [-0.22656, 49.4999], "type": "Point"},
8786
"sch": {"coordinates": [-0.22656, 49.4999], "type": "Point"},
88-
"uic": None,
87+
"ch": "aa",
88+
"uic": 0,
8989
},
9090
{
91-
"ch": None,
9291
"id": None,
9392
"name": None,
9493
"location": {"track_section": "TH1", "offset": 4386.599249046556},
@@ -97,6 +96,7 @@
9796
"suggestion": False,
9897
"geo": {"coordinates": [-0.095104854807785, 49.484], "type": "Point"},
9998
"sch": {"coordinates": [-0.095104854807785, 49.484], "type": "Point"},
99+
"ch": None,
100100
"uic": None,
101101
},
102102
],

0 commit comments

Comments
 (0)