Skip to content

Commit

Permalink
[FEAT] added final changes for OSM id type
Browse files Browse the repository at this point in the history
  • Loading branch information
ltokareva committed Mar 14, 2024
1 parent 117f1a0 commit a562b27
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/nearest_node.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ function nearest_nodes(g::OSMGraph, points::AbstractVector{GeoLocation}, n_neigh
end

"""
nearest_nodes(g::OSMGraph, node_id::Integer, n_neighbours::Integer=1)
nearest_nodes(g::OSMGraph, node_ids::Vector{<:Integer}, n_neighbours::Integer=1)
nearest_nodes(g::OSMGraph, node_id::DEFAULT_OSM_ID_TYPE, n_neighbours::Integer=1)
nearest_nodes(g::OSMGraph, node_ids::Vector{<:DEFAULT_OSM_ID_TYPE}, n_neighbours::Integer=1)
nearest_nodes(g::OSMGraph, node::Node, n_neighbours::Integer=1)
nearest_nodes(g::OSMGraph, nodes::AbstractVector{<:Node}, n_neighbours::Integer=1)
Expand Down
2 changes: 1 addition & 1 deletion src/nearest_way.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function nearest_ways(g::OSMGraph{U,T,W},
end

"""
nearest_point_on_way(g::OSMGraph, point::GeoLocation, way_id::Integer)
nearest_point_on_way(g::OSMGraph, point::GeoLocation, way_id::DEFAULT_OSM_ID_TYPE)
Finds the nearest position on a way to a given point. Matches to an `EdgePoint`.
Expand Down
8 changes: 4 additions & 4 deletions src/shortest_path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function is_restricted(restriction_ll::MutableLinkedList{V}, u::U, v::U, parents
end

"""
restriction_cost(restrictions::AbstractDict{V,Vector{MutableLinkedList{V}}}, u::U, v::U, parents::Vector{U})::Float64 where {U <: Integer,V <: Integer}
restriction_cost(restrictions::AbstractDict{V,Vector{MutableLinkedList{V}}}, u::U, v::U, parents::Vector{U})::Float64 where {U <: DEFAULT_OSM_INDEX_TYPE,V <: Integer}
Given parents, returns `Inf64` if path between `u` and `v` is restricted by the set of restriction linked lists, `0.0` otherwise.
Expand All @@ -175,7 +175,7 @@ Given parents, returns `Inf64` if path between `u` and `v` is restricted by the
# Return
- `Float64`: Returns `Inf64` if path between u and v is restricted, `0.0` otherwise.
"""
function restriction_cost(restrictions::AbstractDict{V,Vector{MutableLinkedList{V}}}, u::U, v::U, parents::P)::Float64 where {P <: Union{<:AbstractVector{<:U}, <:AbstractDict{<:U, <:U}}} where {U <: Integer,V <: Integer}
function restriction_cost(restrictions::AbstractDict{V,Vector{MutableLinkedList{V}}}, u::U, v::U, parents::P)::Float64 where {P <: Union{<:AbstractVector{<:U}, <:AbstractDict{<:U, <:U}}} where {U <: DEFAULT_OSM_INDEX_TYPE,V <: Integer}
!haskey(restrictions, u) && return 0.0

for ll in restrictions[u]
Expand Down Expand Up @@ -217,7 +217,7 @@ hence we pick the largest maxspeed across all ways.
time_heuristic(g::OSMGraph) = (u, v) -> haversine(g.node_coordinates[u], g.node_coordinates[v]) / 100.0

"""
weights_from_path(g::OSMGraph{U,T,W}, path::Vector{T}; weights=g.weights)::Vector{W} where {U <: Integer,T <: DEFAULT_OSM_ID_TYPE,W <: Real}
weights_from_path(g::OSMGraph{U,T,W}, path::Vector{T}; weights=g.weights)::Vector{W} where {U <: DEFAULT_OSM_INDEX_TYPE,T <: DEFAULT_OSM_ID_TYPE,W <: Real}
Extracts edge weights from a path using the weight matrix stored in `g.weights` unless
a different matrix is passed to the `weights` kwarg.
Expand All @@ -230,7 +230,7 @@ a different matrix is passed to the `weights` kwarg.
# Return
- `Vector{W}`: Array of edge weights, distances are in km, time is in hours.
"""
function weights_from_path(g::OSMGraph{U,T,W}, path::Vector{T}; weights=g.weights)::Vector{W} where {U <: Integer,T <: DEFAULT_OSM_ID_TYPE,W <: Real}
function weights_from_path(g::OSMGraph{U,T,W}, path::Vector{T}; weights=g.weights)::Vector{W} where {U <: DEFAULT_OSM_INDEX_TYPE,T <: DEFAULT_OSM_ID_TYPE,W <: Real}
return [weights[g.node_to_index[path[i]], g.node_to_index[path[i + 1]]] for i in 1:length(path) - 1]
end

Expand Down
2 changes: 1 addition & 1 deletion src/subgraph.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
osm_subgraph(g::OSMGraph{U, T, W},
vertex_list::Vector{U}
)::OSMGraph where {U <: Integer, T <: Integer, W <: Real}
)::OSMGraph where {U <: DEFAULT_OSM_INDEX_TYPE, T <: DEFAULT_OSM_ID_TYPE, W <: Real}
Create an OSMGraph representing a subgraph of another OSMGraph containing
specified vertices.
Expand Down

0 comments on commit a562b27

Please sign in to comment.