forked from DeloitteOptimalReality/LightOSM.jl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.jl
38 lines (31 loc) · 1010 Bytes
/
example.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using LightOSM, Plots, GeoInterfaceRecipes
using StatsBase: sample
g = graph_from_download(
:place_name,
place_name="tiergarten, berlin germany",
network_type=:drive
)
sg = simplify_graph(g)
# Set plot size
size = (1920, 1080)
# Show original nodes
plot(g; size)
savefig("original_nodes")
# Show relevant nodes
plot(sg; size)
savefig("relevant_nodes")
osm_ids = sample(collect(values(sg.nodes)), 200)
for source in osm_ids
for target in osm_ids
path = shortest_path(g, source, target)
path_simplified = shortest_path(sg, source, target)
if isnothing(path) || isnothing(path_simplified)
continue
end
path_length = total_path_weight(g, path)
path_simplified_length = total_path_weight(sg, path_simplified)
if !isapprox(path_length, path_simplified_length)
error("Path from $source to $target is $path_length in the original graph and $path_simplified_length in the simplified graph")
end
end
end