diff options
Diffstat (limited to 'server.py')
| -rw-r--r-- | server.py | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -30,10 +30,13 @@ def shortest_path(body): target_id = algorithms.get_closest_node_id(nodes, 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]} + edges = [] + for i in range(len(path)-1): + edges.append({"path": [[nodes[path[i]].lat, nodes[path[i]].lng], + [nodes[path[i+1]].lat, nodes[path[i+1]].lng]], + "color": "#ff0000"}) - return json.dumps(response) + return json.dumps({"edges": edges}) run_server() |
