Closed Timmmm closed 3 years ago
Thanks for this issue and your observations! I will look into it later today. I was already thinking about introducing typed indices but didn't know about typed_index_collections.
I tested three different files from Geofabrik (including http://download.geofabrik.de/europe/netherlands-latest.osm.pbf) but could not reproduce this issue. Could you point me to a file that generates this error?
Weird, yeah it's this one: http://download.openstreetmap.fr/extracts/europe/netherlands.osm.pbf (1.2 GB)
SHA1 hash:
$ shasum netherlands.osm.pbf
6570f4cc23546d266c0d7f72ce13bd0bffbe3417 netherlands.osm.pbf
It looks like this file is inconsistent. There is a way that contains a reference to a node that is not included in the file.
{
println!("start checking");
let reader = ElementReader::from_path("netherlands.osm.pbf")?;
let needle = 8188406987;
reader.for_each(
|element| match element {
Element::DenseNode(n) => {
if n.id == needle {
println!("found node {}", needle);
}
},
Element::Node(n) => {
if n.id() == needle {
println!("found node {}", needle);
}
},
Element::Way(w) => {
if w.refs().any(|node_id| node_id == needle) {
println!("way {} contains node {}", w.id(), needle);
}
},
_ => {}
}
)?;
println!("done checking");
}
When adding this code it prints:
start checking
way 5168742 contains node 8188406987
done checking
So the node 8188406987 is missing :(
I did some research. It seems to be a common issue that referential integrity is not guaranteed for all OSM extracts:
Ah interesting! Thanks for all the help, guess I'll just skip ways with missing refs (or use the file you linked). Not an issue in your library anyway!
Thanks for the great project. I'm using it to make a web server that runs on your phone and serves a map of your location, with the idea being you can connect a kindle to it to use as a satnav when cycling. Phones just don't work when it's sunny.
Got this so far:
Needs a bit of work (e.g. projection is wrong, probably should use different styles for different roads and maybe add rivers), but it's probably good enough for satnav if the route is overlaid.
Anyway, thanks again for the helpful library!
I've written a simple program to extract all of the highways from a file and insert them into a SQLite database. Unfortunately it seems like
read_ways_and_deps()
gives me aWay
but doesn't give me one of theNode
s it contains. If I run it I get this error:I may have misunderstood the data model. It would really help if you used
TiVec
and typed IDs. Like this:It's a little more work but way easier to follow.
Anyway here's the complete code. I would really appreciate it if you could figure out what I'm doing wrong! The relevant bit is
insert_data()
. (Also feel free to use this as an example if it can be fixed.)Btw it's weird that
DenseNode
'sid
is a field, butNode
'sid
is a method.Thanks for the project!