# Get route length 0 wile trying to caculate route between two given locations using package OpenStreetMapX

**URL:** <https://discourse.julialang.org/t/get-route-length-0-wile-trying-to-caculate-route-between-two-given-locations-using-package-openstreetmapx/30220>\
**Category:** General Usage\
**Created:** [October 23, 2019, 1:53pm UTC](https://discourse.julialang.org/t/get-route-length-0-wile-trying-to-caculate-route-between-two-given-locations-using-package-openstreetmapx/30220 "2019-10-23T13:53:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [October 23, 2019, 1:53pm UTC](https://discourse.julialang.org/t/get-route-length-0-wile-trying-to-caculate-route-between-two-given-locations-using-package-openstreetmapx/30220/1 "2019-10-23T13:53:02Z")

</div>

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](https://www.geofabrik.de/data/download.html)  
Then, when I calculate the route between these two points, I got 0. Any comments are greatly appreciated indeed!

code:

```julia
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 )

```
