Skip to content

Commit 0d212f4

Browse files
committed
core: editoast: add weight field to operational points path property
Signed-off-by: Youness CHRIFI ALAOUI <[email protected]>
1 parent cae4d30 commit 0d212f4

File tree

10 files changed

+31
-3
lines changed

10 files changed

+31
-3
lines changed

core/kt-osrd-rjs-parser/src/main/kotlin/fr/sncf/osrd/RawInfraRJSParser.kt

+4
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,10 @@ fun parseRJSInfra(rjsInfra: RJSInfra): RawInfra {
797797
props["chLongLabel"] = sncf.chLongLabel
798798
props["trigram"] = sncf.trigram
799799
}
800+
val weight = operationalPoint.weight
801+
if (weight != null) {
802+
props["weight"] = weight
803+
}
800804
if (opPart.extensions?.sncf != null) props["kp"] = opPart.extensions!!.sncf!!.kp
801805
val partId =
802806
builder.operationalPointPart(

core/osrd-railjson/src/main/java/fr/sncf/osrd/railjson/schema/infra/RJSOperationalPoint.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ public class RJSOperationalPoint implements Identified {
1414
@Nullable
1515
public RJSOperationalPointExtensions extensions;
1616

17+
@Nullable
18+
public String weight;
19+
1720
public RJSOperationalPoint(
18-
String id, List<RJSOperationalPointPart> parts, @Nullable RJSOperationalPointExtensions extensions) {
21+
String id, List<RJSOperationalPointPart> parts, @Nullable RJSOperationalPointExtensions extensions, @Nullable String weight) {
1922
this.id = id;
2023
this.parts = parts;
2124
this.extensions = extensions;
25+
this.weight = weight;
2226
}
2327

2428
@Override

core/src/main/kotlin/fr/sncf/osrd/api/api_v2/path_properties/PathPropResponse.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ data class OperationalPointResponse(
3232
val id: String,
3333
val part: OperationalPointPartResponse,
3434
val extensions: OperationalPointExtensions?,
35-
val position: Offset<Path>
35+
val position: Offset<Path>,
36+
val weight: Long?
3637
)
3738

3839
data class OperationalPointPartResponse(

core/src/main/kotlin/fr/sncf/osrd/api/api_v2/path_properties/PathPropResponseConverter.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ private fun makeOperationalPoints(
101101
val opExtensions =
102102
if (opSncfExtension == null && opIdExtension == null) null
103103
else OperationalPointExtensions(opSncfExtension, opIdExtension)
104+
val weight = if (opPartProps["weight"] == null) null else opPartProps["weight"]!!.toLong()
104105
val opResult =
105-
OperationalPointResponse(operationalPointId, opPartResult, opExtensions, offset)
106+
OperationalPointResponse(operationalPointId, opPartResult, opExtensions, offset, weight)
106107
res.add(opResult)
107108
}
108109
return res

editoast/openapi.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -8010,6 +8010,7 @@ components:
80108010
- id
80118011
- part
80128012
- position
8013+
- weight
80138014
properties:
80148015
extensions:
80158016
$ref: '#/components/schemas/OperationalPointExtensions'
@@ -8024,6 +8025,12 @@ components:
80248025
format: int64
80258026
description: Distance from the beginning of the path in mm
80268027
minimum: 0
8028+
weight:
8029+
type: integer
8030+
format: int32
8031+
description: Importance of the operational point
8032+
nullable: true
8033+
minimum: 0
80278034
description: Operational points along the path
80288035
nullable: true
80298036
slopes:

editoast/src/core/path_properties.rs

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ pub struct OperationalPointOnPath {
7878
extensions: OperationalPointExtensions,
7979
/// Distance from the beginning of the path in mm
8080
position: u64,
81+
/// Importance of the operational point
82+
#[schema(required)]
83+
weight: Option<u8>,
8184
}
8285

8386
/// Zones along a path. Each value is associated to a range of the path.

front/src/applications/operationalStudies/__tests__/sampleData.ts

+4
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ export const sampleWithMultipleOperationalPoints: NonNullable<
611611
},
612612
},
613613
position: 0,
614+
weight: null,
614615
},
615616
{
616617
id: 'Mid_West_station',
@@ -625,6 +626,7 @@ export const sampleWithMultipleOperationalPoints: NonNullable<
625626
},
626627
},
627628
position: 12050000,
629+
weight: null,
628630
},
629631
{
630632
id: 'Mid_East_station',
@@ -639,6 +641,7 @@ export const sampleWithMultipleOperationalPoints: NonNullable<
639641
},
640642
},
641643
position: 26500000,
644+
weight: null,
642645
},
643646
];
644647

@@ -687,5 +690,6 @@ export const sampleWithOneOperationalPoint: OperationalPoint[] = [
687690
},
688691
},
689692
position: 4069000,
693+
weight: null,
690694
},
691695
];

front/src/applications/operationalStudies/helpers/upsertMapWaypointsInOperationalPoints.ts

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const upsertMapWaypointsInOperationalPoints = (
3535
},
3636
part: { track: step.track, position: step.offset },
3737
position: positionOnPath,
38+
weight: null,
3839
};
3940

4041
waypointCounter += 1;

front/src/common/api/generatedEditoastApi.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2567,6 +2567,8 @@ export type PathProperties = {
25672567
part: OperationalPointPart;
25682568
/** Distance from the beginning of the path in mm */
25692569
position: number;
2570+
/** Importance of the operational point */
2571+
weight: number | null;
25702572
}[]
25712573
| null;
25722574
slopes?: {

front/src/modules/simulationResult/components/SpeedSpaceChart/__tests__/helpers.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe('formatStops', () => {
4848
position: 0,
4949
track: 'track',
5050
},
51+
weight: null,
5152
},
5253
];
5354
const expected = [{ position: { start: 0 }, value: 'name ch' }];

0 commit comments

Comments
 (0)