-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathpath_properties.rs
103 lines (93 loc) · 3.54 KB
/
path_properties.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
use editoast_common::geometry::GeoJsonLineString;
use editoast_schemas::infra::OperationalPointExtensions;
use editoast_schemas::infra::OperationalPointPart;
use editoast_schemas::primitives::Identifier;
use serde::Deserialize;
use serde::Serialize;
use utoipa::ToSchema;
use super::pathfinding::TrackRange;
use crate::core::{AsCoreRequest, Json};
#[derive(Debug, Serialize)]
pub struct PathPropertiesRequest<'a> {
pub track_section_ranges: &'a Vec<TrackRange>,
pub infra: i64,
pub expected_version: String,
}
/// Properties along a path.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PathPropertiesResponse {
/// Slopes along the path
pub slopes: PropertyValuesF64,
/// Curves along the path
pub curves: PropertyValuesF64,
/// Electrification modes and neutral section along the path
pub electrifications: PropertyElectrificationValues,
/// Geometry of the path
pub geometry: GeoJsonLineString,
/// Operational points along the path
pub operational_points: Vec<OperationalPointOnPath>,
/// Zones along the path
pub zones: PropertyZoneValues,
}
/// Property f64 values along a path. Each value is associated to a range of the path.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct PropertyValuesF64 {
/// List of `n` boundaries of the ranges.
/// A boundary is a distance from the beginning of the path in mm.
boundaries: Vec<u64>,
/// List of `n+1` values associated to the ranges
values: Vec<f64>,
}
/// Electrification property along a path. Each value is associated to a range of the path.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct PropertyElectrificationValues {
/// List of `n` boundaries of the ranges.
/// A boundary is a distance from the beginning of the path in mm.
boundaries: Vec<u64>,
#[schema(inline)]
/// List of `n+1` values associated to the ranges
values: Vec<PropertyElectrificationValue>,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum PropertyElectrificationValue {
/// Electrified section with a given voltage
Electrification { voltage: String },
/// Neutral section with a lower pantograph instruction or just a dead section
NeutralSection { lower_pantograph: bool },
/// Non electrified section
NonElectrified,
}
/// Operational point along a path.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct OperationalPointOnPath {
/// Id of the operational point
#[schema(inline)]
id: Identifier,
/// The part along the path
part: OperationalPointPart,
/// Extensions associated to the operational point
#[serde(default)]
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.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct PropertyZoneValues {
/// List of `n` boundaries of the ranges.
/// A boundary is a distance from the beginning of the path in mm.
boundaries: Vec<u64>,
/// List of `n+1` values associated to the ranges
values: Vec<String>,
}
impl AsCoreRequest<Json<PathPropertiesResponse>> for PathPropertiesRequest<'_> {
const METHOD: reqwest::Method = reqwest::Method::POST;
const URL_PATH: &'static str = "/v2/path_properties";
fn infra_id(&self) -> Option<i64> {
Some(self.infra)
}
}