11using LightOSM, Plots, GeoInterfaceRecipes
2+ using StatsBase: sample
23
34g = graph_from_download (
45 :place_name ,
56 place_name= " tiergarten, berlin germany" ,
6- network_type= :bike
7+ network_type= :drive
78)
89sg = simplify_graph (g)
910
10- # check for missing edges
11- plot (g, color= :red , linewidth= 0.8 , size= (800 , 800 ))
12- plot! (sg, linewidth= 1.1 , color= :black )
13- savefig (" edge_validation" )
11+ # Set plot size
12+ size = (1920 , 1080 )
1413
15- # show original nodes
16- plot (sg)
17- plot! (node_gdf (g). geom, color= :red , markersize= 2.2 )
14+ # Show original nodes
15+ plot (g; size)
1816savefig (" original_nodes" )
1917
20- # show relevant nodes
21- plot (sg)
22- plot! (node_gdf (sg). geom, color= :green , markersize= 2.2 )
23- savefig (" relevant_nodes" )
18+ # Show relevant nodes
19+ plot (sg; size)
20+ savefig (" relevant_nodes" )
21+
22+
23+
24+ osm_ids = sample (collect (values (sg. nodes)), 200 )
25+ for source in osm_ids
26+ for target in osm_ids
27+ path = shortest_path (g, source, target)
28+ path_simplified = shortest_path (sg, source, target)
29+ if isnothing (path) || isnothing (path_simplified)
30+ continue
31+ end
32+ path_length = total_path_weight (g, path)
33+ path_simplified_length = total_path_weight (sg, path_simplified)
34+ if ! isapprox (path_length, path_simplified_length)
35+ println (" Path from $source to $target is $path_length in the original graph and $path_simplified_length in the simplified graph" )
36+ end
37+ end
38+ end
0 commit comments