@@ -66,31 +66,31 @@ Build a new graph which simplifies the topology of osmg.graph.
66
66
The resulting graph only contains intersections and dead ends from the original graph.
67
67
The geometry of the contracted nodes is kept in the edge_gdf DataFrame
68
68
"""
69
- function simplify_graph (osmg:: OSMGraph{U, T, W} ) where {U, T, W}
70
- g = osmg. graph
71
- relevant_nodes = collect (endpoints (g))
69
+ function simplify_graph (g:: OSMGraph{U, T, W} ) where {U, T, W}
70
+ relevant_nodes = collect (endpoints (g. graph))
72
71
n_relevant = length (relevant_nodes)
73
72
graph = DiGraph (n_relevant)
74
- weights = similar (osmg . weights, (n_relevant, n_relevant))
73
+ weights = similar (g . weights, (n_relevant, n_relevant))
75
74
node_coordinates = Vector {Vector{W}} (undef, n_relevant)
76
75
node_to_index = OrderedDict {T,U} ()
77
76
index_to_node = OrderedDict {U,T} ()
78
77
79
78
index_mapping = Dict {U,U} ()
80
79
for (new_i, old_i) in enumerate (relevant_nodes)
81
80
index_mapping[old_i] = new_i
82
- node_coordinates[new_i] = osmg . node_coordinates[old_i]
83
- node = osmg . index_to_node[old_i]
81
+ node_coordinates[new_i] = g . node_coordinates[old_i]
82
+ node = g . index_to_node[old_i]
84
83
index_to_node[new_i] = node
85
84
node_to_index[node] = new_i
86
85
end
87
86
88
87
edges = Dict {NTuple{3,U}, Vector{U}} ()
88
+ edge_to_way = Dict {NTuple{3,U}, Vector{T}} ()
89
89
edge_count = Dict {Tuple{U,U}, Int} ()
90
- for path in paths_to_reduce (g)
90
+ for path in paths_to_reduce (g. graph )
91
91
u = index_mapping[first (path)]
92
92
v = index_mapping[last (path)]
93
- path_weight = total_weight (osmg , path)
93
+ path_weight = total_weight (g , path)
94
94
if add_edge! (graph, (u, v))
95
95
key = 0
96
96
weights[u, v] = path_weight
@@ -101,15 +101,11 @@ function simplify_graph(osmg::OSMGraph{U, T, W}) where {U, T, W}
101
101
weights[u, v] = min (path_weight, weights[u, v])
102
102
end
103
103
edges[u,v,key] = path
104
- end
105
-
106
- edge_to_way = Dict {NTuple{3,U}, Vector{T}} ()
107
- for (edge, path) in edges
108
- edge_to_way[edge] = ways_in_path (osmg, path)
104
+ edge_to_way[u,v,key] = ways_in_path (g, path)
109
105
end
110
106
111
107
return SimplifiedOSMGraph (
112
- osmg ,
108
+ g ,
113
109
node_coordinates,
114
110
node_to_index,
115
111
index_to_node,
0 commit comments