diff options
| author | Gustav Sörnäs <gusso230@student.liu.se> | 2021-01-06 18:55:57 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gusso230@student.liu.se> | 2021-01-06 18:57:50 +0100 |
| commit | b52a7325c1e0d1b6e87e2bbe96ebafcc22be167a (patch) | |
| tree | af931aef7be808a9162016c52b98b4bfa19fc643 /algorithms.py | |
| parent | 1afff10fa0418647f35fdfc1ec95bff92e37ec11 (diff) | |
| download | tdde25-b52a7325c1e0d1b6e87e2bbe96ebafcc22be167a.tar.gz | |
pep8
Diffstat (limited to 'algorithms.py')
| -rw-r--r-- | algorithms.py | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/algorithms.py b/algorithms.py index 9f3fd78..e2da8f0 100644 --- a/algorithms.py +++ b/algorithms.py @@ -10,8 +10,7 @@ def length_haversine(p1, p2): lat1, lng1, lat2, lng2 = map(math.radians, [lat1, lng1, lat2, lng2]) dlat = lat2 - lat1 dlng = lng2 - lng1 - a = math.sin(dlat / 2) ** 2 + math.cos(lat1) * math.cos(lat2) * math.sin( - dlng / 2) ** 2 + a = math.sin(dlat / 2) ** 2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlng / 2) ** 2 c = 2 * math.asin(math.sqrt(a)) return 6372797.560856 * c # return the distance in meters @@ -33,7 +32,6 @@ def grid_search(grid, source_node): closest_nodes.append(get_closest_node(tile_nodes, source_node)) closest_node_id = get_closest_node(closest_nodes, source_node).id - return closest_node_id @@ -56,14 +54,10 @@ def look_for_nodes(offset, grid, source_key): tiles = [] for i in range(-offset, offset + 1): for j in range(-offset, offset + 1): - if i in (-offset, offset) or j in (-offset, offset): - key = (source_key[0] + j, source_key[1] + i) - if key in grid.keys(): tiles.append(grid[key]) - return tiles |
