DeloitteOptimalReality / LightOSM.jl

A Julia package for downloading and analysing geospatial data from OpenStreetMap APIs.
https://deloitteoptimalreality.github.io/LightOSM.jl/docs
Other
47 stars 12 forks source link

buildings_from_file: ERROR: KeyError: key 5461892572 not found #94

Closed SimonDanisch closed 1 year ago

SimonDanisch commented 1 year ago

So, somehow the OSM building format has changed or something, since this error was not happening some weeks/months ago, and checking out an old version of LightOSM throws exactly the same error:

using LightOSM
download_osm_buildings(:bbox;
    area...,
    metadata=true,
    download_format=:osm,
    save_to_file_location="london_buildings.osm"
);
# load as Buildings Dict
buildings = buildings_from_file("london_buildings.osm");

ERROR: KeyError: key 5461892572 not found
Stacktrace:
 [1] getindex(h::Dict{Int64, Dict{String, Any}}, key::Int64)
   @ Base .\dict.jl:484
 [2] parse_osm_buildings_dict(osm_buildings_dict::Dict{String, Any})
   @ LightOSM C:\Users\sdani\.julia\packages\LightOSM\Ksg88\src\buildings.jl:215
 [3] buildings_from_object
   @ C:\Users\sdani\.julia\packages\LightOSM\Ksg88\src\buildings.jl:260 [inlined]
 [4] buildings_from_file(file_path::String)
   @ LightOSM C:\Users\sdani\.julia\packages\LightOSM\Ksg88\src\buildings.jl:294
 [5] top-level scope
   @ c:\Users\sdani\SimiWorld\ProgrammerLife\GeoDev\dev\Tyler\docs\examples\UserGuide\osmmakie.jl:28

I could work around by inserting an haskey into parse_osm_buildings_dict, but I didn't understand the code well enough to make sure it's the correct fix.

fbanning commented 1 year ago

We now had another user stumbling upon this error. Did anyone happen to have had a look at this in the meantime?

mmiller-max commented 1 year ago

What I think has happened is that relations have been added to nodes (either a format change or some new data added). The code in parse_osm_buildings_dict assumes that everything is a way and therefore tries to lookup a node ID in a dictionary of ways. I'll push a PR but will need @captchanjack to check if we need to handle nodes in an additional way, but in the meantime if you could test the PR gets you what you expect that would be helpful please!