Skip to content
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

where to find this OpenStreetMapX.nearest_node(m, features[key]) function? #18

Open
bsnyh opened this issue Jul 22, 2019 · 5 comments
Open

Comments

@bsnyh
Copy link

bsnyh commented Jul 22, 2019

Hi, I hope that I did not misunderstand anything. I was a bit confused about the following code.

####################################################
###	For Each Feature Find the Nearest Graph Node ###
####################################################

function features_to_graph(m::OpenStreetMapX.MapData, features::Dict{Int,Tuple{String,String}}) where T<:(Union{OpenStreetMapX.ENU,OpenStreetMapX.ECEF})
    features_to_nodes = Dict{Int,Int}()
    sizehint!(features_to_nodes,length(features))
    for (key,value) in features
        if !haskey(m.v,key)
            features_to_nodes[key] = OpenStreetMapX.nearest_node(m,features[key])
        else
            features_to_nodes[key] = key
        end
    end
    return features_to_nodes
end

Firstly, what is exactly "for each feature, find the nearest graph node"? What does it mean? Secondly, where to find this function OpenStreetMapX.nearest_node(m, features[key])?

@bartoszpankratz
Copy link
Collaborator

Hi,

In the most basic scenario, when you use features from the osm file you don't need to bother yourself with this function, features are already nodes. Hovewer, when you want to use the features from the outside file (e.g. you got some special list of objects necessary in your model) or filter the roads (e.g. you only interested in having highways) then it might be quite useful.
The code is here

@bsnyh
Copy link
Author

bsnyh commented Jul 23, 2019

Hi, bartoszpankratz,
Great! Thank you a lot. You mean the code is as the following, right?

function nearest_node(m::MapData, loc::ENU, vs_only::Bool=true)
	vs_only ? nearest_node(m.nodes,loc, keys(m.v)) : nearest_node(m.nodes,loc)
end

@bartoszpankratz
Copy link
Collaborator

Yeah, that's right. My mistake.

@bsnyh
Copy link
Author

bsnyh commented Jul 23, 2019

Or am I wrong also? The features parameter in the function features_to_graph is a Dict{Int,Tuple{String,String}}......

@bartoszpankratz
Copy link
Collaborator

Ok, sorry. I have changed a lot, someone mess around with this function and no one have update it. I remeber that at the beginning this function was written to work with external data sources, like CSV files, thats the reason why features are Dict{Int,Tuple{String,String}} - Tuple{String,String} was the pair of coordinates which then was translated to LLA type. Thank you! We will repair it obviously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants