1
- //! A linear reference system ([Lrs]) is the combination of multiple [LrmScale] and Traversals
1
+ //! A Linear Reference System ([` Lrs` ]) is the combination of multiple [` LrmScale` ] and [`Traversal`]s.
2
2
//!
3
- //! For instance a highway could have a LRS, with an LrmScale for every direction
3
+ //! For instance a highway could have a LRS, with an [` LrmScale`] for every direction.
4
4
//!
5
- //! A traversal is a chain of [ Segment] that build a [Curve]. A segment could be the road between two intersections
5
+ //! A traversal is a chain of ` Segment` that builds a [` Curve` ]. A segment could be the road between two intersections.
6
6
7
7
use std:: cmp:: Ordering ;
8
8
@@ -16,14 +16,14 @@ use crate::lrm_scale::{
16
16
use crate :: lrs_generated;
17
17
use geo:: { coord, point, Point } ;
18
18
19
- /// Handle to identify a [LrmScale] within a specific [Lrs]
19
+ /// Used as handle to identify a [` LrmScale` ] within a specific [` Lrs`].
20
20
#[ derive( Copy , Clone , Debug , Eq , Hash , PartialEq ) ]
21
21
pub struct LrmHandle ( usize ) ;
22
- /// Handle to identify a Traversal within a specific [Lrs]
22
+ /// Used as handle to identify a [` Traversal`] within a specific [` Lrs`].
23
23
#[ derive( Copy , Clone , Debug , Eq , Hash , PartialEq ) ]
24
24
pub struct TraversalHandle ( usize ) ;
25
25
26
- /// Todo create struct LRM {scale, traversals, reference_traversal}
26
+ /// TODO : create struct LRM {scale, traversals, reference_traversal}
27
27
28
28
struct Lrm {
29
29
scale : LrmScale ,
@@ -37,55 +37,56 @@ struct Traversal<CurveImpl: Curve> {
37
37
lrms : Vec < LrmHandle > ,
38
38
}
39
39
40
- /// The Linear Reference System. It must be specified for a given implementation of [Curve], such as [crate::curves::LineStringCurve]
40
+ /// The Linear Reference System. It must be specified for a given implementation
41
+ /// of [Curve], such as [crate::curves::LineStringCurve].
41
42
pub struct Lrs < CurveImpl : Curve > {
42
43
lrms : Vec < Lrm > ,
43
44
traversals : Vec < Traversal < CurveImpl > > ,
44
45
}
45
46
46
- /// The result of a projection onto an [LrmScale]
47
+ /// The result of a projection onto an [` LrmScale`].
47
48
pub struct LrmProjection {
48
- /// The measure anchor and offset
49
+ /// Contains ` measure` ([`LrmScaleMeasure`]) and `lrm` ([`LrmHandle`]).
49
50
pub measure : LrmMeasure ,
50
- /// How far from the Lrm is the point that has been projected
51
+ /// How far from the [` Lrm`] is the [`Point`] that has been projected.
51
52
pub orthogonal_offset : f64 ,
52
53
}
53
54
54
- /// Identifies a position on an [LrmScale] by distance from start
55
+ /// Identifies a [`ScalePosition`] on an [` LrmScale` ] by the distance from the start of the scale.
55
56
#[ derive( Clone , Copy , Debug ) ]
56
57
pub struct LrmPosition {
57
- /// The distance from that of the scale
58
+ /// The distance from that of the scale.
58
59
pub distance_from_start : ScalePosition ,
59
- /// Identifies the LrmScale
60
+ /// Identifies the [` LrmScale`].
60
61
pub lrm : LrmHandle ,
61
62
}
62
63
63
- /// Identifies a position on an [LrmScale] by distance from an anchor of the scale
64
+ /// Identifies a position on an [LrmScale] by distance from an [`Anchor`] of the scale.
64
65
#[ derive( Clone , Debug ) ]
65
66
pub struct LrmMeasure {
66
- /// Anchor and offset to that anchor
67
+ /// Contains `anchor_name` and `scale_offset` ([`ScalePosition`]).
67
68
pub measure : LrmScaleMeasure ,
68
- /// Identifies the LrmScale
69
+ /// Identifies the [` LrmScale`].
69
70
pub lrm : LrmHandle ,
70
71
}
71
72
72
- /// The result of a projection an a Traversal
73
+ /// The result of a projection an a [` Traversal`].
73
74
#[ derive( Clone , Copy , Debug ) ]
74
75
pub struct TraversalProjection {
75
- /// Distance from the start of the curve of the traversal
76
+ /// Distance from the start of the [`Curve`] to the [`Traversal`].
76
77
pub distance_from_start : CurvePosition ,
77
- /// How far from the traversal is the point has been projected
78
+ /// How far from the [`Traversal`] is the [`Point`] that has been projected.
78
79
pub orthogonal_offset : f64 ,
79
- /// identifies the traversal
80
+ /// Identifies the [`Traversal`].
80
81
pub traversal : TraversalHandle ,
81
82
}
82
83
83
- /// Identifies a position on a traversal
84
+ /// Identifies a position on a [`Traversal`].
84
85
#[ derive( Clone , Copy , Debug ) ]
85
86
pub struct TraversalPosition {
86
- /// Distance from the start of the curve of the traversal
87
+ /// Distance from the start of the [`Curve`] to the [`Traversal`].
87
88
pub distance_from_start : CurvePosition ,
88
- /// Identifies the traversal
89
+ /// Identifies the [`Traversal`].
89
90
pub traversal : TraversalHandle ,
90
91
}
91
92
@@ -98,29 +99,31 @@ impl From<TraversalPosition> for CurveProjection {
98
99
}
99
100
}
100
101
101
- /// A range on a traversal
102
- /// It can be used to identify a speed limit zone
102
+ /// Describes an interval (= range) on a [`Traversal`].
103
+ /// The borders are [`CurvePosition`]s.
104
+ /// It can be used to identify a speed limit zone for instance.
103
105
pub struct TraversalRange {
104
- /// Identifies the traversal
106
+ /// Identifies the [`Traversal`].
105
107
pub traversal : TraversalHandle ,
106
- /// Begin of the range
108
+ /// Begin of the range.
107
109
pub begin : CurvePosition ,
108
- /// End of the range
110
+ /// End of the range.
109
111
pub end : CurvePosition ,
110
- /// Direction of the range
112
+ /// [` Direction`] of the range.
111
113
pub direction : Direction ,
112
114
}
113
115
114
- /// A range on a [LrmScale]
115
- /// It can be used to identify a speed limit zone
116
+ /// Describes an interval (= range) on a [`LrmScale`].
117
+ /// The borders are [`LrmScaleMeasure`]s.
118
+ /// It can be used to identify a speed limit zone for instance.
116
119
pub struct LrmRange {
117
- /// Identifies the Lrm
120
+ /// Identifies the [` Lrm`].
118
121
pub lrm : LrmHandle ,
119
- /// Begin of the range
122
+ /// Begin of the range.
120
123
pub begin : LrmScaleMeasure ,
121
- /// End of the range
124
+ /// End of the range.
122
125
pub end : LrmScaleMeasure ,
123
- /// Direction of the range
126
+ /// [` Direction`] of the range.
124
127
pub direction : Direction ,
125
128
}
126
129
@@ -227,97 +230,97 @@ impl<CurveImpl: Curve> Lrs<CurveImpl> {
227
230
}
228
231
}
229
232
230
- /// Errors when manipulating a Lrs
233
+ /// Errors when manipulating [` Lrs`].
231
234
#[ derive( Error , Debug , PartialEq ) ]
232
235
pub enum LrsError {
233
- /// The handle is not valid. Maybe it was build manually or the structure mutated
236
+ /// The [`LrmHandle`] is not valid. It might have been built manually or the structure mutated.
234
237
#[ error( "invalid handle" ) ]
235
238
InvalidHandle ,
236
- /// There was an error when manipulation a curve of the lrs
239
+ /// An error occured while manipulating a [`Curve`] of the [`Lrs`].
237
240
#[ error( "curve error" ) ]
238
241
CurveError ( #[ from] CurveError ) ,
239
- /// There was an error when manipulation a lrm scale of the lrs
242
+ /// An error occured while manipulating a [`LrmScale`] of the [`Lrs`].
240
243
#[ error( "curve error" ) ]
241
244
LrmScaleError ( #[ from] LrmScaleError ) ,
242
- /// Could not open the LRS source
245
+ /// Could not open the LRS file.
243
246
#[ error( "open file error" ) ]
244
247
OpenFileError ,
245
- /// Could not read the LRS source content
248
+ /// Could not read the LRS file.
246
249
#[ error( "read file error" ) ]
247
250
ReadFileError ,
248
- /// Could not parse the LRS source data
251
+ /// Could not parse the LRS file.
249
252
#[ error( "invalid flatbuffer content" ) ]
250
253
InvalidArchive ,
251
254
}
252
255
253
256
trait LrsBase {
254
- /// Returns the handle (if it exists) of the LRM identified by its id
257
+ /// Returns the [`LrmHandle`] (if it exists) of the [`Lrm`] identified by its `lrm_id`.
255
258
fn get_lrm ( & self , lrm_id : & str ) -> Option < LrmHandle > ;
256
- /// Returns the handle (if it exists) of the traversal identified by its name
259
+ /// Returns the [`TraversalHandle`] (if it exists) of the [`Traversal`] identified by its `traversal_id`.
257
260
fn get_traversal ( & self , traversal_id : & str ) -> Option < TraversalHandle > ;
258
261
259
- /// Project a point on all traversals applicable to a given lrm
260
- /// The point must be in the bounding box of the curve of the traversal
261
- /// The result is sorted by orthogonal_offset: the lrm nearest to the point is the first item
262
+ /// Projects a [`Point`] on all applicable [`Traversal`]s to a given [`Lrm`].
263
+ /// The [`Point`] must be in the bounding box of the [`Curve`] of the [`Traversal`].
264
+ /// The result is sorted by ` orthogonal_offset` : the nearest [`Lrm`] to the [`Point`] is the first item.
262
265
fn lookup ( & self , point : Point , lrm : LrmHandle ) -> Vec < LrmProjection > ;
263
- /// Project a point on all LRM where the point is in the bounding box
264
- /// The result is sorted by orthogonal_offset: the lrm nearest to the point is the first item
266
+ /// Projects a [`Point`] on all [`Lrm`] where the [`Point`] is in the bounding box.
267
+ /// The result is sorted by ` orthogonal_offset` : the nearest [`Lrm`] to the [`Point`] is the first item.
265
268
fn lookup_lrms ( & self , point : Point ) -> Vec < LrmProjection > ;
266
- /// Project a point on all traversals where the point is in the bounding box
267
- /// The result is sorted by orthogonal_offset: the lrm nearest to the point is the first item
269
+ /// Projects a [`Point`] on all [`Traversal`]s where the [`Point`] is in the bounding box.
270
+ /// The result is sorted by ` orthogonal_offset` : the nearest [`Lrm`] to the [`Point`] is the first item.
268
271
fn lookup_traversals ( & self , point : Point ) -> Vec < TraversalProjection > ;
269
272
270
- /// Given a traversal position , returns it geographical position
273
+ /// Given a [`TraversalPosition`] , returns it geographical position ([`Point`]).
271
274
fn locate_traversal ( & self , position : TraversalPosition ) -> Result < Point , LrsError > ;
272
275
273
- /// And LRM can be used on many traversals
274
- /// For example for both directions of a highway
275
- /// This method returns all traversals that applicable to that traversal
276
+ /// And [`Lrm`] can be used on many [`Traversal`]s.
277
+ /// For example, for both directions of a highway.
278
+ /// This method returns all applicable [`TraversalHandle`]s to that [`Traversal`].
276
279
fn get_lrm_applicable_traversals ( & self , lrm : LrmHandle ) -> & [ TraversalHandle ] ;
277
- /// An LRM has a reference traversal
278
- /// It could be the centerline of a highway, or a specific track
279
- /// This methods returns the handle to that traversal
280
+ /// An [`Lrm`] has a reference [`Traversal`]
281
+ /// For example, for the centerline of a highway, or a specific track.
282
+ /// This methods returns the [`TraversalHandle`].
280
283
fn get_lrm_reference_traversal ( & self , lrm : LrmHandle ) -> TraversalHandle ;
281
284
282
- /// A traversal can be use for multiple LRM
283
- /// A highway could have milestones referenced in miles and kilometers
285
+ /// A [`Traversal`] can be use for multiple [`Lrm`]s.
286
+ /// For example, a highway could have milestones referenced in ` miles` AND ` kilometers`.
284
287
fn get_traversal_lrms ( & self , traversal : TraversalHandle ) -> & [ LrmHandle ] ;
285
288
286
- /// Projects a position on one traversal onto an other traversal
287
- /// e.g. when placing a point on both sides of the highway
289
+ /// Projects a [`TraversalPosition`] on a [`Traversal`] onto an other [`Traversal`],
290
+ /// e.g. when placing a point on both sides of the highway.
288
291
fn traversal_project (
289
292
& self ,
290
293
position : TraversalPosition ,
291
294
onto : TraversalHandle ,
292
295
) -> Result < TraversalProjection , LrsError > ;
293
296
294
- /// Projects a range on one traversal onto an other traversal
295
- /// e.g. when placing a stretch where wild animal cross
297
+ /// Projects a [`TraversalRange`] on a [`Traversal`] onto an other [`Traversal`],
298
+ /// e.g. when placing a stretch where wild animals cross.
296
299
fn traversal_project_range (
297
300
& self ,
298
301
range : TraversalRange ,
299
302
onto : TraversalHandle ,
300
303
) -> Result < TraversalRange , LrsError > ;
301
304
302
- /// Given the position on a traversal , projects that position onto an LRM
305
+ /// Given the [`TraversalPosition`] on a [`Traversal`] , projects that [`TraversalPosition`] onto an [`Lrm`].
303
306
fn lrm_project (
304
307
& self ,
305
308
position : TraversalPosition ,
306
309
onto : LrmHandle ,
307
310
) -> Result < LrmProjection , LrsError > ;
308
311
309
- /// Projects a range on one traversal onto an [LrmScale]
310
- /// e.g. when placing a stretch where wild animal cross
312
+ /// Projects a [`TraversalRange`] on a [`Traversal`] onto an [LrmScale],
313
+ /// e.g. when placing a stretch where wild animals cross.
311
314
fn lrm_project_range (
312
315
& self ,
313
316
range : TraversalRange ,
314
317
onto : LrmHandle ,
315
318
) -> Result < LrmRange , LrsError > ;
316
319
317
- /// Given a position on the LRM , returns the measure
318
- /// It will find the nearest anchor that gives a positive offset
320
+ /// Given a [`LrmPosition`] , returns its [`LrmMeasure`].
321
+ /// It will find the nearest [`Anchor`] that gives a positive ` offset`.
319
322
fn lrm_get_measure ( & self , position : LrmPosition ) -> Result < LrmMeasure , LrsError > ;
320
- /// Given a measure , returns the position on that LRM
323
+ /// Given an [`LrmMeasure`] , returns its [`LrmPosition`].
321
324
fn lrm_get_position ( & self , measure : LrmMeasure ) -> Result < LrmPosition , LrsError > ;
322
325
323
326
// TODO
0 commit comments