Skip to content

Commit

Permalink
editoast: update temporary speed limit import to use signals
Browse files Browse the repository at this point in the history
Previously, the temporary speed limits creation endpoint expected to
retrieve directional track ranges in the request body. Since it might
not be possible to get that information directly, update the
endpoint so that it retrieves the list of execution and resume signals
associated with the temporary speed limits and then do a graph traversal
on the infrastructure track sections to determine from the signals on
which the track ranges the temporary speed limits apply.

Add an infrastructure id parameter to the request form.

Signed-off-by: Loup Federico <[email protected]>
  • Loading branch information
Sh099078 committed Oct 24, 2024
1 parent 2449281 commit f97338e
Show file tree
Hide file tree
Showing 4 changed files with 1,114 additions and 82 deletions.
14 changes: 9 additions & 5 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2336,8 +2336,12 @@ paths:
type: object
required:
- speed_limit_group_name
- infra_id
- speed_limits
properties:
infra_id:
type: integer
format: int64
speed_limit_group_name:
type: string
speed_limits:
Expand All @@ -2347,7 +2351,7 @@ paths:
required:
- start_date_time
- end_date_time
- track_ranges
- signals
- speed_limit
- obj_id
properties:
Expand All @@ -2356,16 +2360,16 @@ paths:
format: date-time
obj_id:
type: string
signals:
type: array
items:
$ref: '#/components/schemas/Sign'
speed_limit:
type: number
format: double
start_date_time:
type: string
format: date-time
track_ranges:
type: array
items:
$ref: '#/components/schemas/DirectionalTrackRange'
required: true
responses:
'201':
Expand Down
11 changes: 11 additions & 0 deletions editoast/src/infra_cache/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ impl<'a> Graph<'a> {
.map(|groups| groups.keys().cloned().collect())
.unwrap_or_default()
}

/// Given an endpoint return all its neighbours indiscriminately
/// of their group.
pub fn get_all_neighbours(&'a self, track_endpoint: &TrackEndpoint) -> Vec<&'a TrackEndpoint> {
let groups = self.links.get(track_endpoint);
if let Some(groups) = groups {
groups.values().copied().collect::<Vec<_>>()
} else {
Vec::new()
}
}
}

#[cfg(test)]
Expand Down
Loading

0 comments on commit f97338e

Please sign in to comment.