diff options
| author | Max Bringemo <maxbr167@student.liu.se> | 2020-12-15 11:03:23 +0100 |
|---|---|---|
| committer | Max Bringemo <maxbr167@student.liu.se> | 2020-12-15 11:03:23 +0100 |
| commit | ace809ebf6f38b1d4fc9f4ec59890d738b7ca583 (patch) | |
| tree | a5902829ffd96d72f6266b52bf0c303a212e9b9b /server.py | |
| parent | eeb8250dd7acbd7318d83195145e4ed0ce84011b (diff) | |
| download | tdde25-ace809ebf6f38b1d4fc9f4ec59890d738b7ca583.tar.gz | |
updated server to use grid-search
Diffstat (limited to 'server.py')
| -rw-r--r-- | server.py | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -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) |
