-
Notifications
You must be signed in to change notification settings - Fork 71
osm_to_railjson: minor upgrades #16209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
1795769
3bba060
863b5db
ca87ca4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -449,13 +449,17 @@ pub fn electrifications(edge: &Edge) -> Option<Electrification> { | |
| }) | ||
| } | ||
|
|
||
| fn map_node_id_to_node( | ||
| fn map_node_id_to_trigram( | ||
| pbf: &mut OsmPbfReader<std::fs::File>, | ||
| ) -> HashMap<osm4routing::osmpbfreader::NodeId, osm4routing::osmpbfreader::Node> { | ||
| ) -> HashMap<osm4routing::osmpbfreader::NodeId, String> { | ||
| pbf.iter() | ||
| .flatten() | ||
| .filter_map(|obj| match obj { | ||
| osm4routing::osmpbfreader::OsmObj::Node(node) => Some((node.id, node)), | ||
| osm4routing::osmpbfreader::OsmObj::Node(node) => node | ||
| .tags | ||
| .get("railway:ref") | ||
| .filter(|trigram| trigram.len() <= 3) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Germany they can have up to 5 characters (and in France 1 or 2...).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added this filter because editoast give me and error when I have a trigram longer then 3 characters. I don't know where but I think there is a 3 characters limitation somewhere else in the code.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah it seems the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Openned #16212 but i don't know how this will play out with the OP model refacto
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened #16215 to fix editoast
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice ! but ths problem still remains, sometimes there is a number where the trigram should be.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm if it doesn't break editoast too much i'd say let invalid OSM data resurface to the users so that they (and us) can see what needs to be fixed in OSM more easily? but probably someone else has another opinion |
||
| .map(|tag| (node.id, tag.to_string())), | ||
| _ => None, | ||
| }) | ||
| .collect() | ||
|
|
@@ -467,7 +471,7 @@ pub fn operational_points( | |
| ) -> Vec<OperationalPoint> { | ||
| let file = std::fs::File::open(osm_pbf_in).unwrap(); | ||
| let mut pbf: OsmPbfReader<std::fs::File> = osm4routing::osmpbfreader::OsmPbfReader::new(file); | ||
| let node_id_to_node = map_node_id_to_node(&mut pbf); | ||
| let node_id_to_trigram = map_node_id_to_trigram(&mut pbf); | ||
| pbf.rewind().expect("Could not rewind file."); | ||
| pbf.iter() | ||
| .flatten() | ||
|
|
@@ -504,11 +508,8 @@ pub fn operational_points( | |
| _ => None, | ||
| }) | ||
| .find_map(|node_id| { | ||
| node_id_to_node.get(&node_id).and_then(|node| { | ||
| node.tags | ||
| .get("railway:ref") | ||
| .map(ToString::to_string) | ||
| }) | ||
| node_id_to_trigram.get(&node_id) | ||
| .cloned() | ||
| }) | ||
| .unwrap_or_default(); | ||
| // Parts can be empty when the stop_area references stops that are not railway (e.g. bus station) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.