@@ -22,34 +22,35 @@ fn read_osm(input_file: &str, lrm_tag: &str) -> (Vec<osm4routing::Node>, Vec<osm
22
22
23
23
#[ derive( Parser , Debug ) ]
24
24
#[ command( version, about, long_about = None ) ]
25
+ /// Arguments given by the command line interface.
25
26
struct Args {
26
- /// OpenStreetMap file to parse
27
+ /// OpenStreetMap file to parse.
27
28
#[ arg( short, long) ]
28
29
input_osm_file : String ,
29
30
30
- /// Output file where the LRS will be written
31
+ /// Output file where the [`Lrs`] will be written.
31
32
#[ arg( short, long) ]
32
33
output_lrs : String ,
33
34
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`.
35
36
#[ arg( short, long) ]
36
37
lrm_tag : String ,
37
38
}
38
39
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.
40
41
#[ derive( PartialEq , Eq , Debug ) ]
41
42
enum Candidate {
42
43
Source ,
43
44
Target ,
44
45
NotCandidate ,
45
46
}
46
47
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.
53
54
fn can_be_appended ( candidate : & Edge , last_edge : & Edge , consider_source : bool ) -> Candidate {
54
55
let last_node = if consider_source {
55
56
last_edge. source
@@ -136,6 +137,9 @@ fn sort_edges(edges: Vec<Edge>, traversal_ref: &str) -> Vec<(Edge, bool)> {
136
137
return sorted;
137
138
}
138
139
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`
139
143
fn main ( ) {
140
144
let cli_args = Args :: parse ( ) ;
141
145
let ( nodes, edges) = read_osm ( & cli_args. input_osm_file , & cli_args. lrm_tag ) ;
@@ -209,7 +213,7 @@ fn main() {
209
213
} )
210
214
. collect ( ) ;
211
215
212
- println ! ( "In the LRS we have {} traversals" , traversals. len( ) ) ;
216
+ println ! ( "In the LRS, we have {} traversals. " , traversals. len( ) ) ;
213
217
214
218
let nodes: Vec < _ > = nodes
215
219
. iter ( )
@@ -275,6 +279,7 @@ fn main() {
275
279
views : Some ( fbb. create_vector ( & [ view] ) ) ,
276
280
..Default :: default ( )
277
281
} ;
282
+
278
283
let lrs = Lrs :: create ( & mut fbb, & lrs_args) ;
279
284
280
285
fbb. finish ( lrs, None ) ;
0 commit comments