I have two locations with latitude and longitude pair as the following:
loc1 = (35.96395340992261,25.08696560352753)
loc2 = (69.37249071020585,35.60655488064029)
Openstreetmap data is obtained from the link: GEOFABRIK // Downloads
Then, when I calculate the route between these two points, I got 0. Any comments are greatly appreciated indeed!
code:
using OpenStreetMapX
md = OpenStreetMapX.get_map_data("/home/s.osm")
function fetchRouteInfo!(md::MapData, routeChoice::String, LLAloc1::OpenStreetMapX.LLA, LLAloc2::OpenStreetMapX.LLA)
# figure out this later, try original version with function point_to_nodes instead
# node1ID = LLAloc2nearestNdID(md, LLAloc1) # the id of the nearest node to LLAloc1 in md
# node2ID = LLAloc2nearestNdID(md, LLAloc2) # the id of the nearest node to LLAloc2 in md
println("location 1: ", LLAloc1.lon, "*", LLAloc1.lat)
println("location 2: ", LLAloc2.lon, "*", LLAloc2.lat)
node1ID = OpenStreetMapX.point_to_nodes(LLAloc1,md)
node2ID = OpenStreetMapX.point_to_nodes(LLAloc2,md)
if routeChoice == "shortest"
ndIDs, rDist, rTime = OpenStreetMapX.shortest_route(md,node1ID,node2ID) # no shortest-path algorithm is provided, so aStar algorithm is used; but apparently it is really really slow; # so I need to find a new algorithm to at least improve it
elseif routeChoice == "fastest"
ndIDs, rDist, rTime = OpenStreetMapX.fastest_route(md,node1ID,node2ID)
end
vtsIDs = Array{Int}(undef, length(ndIDs))
for i in 1:length(ndIDs)
vtsIDs[i] = md.v[ndIDs[i]] # md.v: node id => graph vertex id
end
println("ndIDs length: ", length(ndIDs))
end
# loc1 = OpenStreetMapX.LLA(51.60294961535597, 30.789688389286564)
# loc2 = OpenStreetMapX.LLA(50.74702708216419, 21.350926433935673)
loc1 = OpenStreetMapX.LLA(35.96395340992261,25.08696560352753 )
loc2 = OpenStreetMapX.LLA(69.37249071020585,35.60655488064029 )
fetchRouteInfo!(md, "shortest", loc1, loc2 )