Skip to content

Commit deb4f59

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

File tree

11 files changed

+47
-3
lines changed

11 files changed

+47
-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

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@ 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,
22+
List<RJSOperationalPointPart> parts,
23+
@Nullable RJSOperationalPointExtensions extensions,
24+
@Nullable String weight) {
1925
this.id = id;
2026
this.parts = parts;
2127
this.extensions = extensions;
28+
this.weight = weight;
2229
}
2330

2431
@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/__tests__/upsertMapWaypointsInOperationalPoints.spec.ts

+13
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
3838
},
3939
},
4040
position: 0,
41+
weight: null,
4142
},
4243
{
4344
id: '2',
@@ -52,6 +53,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
5253
position: 7746000,
5354
},
5455
position: 9246000,
56+
weight: null,
5557
},
5658
{
5759
id: 'Mid_West_station',
@@ -66,6 +68,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
6668
},
6769
},
6870
position: 12050000,
71+
weight: null,
6972
},
7073
{
7174
id: 'Mid_East_station',
@@ -80,6 +83,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
8083
},
8184
},
8285
position: 26500000,
86+
weight: null,
8387
},
8488
]);
8589
});
@@ -108,6 +112,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
108112
position: 6481000,
109113
},
110114
position: 0,
115+
weight: null,
111116
},
112117
{
113118
id: 'Mid_West_station',
@@ -122,6 +127,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
122127
},
123128
},
124129
position: 4069000,
130+
weight: null,
125131
},
126132
{
127133
id: '2',
@@ -136,6 +142,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
136142
position: 679000,
137143
},
138144
position: 4198000,
145+
weight: null,
139146
},
140147
{
141148
id: '3',
@@ -150,6 +157,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
150157
position: 883000,
151158
},
152159
position: 4402000,
160+
weight: null,
153161
},
154162
]);
155163
});
@@ -178,6 +186,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
178186
position: 6481000,
179187
},
180188
position: 0,
189+
weight: null,
181190
},
182191
{
183192
id: '2',
@@ -192,6 +201,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
192201
position: 4733000,
193202
},
194203
position: 1748000,
204+
weight: null,
195205
},
196206
]);
197207
});
@@ -220,6 +230,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
220230
},
221231
},
222232
position: 0,
233+
weight: null,
223234
},
224235
{
225236
id: 'Mid_West_station',
@@ -234,6 +245,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
234245
},
235246
},
236247
position: 12050000,
248+
weight: null,
237249
},
238250
{
239251
id: 'Mid_East_station',
@@ -248,6 +260,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
248260
},
249261
},
250262
position: 26500000,
263+
weight: null,
251264
},
252265
]);
253266
});

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)