You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When iterating over the references of nodes in a way the first and last node id reference has the same id, in almost all ways (there are exceptions, but they are in the minority). I've tried this on a couple of different data sets but it yields the same result. Based on my knowledge on the structure of OSM this should not happen, but if I'm mistaken then please let me know. I've posted a basic function to replicate the issue.
fn iter_ways() {
let reader = ElementReader::from_path("path/to/file").unwrap();
reader
.for_each(|element| if let Element::Way(way) = element {
let mut it: WayRefIter<'_> = way.refs();
let first_node_in_way: i64 = it.next().unwrap();
let last_node_in_way: i64 = it.last().unwrap();
println!("first: {first_node_in_way}, last: {last_node_in_way}"); // both are equal
})
.unwrap();
}
The text was updated successfully, but these errors were encountered:
Yes, of course! I had forgotten about the closed polyline objects :)
An additional question though, what would be the best way to filter out ways based on tags in the above example, I know that I can use the tags(), but I haven't found an easy way of how to filter out highway nodes and then retrieving node ID's (and preferably node locations). Perhaps this is quite trivial, however I'm quite new to rust as well as this crate.
When iterating over the references of nodes in a way the first and last node id reference has the same id, in almost all ways (there are exceptions, but they are in the minority). I've tried this on a couple of different data sets but it yields the same result. Based on my knowledge on the structure of OSM this should not happen, but if I'm mistaken then please let me know. I've posted a basic function to replicate the issue.
fn iter_ways() {
let reader = ElementReader::from_path("path/to/file").unwrap();
reader
.for_each(|element| if let Element::Way(way) = element {
let mut it: WayRefIter<'_> = way.refs();
let first_node_in_way: i64 = it.next().unwrap();
let last_node_in_way: i64 = it.last().unwrap();
println!("first: {first_node_in_way}, last: {last_node_in_way}"); // both are equal
})
.unwrap();
}
The text was updated successfully, but these errors were encountered: