-
Notifications
You must be signed in to change notification settings - Fork 1
/
area.go
67 lines (57 loc) · 1.44 KB
/
area.go
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
64
65
66
67
package h3geodist
// Supported H3 resolutions.
const (
Level0 = iota // number of unique indexes 122
Level1 // number of unique indexes 842
Level2 // number of unique indexes 5882
Level3 // number of unique indexes 41162
Level4 // number of unique indexes 288122
Level5 // number of unique indexes 2016842
Level6 // number of unique indexes 14117882
)
// Table of cell areas for H3 resolutions.
var cellAreas = map[int]uint{
Level0: 122,
Level1: 842,
Level2: 5882,
Level3: 41162,
Level4: 288122,
Level5: 2016842,
Level6: 14117882,
}
// Level0Area returns the area (km2) for level 0.
func Level0Area() uint {
return cellArea(Level0)
}
// Level1Area returns the area (km2) for level 1.
func Level1Area() uint {
return cellArea(Level1)
}
// Level2Area returns the area (km2) for level 2.
func Level2Area() uint {
return cellArea(Level2)
}
// Level3Area returns the area (km2) for level 3.
func Level3Area() uint {
return cellArea(Level3)
}
// Level4Area returns the area (km2) for level 4.
func Level4Area() uint {
return cellArea(Level4)
}
// Level5Area returns the area (km2) for level 5.
func Level5Area() uint {
return cellArea(Level5)
}
// Level6Area returns the area (km2) for level 6.
func Level6Area() uint {
return cellArea(Level6)
}
// cellArea returns the area (km2) for specified level.
func cellArea(level int) uint {
area, found := cellAreas[level]
if !found {
return 0
}
return area
}