@gdalle thanks for the link, I read it again. However, the issue is getting more strange now, if I don’t specify maxdist
it copies the same routes n times. If I specify a maxdist
it just gives back one!! For example:
using Graphs
using Random
using Parameters
using OpenStreetMapX
using Graphs
using PyCall
using Colors
const flm = pyimport("folium");
using OpenStreetMapXPlot
m = get_map_data(OSM_File_path, use_cache=false, trim_to_connected_graph=true );
println("The map contains $(length(m.nodes)) nodes")
println("The map boundary is $((m.bounds)) nodes")
a,b = [point_to_nodes(generate_point_in_bounds(m), m) for _ in 1:2]
routes = Vector{Vector{Int}}()
route_times = Vector{Float64}()
route_times = yen_k_shortest_paths(m.g, m.v[a],m.v[b], m.w, 5).dists
routes = yen_k_shortest_paths(m.g, m.v[a],m.v[b], m.w, 5).paths
The output is:
5-element Vector{Vector{Int64}}:
[323, 6886, 6887, 7219, 5051, 2439, 2440, 1379, 1371, 1401 … 904, 1012, 917, 916, 988, 2725, 924, 923, 922, 6881]
[323, 6886, 6887, 7219, 5051, 2439, 2440, 1379, 1371, 1401 … 904, 1012, 917, 916, 988, 2725, 924, 923, 922, 6881]
[323, 6886, 6887, 7219, 5051, 2439, 2440, 1379, 1371, 1401 … 904, 1012, 917, 916, 988, 2725, 924, 923, 922, 6881]
[323, 6886, 6887, 7219, 5051, 2439, 2440, 1379, 1371, 1401 … 904, 1012, 917, 916, 988, 2725, 924, 923, 922, 6881]
[323, 6886, 6887, 7219, 5051, 2439, 2440, 1379, 1371, 1401 … 904, 1012, 917, 916, 988, 2725, 924, 923, 922, 6881]
An they are all infact the samething. To check that, I ran:
aa = [n for n in routes[1]]
bb = [n for n in routes[1]]
aa==bb
It gives true
I’ve tried to visuliaze this from @pszufe tutorila [here] to see if there’s really one path??(OpenStreetMapX_tutorial), But it return a key error which I don’t know what does it mean here:
fm = flm.Map()
colrs = distinguishable_colors(10, [RGB(1,0.6,0.5)])
for k=1:5
locs = [LLA(m.nodes[n],m.bounds) for n in routes[k]]
info = "The route of Car $k\n<BR>"*
"Length: $(length(routes[k])) nodes\n<br>" *
"From: $(routes[k][1]) $(round.((locs[1].lat, locs[1].lon),digits=4))\n<br>" *
"To: $(routes[k][end]) $(round.((locs[end].lat, locs[end].lon),digits=4))"
flm.PolyLine(
[(loc.lat, loc.lon) for loc in locs ],
popup=info,
tooltip=info,
color="#$(hex(colrs[k]))"
).add_to(fm)
end
MAP_BOUNDS = [(m.bounds.min_y,m.bounds.min_x),(m.bounds.max_y,m.bounds.max_x)]
flm.Rectangle(MAP_BOUNDS, color="black",weight=6).add_to(fm)
fm.fit_bounds(MAP_BOUNDS)
fm
Key Error
KeyError: key 323 not found
Stacktrace:
[1] getindex(h::Dict{Int64, ENU}, key::Int64)
@ Base .\dict.jl:498
[2] (::var"#99#101")(n::Int64)
@ Main .\none:0
[3] iterate
@ .\generator.jl:47 [inlined]
[4] collect(itr::Base.Generator{Vector{Int64}, var"#99#101"})
@ Base .\array.jl:787
[5] top-level scope