Skip to content
Snippets Groups Projects
Commit 6a05ba1a authored by markn92's avatar markn92
Browse files

wip

parent 067c10fd
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,6 @@ Added : ...@@ -11,7 +11,6 @@ Added :
- distance computation to estimate length of each ways (useful to compute the shortest path) - distance computation to estimate length of each ways (useful to compute the shortest path)
""" """
import copy import copy
import xml.sax import xml.sax
import logging import logging
...@@ -142,11 +141,11 @@ def read_osm(osm_xml_data, profile) -> OSMGraph: ...@@ -142,11 +141,11 @@ def read_osm(osm_xml_data, profile) -> OSMGraph:
}) })
# Complete the used nodes' information # Complete the used nodes' information
for n_id in G.nodes(): for n_id, data in G.nodes(data=True):
n = osm.nodes[n_id] n = osm.nodes[n_id]
G.nodes[n_id]['lat'] = n.lat data['lat'] = n.lat
G.nodes[n_id]['lon'] = n.lon data['lon'] = n.lon
G.nodes[n_id]['id'] = n.id data['id'] = n.id
G.insert_into_rtree(n_id) G.insert_into_rtree(n_id)
return G return G
......
...@@ -32,8 +32,6 @@ def haversine_distance(lon1, lat1, lon2, lat2, unit_m=True): ...@@ -32,8 +32,6 @@ def haversine_distance(lon1, lat1, lon2, lat2, unit_m=True):
def shortest_path(G, s: point, t: point, profile): def shortest_path(G, s: point, t: point, profile):
"""Calc A* shortest path.""" """Calc A* shortest path."""
_s = G.find_nearest(s)
_t = G.find_nearest(t)
def dist(u, v): def dist(u, v):
return haversine_distance( return haversine_distance(
...@@ -44,7 +42,7 @@ def shortest_path(G, s: point, t: point, profile): ...@@ -44,7 +42,7 @@ def shortest_path(G, s: point, t: point, profile):
unit_m=True unit_m=True
) / profile['maxspeed'] * ms_to_kmh ) / profile['maxspeed'] * ms_to_kmh
return nx.astar_path(G, _s, _t, heuristic=dist) return nx.astar_path(G, s, t, heuristic=dist)
def to_coordinates(G, path): def to_coordinates(G, path):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment