summaryrefslogtreecommitdiffstats
path: root/server.py
diff options
context:
space:
mode:
authorMax Bringemo <maxbr167@student.liu.se>2020-12-15 11:03:23 +0100
committerMax Bringemo <maxbr167@student.liu.se>2020-12-15 11:03:23 +0100
commitace809ebf6f38b1d4fc9f4ec59890d738b7ca583 (patch)
treea5902829ffd96d72f6266b52bf0c303a212e9b9b /server.py
parenteeb8250dd7acbd7318d83195145e4ed0ce84011b (diff)
downloadtdde25-ace809ebf6f38b1d4fc9f4ec59890d738b7ca583.tar.gz
updated server to use grid-search
Diffstat (limited to 'server.py')
-rw-r--r--server.py16
1 files 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)