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 <youness.chrifi@gmail.com>
  • Loading branch information
younesschrifi authored and Akctarus committed Jan 9, 2025
1 parent ed6fcf4 commit e0b99bc
Show file tree
Hide file tree
Showing 7 changed files with 25 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,15 @@ 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
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

0 comments on commit e0b99bc

Please sign in to comment.