-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
79 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,30 @@ | ||
using OpenStreetMapX | ||
|
||
mapfile = "mymap.osm"; | ||
mapfile = "reno_east3.osm"; # This file can be found in test/data folder | ||
datapath = "/home/ubuntu/"; | ||
map_data = OpenStreetMapX.get_map_data(datapath, mapfile); | ||
map_data = get_map_data(datapath, mapfile,use_cache=false); | ||
|
||
function generate_point_in_bounds(map_data::OpenStreetMapX.MapData) | ||
boundaries = map_data.bounds | ||
(rand() * (boundaries.max_y - boundaries.min_y) + boundaries.min_y, | ||
rand() * (boundaries.max_x - boundaries.min_x) + boundaries.min_x) | ||
end | ||
|
||
function point_to_nodes(point::Tuple{Float64,Float64}, map_data::OpenStreetMapX.MapData) | ||
point = OpenStreetMapX.LLA(point[1],point[2]) | ||
point = OpenStreetMapX.nearest_node(map_data.nodes,OpenStreetMapX.ENU(point, map_data.bounds), map_data.network) | ||
end | ||
using Random | ||
Random.seed!(0); | ||
|
||
origin = generate_point_in_bounds(map_data); | ||
destination = generate_point_in_bounds(map_data); | ||
|
||
pointA = point_to_nodes(origin, map_data) | ||
pointB = point_to_nodes(destination, map_data) | ||
|
||
shortest_route, shortest_distance, shortest_time = OpenStreetMapX.shortest_route(map_data.network, pointA, pointB) | ||
fastest_route, fastest_distance, fastest_time = OpenStreetMapX.fastest_route(map_data.network, pointA, pointB) | ||
shortest_route1, shortest_distance1, shortest_time1 = shortest_route(map_data, pointA, pointB) | ||
fastest_route1, fastest_distance1, fastest_time1 = fastest_route(map_data, pointA, pointB) | ||
|
||
println("shortest_route nodes: ",shortest_route) | ||
println("fastest route nodes: ",fastest_route) | ||
println("shortest_route nodes: ",shortest_route1) | ||
println("fastest route nodes: ",fastest_route1) | ||
|
||
### Create this file if you want to test routing with Google API | ||
### The file should only contain your Google API key | ||
google_api_file = joinpath(datapath,"googleapi.key") | ||
|
||
if isfile(google_api_file) | ||
google_api_key = readlines(google_api_file)[1] | ||
google_route = OpenStreetMapX.get_google_route(pointA, pointB,map_data,google_api_key)[1] | ||
google_route = get_google_route(pointA, pointB,map_data,google_api_key)[1] | ||
println("Google API route nodes : ",google_route) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters