diff options
| author | Stefan Hansson <steha708@edu.liu.se> | 2020-12-16 09:20:12 +0100 |
|---|---|---|
| committer | Newbyte <steha708@liu.se> | 2020-12-16 09:20:12 +0100 |
| commit | dd50eb5818501eb45cdde745cf239ac12b13a04e (patch) | |
| tree | 1ff5da81c859b65b3883226a1507914c0ba4ec87 /server.py | |
| parent | a11a7b4cde5834781aa57e7f9c9a8a3a309d6411 (diff) | |
| download | tdde25-dd50eb5818501eb45cdde745cf239ac12b13a04e.tar.gz | |
Implement mode of transport
Diffstat (limited to 'server.py')
| -rw-r--r-- | server.py | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -52,15 +52,19 @@ def shortest_path(body): body = json.loads(body) transport_mode = body['transport_mode'] - source_id = algorithms.get_closest_node(grids[transport_mode], - store.Node(-1, body['lat1'], - body['lng1'])) - target_id = algorithms.get_closest_node(grids[transport_mode], - store.Node(-1, body['lat2'], - body['lng2'])) + relevant_grid = grids[transport_mode] + + source_id = algorithms.grid_search(relevant_grid, + store.Node(-1, body['lat1'], + body['lng1'])) + target_id = algorithms.grid_search(relevant_grid, + store.Node(-1, body['lat2'], + body['lng2'])) + + relevant_nodes = nodes[transport_mode] path = algorithms.find_shortest_path(nodes[transport_mode], source_id, target_id) - response = {"path": [(nodes[node].lat, nodes[node].lng) for node in path]} + response = {"path": [(relevant_nodes[node].lat, relevant_nodes[node].lng) for node in path]} return json.dumps(response) |
