-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathysfutils.py
56 lines (34 loc) · 1012 Bytes
/
ysfutils.py
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
# part of ysf_bridge
#
import math
def list_to_string(l):
return ''.join(chr(i) for i in l)
def calculateLocator(latitude, longitude):
locator = ''
if ((latitude < -90.0) or (latitude > 90.0)):
return "AA00AA"
if ((longitude < -360.0) or (longitude > 360.0)):
return "AA00AA";
latitude += 90.0
if (longitude > 180.0):
longitude -= 360.0
if (longitude < -180.0):
longitude += 360.0
longitude += 180.0
lon = math.floor(longitude / 20.0)
lat = math.floor(latitude / 10.0)
locator += chr(ord('A') + lon)
locator += chr(ord('A') + lat)
longitude -= lon * 20.0
latitude -= lat * 10.0
lon = math.floor(longitude / 2.0)
lat = math.floor(latitude / 1.0)
locator += chr(ord('0') + lon)
locator += chr(ord('0') + lat)
longitude -= lon * 2.0
latitude -= lat * 1.0
lon = math.floor(longitude / (2.0 / 24.0))
lat = math.floor(latitude / (1.0 / 24.0))
locator += chr(ord('a') + lon)
locator += chr(ord('a') + lat)
return locator