Skip to content

Commit f0bf7ce

Browse files
committed
Doc improvements
1 parent 75bdfea commit f0bf7ce

File tree

4 files changed

+34
-18
lines changed

4 files changed

+34
-18
lines changed

schema/lrs.fbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ table LinearReferencingMethod {
119119
properties:[Property];
120120

121121
traversal_index:TraversalRef;
122-
/// An LRM can apply to multiple referals
122+
/// An LRM can apply to multiple traversal
123123
/// For instance a LRM can be the central line of a highway
124124
/// And that LRM is the reference for the two other traversals corresponding to each direction
125125
used_on:[TraversalRef];

src/geometry_from_osm.rs

+16-11
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,35 @@ fn read_osm(input_file: &str, lrm_tag: &str) -> (Vec<osm4routing::Node>, Vec<osm
2222

2323
#[derive(Parser, Debug)]
2424
#[command(version, about, long_about = None)]
25+
/// Arguments given by the command line interface.
2526
struct Args {
26-
/// OpenStreetMap file to parse
27+
/// OpenStreetMap file to parse.
2728
#[arg(short, long)]
2829
input_osm_file: String,
2930

30-
/// Output file where the LRS will be written
31+
/// Output file where the [`Lrs`] will be written.
3132
#[arg(short, long)]
3233
output_lrs: String,
3334

34-
/// OpenStreetMap tag identifying the lrm. For the french railway network use ref:FR:SNCF_Reseau
35+
/// OpenStreetMap tag identifying the LRM. The french railway network uses `ref:FR:SNCF_Reseau`.
3536
#[arg(short, long)]
3637
lrm_tag: String,
3738
}
3839

39-
// When sortir the edges, we test each candidate to see if they match and if they need to bee reversed
40+
// When sorting the edges, each candidate is tested to see if they match and if they need to be reversed.
4041
#[derive(PartialEq, Eq, Debug)]
4142
enum Candidate {
4243
Source,
4344
Target,
4445
NotCandidate,
4546
}
4647

47-
// If we have a string of edges that ends with `end_edge`
48-
// Can the candidate Edge(s, t) be joined at the end_edge(source, target)
49-
// Returns Forward if the Edge’s can be appened in the same direction (target == s)
50-
// Backward if it must be reverded (target == t)
51-
// And NotCandidate if it can’t be appended
52-
// consider_source means that we consider the source (or target if false) of the last_edge
48+
// If we have a string of edges that ends with `end_edge`,
49+
// the candidate `Edge(s, t)` can be joined at the `end_edge(source, target)`.
50+
// Returns Forward if the `Edge` can be append in the same direction `(target == s)`,
51+
// Backward if it must be reversed `(target == t)` or
52+
// And NotCandidate if it can’t be appended.
53+
// `consider_source` means that the source (or target if false) of the `last_edge` is considered.
5354
fn can_be_appended(candidate: &Edge, last_edge: &Edge, consider_source: bool) -> Candidate {
5455
let last_node = if consider_source {
5556
last_edge.source
@@ -136,6 +137,9 @@ fn sort_edges(edges: Vec<Edge>, traversal_ref: &str) -> Vec<(Edge, bool)> {
136137
return sorted;
137138
}
138139

140+
/// Example: to generate an LRS from an OpenStreetMap dump
141+
///
142+
/// `$ cargo run --release --bin geometry_from_osm -- -i france.osm.pbf -o osm_83000.lrs.bin --lrm-tag=ref:fr:SNCF_Reseau`
139143
fn main() {
140144
let cli_args = Args::parse();
141145
let (nodes, edges) = read_osm(&cli_args.input_osm_file, &cli_args.lrm_tag);
@@ -209,7 +213,7 @@ fn main() {
209213
})
210214
.collect();
211215

212-
println!("In the LRS we have {} traversals", traversals.len());
216+
println!("In the LRS, we have {} traversals.", traversals.len());
213217

214218
let nodes: Vec<_> = nodes
215219
.iter()
@@ -275,6 +279,7 @@ fn main() {
275279
views: Some(fbb.create_vector(&[view])),
276280
..Default::default()
277281
};
282+
278283
let lrs = Lrs::create(&mut fbb, &lrs_args);
279284

280285
fbb.finish(lrs, None);

src/lrs.rs

+16-5
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,25 @@ pub struct LrmHandle(usize);
2323
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
2424
pub struct TraversalHandle(usize);
2525

26-
struct Lrm {
27-
scale: LrmScale,
28-
reference_traversal: TraversalHandle,
29-
traversals: Vec<TraversalHandle>,
26+
/// Represents an Linear Reference Method (LRM).
27+
/// It is the combination of one (or more) [`Traversal`]s for one [`LrmScale`].
28+
pub struct Lrm {
29+
/// The scale of this [`Lrm`].
30+
pub scale: LrmScale,
31+
/// The [`Traversal`] that is the reference of this [`Lrm`].
32+
pub reference_traversal: TraversalHandle,
33+
/// All the [`Traversal`]s where this [`Lrm`] applies.
34+
pub traversals: Vec<TraversalHandle>,
3035
}
3136

37+
/// A [`Traversal`] is path in the network that ends [`Curve`].
38+
/// That [`Traversal`]s can be used for many different [`Lrm`]s.
3239
struct Traversal<CurveImpl: Curve> {
40+
/// Identifies this [`Traversal`].
3341
id: String,
42+
/// The geometrical [`Curve`] of this [`Traversal`].
3443
curve: CurveImpl,
44+
/// All the [`Lrm`]s that use this [`Traversal`].
3545
lrms: Vec<LrmHandle>,
3646
}
3747

@@ -251,7 +261,8 @@ pub enum LrsError {
251261
InvalidArchive,
252262
}
253263

254-
trait LrsBase {
264+
/// The basic functions to manipulate the [`Lrs`].
265+
pub trait LrsBase {
255266
/// Returns the [`LrmHandle`] (if it exists) of the [`Lrm`] identified by its `lrm_id`.
256267
fn get_lrm(&self, lrm_id: &str) -> Option<LrmHandle>;
257268
/// Returns the [`TraversalHandle`] (if it exists) of the [`Traversal`] identified by its `traversal_id`.

src/lrs_generated.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1974,7 +1974,7 @@ impl<'a> LinearReferencingMethod<'a> {
19741974
// which contains a valid value in this slot
19751975
unsafe { self._tab.get::<TraversalRef>(LinearReferencingMethod::VT_TRAVERSAL_INDEX, None)}
19761976
}
1977-
/// An LRM can apply to multiple referals
1977+
/// An LRM can apply to multiple traversal
19781978
/// For instance a LRM can be the central line of a highway
19791979
/// And that LRM is the reference for the two other traversals corresponding to each direction
19801980
#[inline]

0 commit comments

Comments
 (0)