Hi, I’m reading the code from this great OpenStreetMapX package, and the following function confused me a little bit. I would really appreciate it if anyone can help me clarify some doubts.
function get_edges(nodes::Dict{Int,T}, roadways::Vector{OpenStreetMapX.Way}) where T<: Union{OpenStreetMapX.ENU, OpenStreetMapX.ECEF}
oneway_roads = map(OpenStreetMapX.oneway, roadways)
reverse_roads = map(OpenStreetMapX.reverseway, roadways)
classes = OpenStreetMapX.classify_roadways(roadways)
edges = Dict{Tuple{Int, Int}, Int}()
for i = 1:length(roadways)
for j = 2: length(roadways[I].nodes)
n0 = roadways[i].nodes[j-1]
n1 = roadways[i].nodes[j]
start = n0 * !reverse_roads[i] + n1 * reverse_roads[i]
fin = n0 * reverse_roads[i] + n1 * !reverse_roads[i]
edges[(start, fin)] = classes[roadways[i].id]
oneway_roads[i] || (edges[(fin,start)] = classes[roadways[i].id])
end
end
return collect(keys(edges)), collect(values(edges))
end
what confused me are the two lines to assign values to the variables start
and fin
. Any comments are greatly appreciated.