diff options
| author | Stefan Hansson <steha708@edu.liu.se> | 2020-11-16 13:55:06 +0100 |
|---|---|---|
| committer | Newbyte <steha708@liu.se> | 2020-12-15 18:23:53 +0100 |
| commit | fe0d3bcc28f723e97cfa4105bed83eb8bb85bbe5 (patch) | |
| tree | f9992628c6e82ee0175c072e4da23e22dcd1e000 /server.py | |
| parent | 6c8acb4f4eabb20da41b941158bf52038035699f (diff) | |
| download | tdde25-fe0d3bcc28f723e97cfa4105bed83eb8bb85bbe5.tar.gz | |
wip
Diffstat (limited to 'server.py')
| -rw-r--r-- | server.py | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -47,17 +47,28 @@ def show_unconnected_nodes(): @post('/shortest-path') def shortest_path(body): body = json.loads(body) +<<<<<<< HEAD source_id = algorithms.grid_search(grid, store.Node(-1, body['lat1'], body['lng1'])) target_id = algorithms.grid_search(grid, store.Node(-1, body['lat2'], body['lng2'])) - - path = algorithms.find_shortest_path(nodes, source_id, target_id) - print(path) - response = { - "path": [(nodes[node].lat, nodes[node].lng) for node in path]} +======= + transport_mode = body['transport_mode'] + + source_id = algorithms.get_closest_node_id(nodes, + store.Node(-1, body['lat1'], + body['lng1']) + transport_mode) + target_id = algorithms.get_closest_node_id(nodes, + store.Node(-1, body['lat2'], + body['lng2']) + transport_mode) +>>>>>>> 532c0cb... wip + + path = algorithms.find_shortest_path(nodes, source_id, target_id, transport_mode) + response = {"path": [(nodes[node].lat, nodes[node].lng) for node in path]} return json.dumps(response) |
