Skip to content

Commit

Permalink
core: editoast: add weight field to operational points path property
Browse files Browse the repository at this point in the history
Signed-off-by: Youness CHRIFI ALAOUI <[email protected]>
  • Loading branch information
younesschrifi committed Jan 9, 2025
1 parent 384dcea commit deb4f59
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,10 @@ fun parseRJSInfra(rjsInfra: RJSInfra): RawInfra {
props["chLongLabel"] = sncf.chLongLabel
props["trigram"] = sncf.trigram
}
val weight = operationalPoint.weight
if (weight != null) {
props["weight"] = weight
}
if (opPart.extensions?.sncf != null) props["kp"] = opPart.extensions!!.sncf!!.kp
val partId =
builder.operationalPointPart(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@ public class RJSOperationalPoint implements Identified {
@Nullable
public RJSOperationalPointExtensions extensions;

@Nullable
public String weight;

public RJSOperationalPoint(
String id, List<RJSOperationalPointPart> parts, @Nullable RJSOperationalPointExtensions extensions) {
String id,
List<RJSOperationalPointPart> parts,
@Nullable RJSOperationalPointExtensions extensions,
@Nullable String weight) {
this.id = id;
this.parts = parts;
this.extensions = extensions;
this.weight = weight;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ data class OperationalPointResponse(
val id: String,
val part: OperationalPointPartResponse,
val extensions: OperationalPointExtensions?,
val position: Offset<Path>
val position: Offset<Path>,
val weight: Long?
)

data class OperationalPointPartResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ private fun makeOperationalPoints(
val opExtensions =
if (opSncfExtension == null && opIdExtension == null) null
else OperationalPointExtensions(opSncfExtension, opIdExtension)
val weight = if (opPartProps["weight"] == null) null else opPartProps["weight"]!!.toLong()
val opResult =
OperationalPointResponse(operationalPointId, opPartResult, opExtensions, offset)
OperationalPointResponse(operationalPointId, opPartResult, opExtensions, offset, weight)
res.add(opResult)
}
return res
Expand Down
7 changes: 7 additions & 0 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8010,6 +8010,7 @@ components:
- id
- part
- position
- weight
properties:
extensions:
$ref: '#/components/schemas/OperationalPointExtensions'
Expand All @@ -8024,6 +8025,12 @@ components:
format: int64
description: Distance from the beginning of the path in mm
minimum: 0
weight:
type: integer
format: int32
description: Importance of the operational point
nullable: true
minimum: 0
description: Operational points along the path
nullable: true
slopes:
Expand Down
3 changes: 3 additions & 0 deletions editoast/src/core/path_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ pub struct OperationalPointOnPath {
extensions: OperationalPointExtensions,
/// Distance from the beginning of the path in mm
position: u64,
/// Importance of the operational point
#[schema(required)]
weight: Option<u8>,
}

/// Zones along a path. Each value is associated to a range of the path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ export const sampleWithMultipleOperationalPoints: NonNullable<
},
},
position: 0,
weight: null,
},
{
id: 'Mid_West_station',
Expand All @@ -625,6 +626,7 @@ export const sampleWithMultipleOperationalPoints: NonNullable<
},
},
position: 12050000,
weight: null,
},
{
id: 'Mid_East_station',
Expand All @@ -639,6 +641,7 @@ export const sampleWithMultipleOperationalPoints: NonNullable<
},
},
position: 26500000,
weight: null,
},
];

Expand Down Expand Up @@ -687,5 +690,6 @@ export const sampleWithOneOperationalPoint: OperationalPoint[] = [
},
},
position: 4069000,
weight: null,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
},
},
position: 0,
weight: null,
},
{
id: '2',
Expand All @@ -52,6 +53,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
position: 7746000,
},
position: 9246000,
weight: null,
},
{
id: 'Mid_West_station',
Expand All @@ -66,6 +68,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
},
},
position: 12050000,
weight: null,
},
{
id: 'Mid_East_station',
Expand All @@ -80,6 +83,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
},
},
position: 26500000,
weight: null,
},
]);
});
Expand Down Expand Up @@ -108,6 +112,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
position: 6481000,
},
position: 0,
weight: null,
},
{
id: 'Mid_West_station',
Expand All @@ -122,6 +127,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
},
},
position: 4069000,
weight: null,
},
{
id: '2',
Expand All @@ -136,6 +142,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
position: 679000,
},
position: 4198000,
weight: null,
},
{
id: '3',
Expand All @@ -150,6 +157,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
position: 883000,
},
position: 4402000,
weight: null,
},
]);
});
Expand Down Expand Up @@ -178,6 +186,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
position: 6481000,
},
position: 0,
weight: null,
},
{
id: '2',
Expand All @@ -192,6 +201,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
position: 4733000,
},
position: 1748000,
weight: null,
},
]);
});
Expand Down Expand Up @@ -220,6 +230,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
},
},
position: 0,
weight: null,
},
{
id: 'Mid_West_station',
Expand All @@ -234,6 +245,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
},
},
position: 12050000,
weight: null,
},
{
id: 'Mid_East_station',
Expand All @@ -248,6 +260,7 @@ describe('upsertMapWaypointsInOperationalPoints', () => {
},
},
position: 26500000,
weight: null,
},
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const upsertMapWaypointsInOperationalPoints = (
},
part: { track: step.track, position: step.offset },
position: positionOnPath,
weight: null,
};

waypointCounter += 1;
Expand Down
2 changes: 2 additions & 0 deletions front/src/common/api/generatedEditoastApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2567,6 +2567,8 @@ export type PathProperties = {
part: OperationalPointPart;
/** Distance from the beginning of the path in mm */
position: number;
/** Importance of the operational point */
weight: number | null;
}[]
| null;
slopes?: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('formatStops', () => {
position: 0,
track: 'track',
},
weight: null,
},
];
const expected = [{ position: { start: 0 }, value: 'name ch' }];
Expand Down

0 comments on commit deb4f59

Please sign in to comment.