From ace809ebf6f38b1d4fc9f4ec59890d738b7ca583 Mon Sep 17 00:00:00 2001 From: Max Bringemo Date: Tue, 15 Dec 2020 11:03:23 +0100 Subject: updated server to use grid-search --- server.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/server.py b/server.py index 4ba7506..6786125 100644 --- a/server.py +++ b/server.py @@ -21,7 +21,9 @@ def index(): @get('/show-area') def show_area(): rect = dict() - for (k, node) in enumerate(store.select_nodes_in_rectangle(nodes, 58.3984, 58.3990, 15.5733, 15.576)): + for (k, node) in enumerate( + store.select_nodes_in_rectangle(nodes, 58.3984, 58.3990, 15.5733, + 15.576)): rect[node.id] = node.coord_tuple() return json.dumps(rect) @@ -38,12 +40,12 @@ def favicon(): @post('/shortest-path') def shortest_path(body): body = json.loads(body) - source_id = algorithms.get_closest_node_id(nodes, - store.Node(-1, body['lat1'], - body['lng1'])) - target_id = algorithms.get_closest_node_id(nodes, - store.Node(-1, body['lat2'], - body['lng2'])) + 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) -- cgit v1.2.1