pub struct Parser { /* private fields */ }Expand description
Main class that parses a pbf file and maintains a cache of relations/ways/nodes then provides methods to access the public transports (PTv2) inside that (cached) file
Implementations§
Source§impl Parser
Main class, it parses the pbf file on new() and maintains an internal cache
of relations / ways / nodes, to build on the fly PublicTransport representations
impl Parser
Main class, it parses the pbf file on new() and maintains an internal cache of relations / ways / nodes, to build on the fly PublicTransport representations
Sourcepub fn new_ptv2(pbf_filename: &str, cpus: usize) -> Self
pub fn new_ptv2(pbf_filename: &str, cpus: usize) -> Self
creates internal cache by parsing public transport v2 from pbf file in the pbf_filename path, in parallel with cpus threads
Sourcepub fn new_aa(pbf_filename: &str, cpus: usize) -> Self
pub fn new_aa(pbf_filename: &str, cpus: usize) -> Self
creates internal cache by parsing administrative areas from pbf file in the pbf_filename path, in parallel with cpus threads
Sourcepub fn new(pbf_filename: &str, cpus: usize, filters: String) -> Self
pub fn new(pbf_filename: &str, cpus: usize, filters: String) -> Self
creates internal cache by parsing the pbf file in the pbf_filename path, in parallel with cpus threads, filtering by tags in filters
filters examples:
“tag_key”
the relation must have the tag “tag_key”
“tag_key=tag_value”
the relation must have the tag “tag_key” with value “tag_value”
“tag_key=tag_value,tag_value2&tag_key2=tag_value3”
the relation must have the tag “tag_key” with value “tag_value” or “tag_value2” and the tag “tag_key2” with value “tag_value3”
Examples found in repository?
4fn main() {
5 let pbf_filename_option = std::env::args().skip(1).next();
6 if pbf_filename_option == None {
7 return println!("Expected filename");
8 }
9 let pbf_filename = pbf_filename_option.unwrap();
10
11 let nthreads = num_cpus::get();
12 let parser = Parser::new(&pbf_filename, nthreads, "natural=beach".to_string());
13 // let parser = Parser::new_aa(&pbf_filename, nthreads);
14
15 let mut accum = 0usize;
16 let v1 = parser.get_areas(150_f64);
17 for _ in v1 {
18 accum += 1;
19 }
20
21 // OPTION2:
22 // let v2 = parser.par_map(|r| r.flatten_ways(150_f64).unwrap());
23
24 println!("OKs = {:?}", accum);
25}Sourcepub fn get_public_transports(&self, gap: f64) -> Vec<PublicTransport>
pub fn get_public_transports(&self, gap: f64) -> Vec<PublicTransport>
Builds a vector in parallel with all the public transport ways normalized and “fixed”. It works in parallel using the same amount of threads that were configured on new()
Sourcepub fn par_map<R, F>(&self, func: &F) -> Vec<R>
pub fn par_map<R, F>(&self, func: &F) -> Vec<R>
Iterates in parallel through the cache of public transports and
offers the possibility to further process them with the func function being executed in parallel
It works in parallel using the same amount of threads that were configured on new()
Sourcepub fn get_areas(&self, gap: f64) -> Vec<Area>
pub fn get_areas(&self, gap: f64) -> Vec<Area>
Builds a vector in parallel with all the areas normalized and “fixed”. It works in parallel using the same amount of threads that were configured on new()
Examples found in repository?
4fn main() {
5 let pbf_filename_option = std::env::args().skip(1).next();
6 if pbf_filename_option == None {
7 return println!("Expected filename");
8 }
9 let pbf_filename = pbf_filename_option.unwrap();
10
11 let nthreads = num_cpus::get();
12 let parser = Parser::new(&pbf_filename, nthreads, "natural=beach".to_string());
13 // let parser = Parser::new_aa(&pbf_filename, nthreads);
14
15 let mut accum = 0usize;
16 let v1 = parser.get_areas(150_f64);
17 for _ in v1 {
18 accum += 1;
19 }
20
21 // OPTION2:
22 // let v2 = parser.par_map(|r| r.flatten_ways(150_f64).unwrap());
23
24 println!("OKs = {:?}", accum);
25}Sourcepub fn get_relation_from_id(self, id: u64) -> Relation
pub fn get_relation_from_id(self, id: u64) -> Relation
Builds the Relation from the provided osm_id id
Sourcepub fn get_relation_at(&self, index: usize) -> Relation
pub fn get_relation_at(&self, index: usize) -> Relation
Builds the Relation at position index in the internal cache
Sourcepub fn get_way_at(&self, index: usize) -> Way
pub fn get_way_at(&self, index: usize) -> Way
Builds the Way at position index in the internal cache
Sourcepub fn iter(self) -> ParserRelationIterator ⓘ
pub fn iter(self) -> ParserRelationIterator ⓘ
Returns a sequential iterator that returns a Relation on each turn