-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtiling.txt
64 lines (46 loc) · 1.48 KB
/
tiling.txt
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Tiling process
/base_url/zoom/x/y.json
zoom 0 is full world
runs from -180 to 180 longitude
runs from -90 to 270 latitude
size of tile is 360/2**zoom level
west end of tile = -180+(x*(size)/2)
east end of tile = west end + size
south = -90+(y*(size)/2)
north = south + size
three ways to represent data:
1. raw data store
2. pre-tile representation (optional, goal)
3. actual json tile
cells per tile, must be even, 10x10, should not be hardcoded
overall code structure:
1. database implementation for data
1a. generate random test data
1b. use sqlite for now
2. generating tiles
for pt in pts:
for tiles containing pt:
write pt to file
write out all tiles
calculating which tiles a point is in:
tile.west < point.lng < tile.east
tile.south < point.lat < tile.north
-180+(x*(360/(2**(z+1))) = point.lng
(x*(360/(2**(z+1))) = point.lng+180
x = (point.lng+180)/(360/(2**(z+1)))
y = (point.lat+ 90)/(360/(2**(z+1)))
take floor x, you just got tile index!
(using current settings for defaultSettings.py)
for zoom in range(10):
xf = (point.lng+180)/(360/(2**(z+1)))
yf = (point.lat+ 90)/(360/(2**(z+1)))
xmax = math.floor(xf)
ymax = math.floor(yf)
xmin = max(0,xmax-1)
ymin = max(0,ymax-1)
xcell = math.floor(((xf-xmax)*CELLS_PER_TILE)*2)
ycell = math.floor(((yf-ymax)*CELLS_PER_TILE)*2)
for x in range(xmin,xmax+1):
for y in range(ymin,ymax+1):
tile = tiles[zoom,x,y]
tile[xcell,ycell].process(point)