DeloitteOptimalReality / LightOSM.jl

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

node_to_way relationship contained duplicate ways when only considering the largest connected component #81

Closed henrik-wolf closed 2 years ago

henrik-wolf commented 2 years ago

I noticed that, when I create a OSMGraph object like this:

using LightOSM
data = download_osm_network(:bbox; minlat=52.89, minlon=-1.2, maxlat=52.92, maxlon=-1.165)
g = graph_from_object(data, weight_type=:distance)

the values of g.node_to_way would contain every way the corresponding key is part of twice. I believe I narrowed it down to the fact, that in this case above, largest_connected_component=true. So when rebuilding the mappings in trim_to_largest_connected_component!(...) we would again call add_node_and_edge_mappings!(...), which only adds to the dict, without checking if the ways have already been added.

I fixed this problem, by explicitly converting and then collecting the values of g.node_to_way to a set, at the end of every call to add_node_and_edge_mappings!(...)

captchanjack commented 2 years ago

Nice find! LGTM