1+ coordinates (node:: Node ) = node. location. lon, node. location. lat
2+
3+ function node_gdf (g:: OSMGraph )
4+ ids = collect (keys (g. nodes))
5+ geom = map (ids) do id
6+ coordinates (g. nodes[id])
7+ end
8+ return DataFrame (;id= ids, geom= createpoint .(geom))
9+ end
10+
11+ function highway_gdf (g:: OSMGraph )
12+ ids = collect (keys (g. highways))
13+ _way_coordinates (way) = map (way. nodes) do id
14+ coordinates (g. nodes[id])
15+ end
16+ geom = map (id -> _way_coordinates (g. highways[id]), ids)
17+ return DataFrame (;id= ids, geom= createlinestring .(geom))
18+ end
19+
20+ function node_gdf (sg:: SimplifiedOSMGraph )
21+ ids = collect (keys (sg. node_to_index))
22+ geom = map (ids) do id
23+ coordinates (sg. parent. nodes[id])
24+ end
25+ return DataFrame (;id= ids, geom= createpoint .(geom))
26+ end
27+
28+ highway_gdf (sg:: SimplifiedOSMGraph ) = highway_gdf (sg. parent)
29+
30+ function edge_gdf (sg:: SimplifiedOSMGraph )
31+ edge_ids = collect (keys (sg. edges))
32+ geom = map (edge_ids) do edge
33+ path = sg. edges[edge]
34+ reverse .(sg. parent. node_coordinates[path])
35+ end
36+ u, v, key = map (i -> getindex .(edge_ids, i), 1 : 3 )
37+ return DataFrame (;u, v, key, geom= createlinestring .(geom))
38+ end
0 commit comments