-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlocations.py
More file actions
35 lines (27 loc) · 803 Bytes
/
locations.py
File metadata and controls
35 lines (27 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
grid = [
[ 524, 523, 522, 521, 520, 519, 518, 517, 516 ],
[ 546, 546, 531, 530, 529, 528, 527, 526, 525 ],
[ 546, 546, 537, 536, 535, 534, 533, 532, 0 ]
]
mappings = {}
def make_grid_mappings():
rownum = 0
for row in grid:
colnum = 0
for col in row:
mappings[grid[rownum][colnum]] = (rownum, colnum)
colnum += 1
rownum += 1
def gridno_to_coord(gridno):
make_grid_mappings()
return mappings[gridno]
# say lat varies from 36.6 to 36.8
# long from -121.0 to -121.8 (am I mixing e and w?)
def find_gridno(lat, long):
gridheight = len(grid)
gridwidth = len(grid[0])
# etc. for now. must sleep.
print gridno_to_coord(534)
(row, col) = gridno_to_coord(534)
# 1 west, 1 north
print grid[row - 1][col - 1]