Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/graph_utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@

Maps node index to node id.
"""
index_to_node_id(g::OSMGraph, x::DEFAULT_OSM_INDEX_TYPE) = g.index_to_node[x]
index_to_node_id(g::OSMGraph, x::Vector{<:DEFAULT_OSM_INDEX_TYPE}) = [index_to_node_id(g, i) for i in x]
index_to_node_id(g::OSMGraph{U}, x::U) where U = g.index_to_node[x]
index_to_node_id(g::OSMGraph{U}, x::Vector{<:U}) where U = [index_to_node_id(g, i) for i in x]

"""
index_to_node(g::OSMGraph, x::DEFAULT_OSM_INDEX_TYPE)
index_to_node(g::OSMGraph, x::Vector{<:DEFAULT_OSM_INDEX_TYPE})

Maps node index to node object.
"""
index_to_node(g::OSMGraph, x::DEFAULT_OSM_INDEX_TYPE) = g.nodes[g.index_to_node[x]]
index_to_node(g::OSMGraph, x::Vector{<:DEFAULT_OSM_INDEX_TYPE}) = [index_to_node(g, i) for i in x]
index_to_node(g::OSMGraph{U}, x::U) where U = g.nodes[g.index_to_node[x]]
index_to_node(g::OSMGraph{U}, x::Vector{<:U}) where U = [index_to_node(g, i) for i in x]

"""
node_id_to_index(g::OSMGraph, x::DEFAULT_OSM_ID_TYPE)
node_id_to_index(g::OSMGraph, x::Vector{<:DEFAULT_OSM_ID_TYPE})

Maps node id to index.
"""
node_id_to_index(g::OSMGraph, x::DEFAULT_OSM_ID_TYPE) = g.node_to_index[x]
node_id_to_index(g::OSMGraph, x::Vector{<:DEFAULT_OSM_ID_TYPE}) = [node_id_to_index(g, i) for i in x]
node_id_to_index(g::OSMGraph{U,T}, x::T) where {U,T} = g.node_to_index[x]
node_id_to_index(g::OSMGraph{U,T}, x::Vector{<:T}) where {U,T} = [node_id_to_index(g, i) for i in x]
"""
node_to_index(g::OSMGraph, x::Node)
node_to_index(g::OSMGraph, x::Vector{Node})
Expand All @@ -38,30 +38,30 @@ node_to_index(g::OSMGraph, x::Vector{Node}) = [node_id_to_index(g, i.id) for i i

Maps node index to dijkstra state (parents).
"""
index_to_dijkstra_state(g::OSMGraph, x::DEFAULT_OSM_INDEX_TYPE) = g.dijkstra_states[x]
index_to_dijkstra_state(g::OSMGraph{U}, x::U) where U = g.dijkstra_states[x]
"""
node_id_to_dijkstra_state(g::OSMGraph, x::DEFAULT_OSM_ID_TYPE)

Maps node id to dijkstra state (parents).
"""
node_id_to_dijkstra_state(g::OSMGraph, x::DEFAULT_OSM_ID_TYPE) = g.dijkstra_states[node_id_to_index(g, x)]
node_id_to_dijkstra_state(g::OSMGraph{U,T}, x::T) where {U,T} = g.dijkstra_states[node_id_to_index(g, x)]
"""
set_dijkstra_state_with_index!(g::OSMGraph, index::DEFAULT_OSM_INDEX_TYPE, state)

Set dijkstra state (parents) with node index.
"""
set_dijkstra_state_with_index!(g::OSMGraph, index::DEFAULT_OSM_INDEX_TYPE, state) = push!(g.dijkstra_states, index, state)
set_dijkstra_state_with_index!(g::OSMGraph{U}, index::U, state) where U = push!(g.dijkstra_states, index, state)
"""
set_dijkstra_state_with_node_id!(g::OSMGraph, index::DEFAULT_OSM_ID_TYPE, state)

Set dijkstra state (parents) with node id.
"""
set_dijkstra_state_with_node_id!(g::OSMGraph, node_id::DEFAULT_OSM_ID_TYPE, state) = push!(g.dijkstra_states, node_id_to_index(g, node_id), state)
set_dijkstra_state_with_node_id!(g::OSMGraph{U,T}, node_id::T, state) where {U,T} = push!(g.dijkstra_states, node_id_to_index(g, node_id), state)
"""
maxspeed_from_index(g, x::DEFAULT_OSM_INDEX_TYPE)
maxspeed_from_node_id(g, x::DEFAULT_OSM_ID_TYPE)

Get maxspeed from index id or node id.
"""
maxspeed_from_index(g, x::DEFAULT_OSM_INDEX_TYPE) = index_to_node(g, x).tags["maxspeed"]
maxspeed_from_node_id(g, x::DEFAULT_OSM_ID_TYPE) = g.nodes[x].tags["maxspeed"]
maxspeed_from_index(g::OSMGraph{U}, x::U) where U = index_to_node(g, x).tags["maxspeed"]
maxspeed_from_node_id(g::OSMGraph{U,T}, x::T) where {U,T} = g.nodes[x].tags["maxspeed"]