Skip to content

Commit c2a5fa9

Browse files
editoast: add path projection endpoint
Co-Authored-by: Florian Amsallem <[email protected]>
1 parent ad800d4 commit c2a5fa9

File tree

8 files changed

+1108
-310
lines changed

8 files changed

+1108
-310
lines changed

editoast/editoast_schemas/src/infra/track_offset.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,21 @@ editoast_common::schemas! {
77
TrackOffset,
88
}
99

10-
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, Hash)]
10+
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, ToSchema, Hash)]
1111
pub struct TrackOffset {
1212
/// Track section identifier
1313
#[schema(inline)]
1414
pub track: Identifier,
1515
/// Offset in mm
1616
pub offset: u64,
1717
}
18+
19+
impl TrackOffset {
20+
/// Create a new track location.
21+
pub fn new<T: AsRef<str>>(track: T, offset: u64) -> Self {
22+
Self {
23+
track: track.as_ref().into(),
24+
offset,
25+
}
26+
}
27+
}

editoast/openapi.yaml

+217-25
Original file line numberDiff line numberDiff line change
@@ -4958,29 +4958,123 @@ components:
49584958
- $ref: '#/components/schemas/Tags'
49594959
nullable: true
49604960
type: object
4961-
ProjectPathResult:
4962-
description: Project path output is described by time-space points and blocks
4961+
ProjectPathInput:
4962+
description: Project path input is described by a list of routes and a list of track range
49634963
properties:
4964-
blocks:
4965-
items:
4966-
$ref: '#/components/schemas/SignalUpdate'
4967-
type: array
4968-
positions:
4964+
routes:
4965+
description: List of route ids
49694966
items:
4970-
format: int64
4971-
minimum: 0
4972-
type: integer
4967+
maxLength: 255
4968+
minLength: 1
4969+
type: string
4970+
minItems: 1
49734971
type: array
4974-
times:
4972+
track_section_ranges:
4973+
description: List of track ranges
49754974
items:
4976-
format: double
4977-
type: number
4975+
$ref: '#/components/schemas/TrackRange'
4976+
minItems: 1
49784977
type: array
49794978
required:
4980-
- positions
4981-
- times
4982-
- blocks
4979+
- routes
4980+
- track_section_ranges
49834981
type: object
4982+
ProjectPathTrainResult:
4983+
allOf:
4984+
- description: Project path output is described by time-space points and blocks
4985+
properties:
4986+
signal_updates:
4987+
description: List of signal updates along the path
4988+
items:
4989+
properties:
4990+
aspect_label:
4991+
description: The labels of the new aspect
4992+
type: string
4993+
blinking:
4994+
description: Whether the signal is blinking
4995+
type: boolean
4996+
color:
4997+
description: |-
4998+
The color of the aspect
4999+
(Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue)
5000+
format: int32
5001+
type: integer
5002+
position_end:
5003+
description: The route ends at this position in mm on the train path
5004+
format: int64
5005+
minimum: 0
5006+
type: integer
5007+
position_start:
5008+
description: The route starts at this position in mm on the train path
5009+
format: int64
5010+
minimum: 0
5011+
type: integer
5012+
signal_id:
5013+
description: The id of the updated signal
5014+
type: string
5015+
time_end:
5016+
description: The aspects stop being displayed at this time (number of seconds since `departure_time`)
5017+
format: int64
5018+
minimum: 0
5019+
type: integer
5020+
time_start:
5021+
description: The aspects start being displayed at this time (number of mseconds since `departure_time`)
5022+
format: int64
5023+
minimum: 0
5024+
type: integer
5025+
required:
5026+
- signal_id
5027+
- time_start
5028+
- time_end
5029+
- position_start
5030+
- position_end
5031+
- color
5032+
- blinking
5033+
- aspect_label
5034+
type: object
5035+
type: array
5036+
space_time_curves:
5037+
description: List of space-time curves sections along the path
5038+
items:
5039+
properties:
5040+
positions:
5041+
items:
5042+
format: int64
5043+
minimum: 0
5044+
type: integer
5045+
minItems: 2
5046+
type: array
5047+
times:
5048+
items:
5049+
format: int64
5050+
minimum: 0
5051+
type: integer
5052+
minItems: 2
5053+
type: array
5054+
required:
5055+
- positions
5056+
- times
5057+
type: object
5058+
type: array
5059+
required:
5060+
- space_time_curves
5061+
- signal_updates
5062+
type: object
5063+
- properties:
5064+
departure_time:
5065+
description: Departure time of the train
5066+
format: date-time
5067+
type: string
5068+
rolling_stock_length:
5069+
description: Rolling stock length in mm
5070+
format: int64
5071+
minimum: 0
5072+
type: integer
5073+
required:
5074+
- departure_time
5075+
- rolling_stock_length
5076+
type: object
5077+
description: Project path output is described by time-space points and blocks
49845078
ProjectWithStudies:
49855079
allOf:
49865080
- $ref: '#/components/schemas/Project'
@@ -6568,9 +6662,49 @@ components:
65686662
base:
65696663
$ref: '#/components/schemas/ReportTrainV2'
65706664
final_output:
6571-
$ref: '#/components/schemas/CompleteReportTrain'
6665+
allOf:
6666+
- $ref: '#/components/schemas/ReportTrainV2'
6667+
- properties:
6668+
routing_requirements:
6669+
items:
6670+
$ref: '#/components/schemas/RoutingRequirement'
6671+
type: array
6672+
signal_sightings:
6673+
items:
6674+
$ref: '#/components/schemas/SignalSighting'
6675+
type: array
6676+
spacing_requirements:
6677+
items:
6678+
$ref: '#/components/schemas/SpacingRequirement'
6679+
type: array
6680+
zone_updates:
6681+
items:
6682+
$ref: '#/components/schemas/ZoneUpdate'
6683+
type: array
6684+
required:
6685+
- signal_sightings
6686+
- zone_updates
6687+
- spacing_requirements
6688+
- routing_requirements
6689+
type: object
65726690
mrsp:
6573-
$ref: '#/components/schemas/Mrsp'
6691+
description: A MRSP computation result (Most Restrictive Speed Profile)
6692+
properties:
6693+
positions:
6694+
items:
6695+
format: int64
6696+
minimum: 0
6697+
type: integer
6698+
type: array
6699+
speeds:
6700+
items:
6701+
format: double
6702+
type: number
6703+
type: array
6704+
required:
6705+
- positions
6706+
- speeds
6707+
type: object
65746708
power_restrictions:
65756709
items:
65766710
properties:
@@ -6621,7 +6755,15 @@ components:
66216755
- pathfinding_result
66226756
- status
66236757
type: object
6624-
SimulationSummaryResultResponse:
6758+
- properties:
6759+
status:
6760+
enum:
6761+
- simulation_failed
6762+
type: string
6763+
required:
6764+
- status
6765+
type: object
6766+
SimulationSummaryResult:
66256767
oneOf:
66266768
- properties:
66276769
Success:
@@ -6649,7 +6791,7 @@ components:
66496791
- PathfindingFailed
66506792
type: string
66516793
- enum:
6652-
- RunningTimeFailed
6794+
- SimulationFailed
66536795
type: string
66546796
SingleSimulationRequest:
66556797
allOf:
@@ -7225,14 +7367,19 @@ components:
72257367
- offset
72267368
type: object
72277369
TrackRange:
7370+
description: |-
7371+
An oriented range on a track section.
7372+
`begin` is always less than `end`.
72287373
properties:
72297374
begin:
7375+
description: The beginning of the range in mm.
72307376
format: int64
72317377
minimum: 0
72327378
type: integer
72337379
direction:
72347380
$ref: '#/components/schemas/Direction'
72357381
end:
7382+
description: The end of the range in mm.
72367383
format: int64
72377384
minimum: 0
72387385
type: integer
@@ -10856,14 +11003,42 @@ paths:
1085611003
post:
1085711004
description: |-
1085811005
Projects the space time curves and paths of a number of train schedules onto a given path
10859-
Params are the infra_id and a list of train_ids
11006+
11007+
- Returns 404 if the infra or any of the train schedules are not found
11008+
- Returns 200 with a hashmap of train_id to ProjectPathTrainResult
11009+
11010+
Train schedules that are invalid (pathfinding or simulation failed) are not included in the result
11011+
parameters:
11012+
- description: The infra id
11013+
in: query
11014+
name: infra
11015+
required: true
11016+
schema:
11017+
format: int64
11018+
type: integer
11019+
- description: Ids of train schedule
11020+
in: query
11021+
name: ids
11022+
required: true
11023+
schema:
11024+
items:
11025+
format: int64
11026+
type: integer
11027+
type: array
11028+
requestBody:
11029+
content:
11030+
application/json:
11031+
schema:
11032+
$ref: '#/components/schemas/ProjectPathInput'
11033+
description: ''
11034+
required: true
1086011035
responses:
1086111036
'200':
1086211037
content:
1086311038
application/json:
1086411039
schema:
1086511040
additionalProperties:
10866-
$ref: '#/components/schemas/ProjectPathResult'
11041+
$ref: '#/components/schemas/ProjectPathTrainResult'
1086711042
type: object
1086811043
description: Project Path Output
1086911044
summary: Projects the space time curves and paths of a number of train schedules onto a given path
@@ -10874,21 +11049,38 @@ paths:
1087411049
description: |-
1087511050
Retrieve simulation information for a given train list.
1087611051
Useful for finding out whether pathfinding/simulation was successful.
11052+
parameters:
11053+
- description: The infra id
11054+
in: query
11055+
name: infra
11056+
required: true
11057+
schema:
11058+
format: int64
11059+
type: integer
11060+
- description: Ids of train schedule
11061+
in: query
11062+
name: ids
11063+
required: true
11064+
schema:
11065+
items:
11066+
format: int64
11067+
type: integer
11068+
type: array
1087711069
responses:
1087811070
'200':
1087911071
content:
1088011072
application/json:
1088111073
schema:
1088211074
additionalProperties:
10883-
$ref: '#/components/schemas/SimulationSummaryResultResponse'
11075+
$ref: '#/components/schemas/SimulationSummaryResult'
1088411076
type: object
1088511077
description: Project Path Output
1088611078
summary: Retrieve simulation information for a given train list.
1088711079
tags:
1088811080
- train_schedulev2
1088911081
/v2/train_schedule/{id}/:
1089011082
get:
10891-
description: Return a specific timetable with its associated schedules
11083+
description: Return a specific train schedule
1089211084
parameters:
1089311085
- description: A train schedule ID
1089411086
in: path
@@ -10904,7 +11096,7 @@ paths:
1090411096
schema:
1090511097
$ref: '#/components/schemas/TrainScheduleResult'
1090611098
description: The train schedule
10907-
summary: Return a specific timetable with its associated schedules
11099+
summary: Return a specific train schedule
1090811100
tags:
1090911101
- train_schedulev2
1091011102
put:

editoast/src/core/v2/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pub mod path_properties;
22
pub mod pathfinding;
3+
pub mod signal_updates;
34
pub mod simulation;

0 commit comments

Comments
 (0)