-
Notifications
You must be signed in to change notification settings - Fork 1
/
json_to_py.py
executable file
·170 lines (149 loc) · 5.19 KB
/
json_to_py.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import simplejson
with open("jsons/SUAScord.json","r")as f:
data = simplejson.load(f)
#print(data)
#for item in data['waypoints']:
# print(item)
def waypoints(lat_long):
# looks for 'latitude' 'longitude' 'altitude'
items = []
if lat_long == 'altitude': #altitude is in feet needs meters
x = len(data['waypoints'])
#print("there are " + str(x) + " waypoints")
i = 0
while i < x:
#print(str((data['waypoints'][i][lat_long])/3.281))
items.append((data['waypoints'][i][lat_long])/3.281)
i = i + 1
#print("End of the " + str(len(items)) + " " + lat_long + " list")
return items
else:
x = len(data['waypoints'])
#print("there are " + str(x) + " waypoints")
i = 0
while i < x:
#print(data['waypoints'][i][lat_long])
items.append(data['waypoints'][i][lat_long])
i = i + 1
#print("End of the " + str(len(items)) + " " + lat_long + " list")
return items
def boundary(lat_long):
items = []
#print(data['flyZones'][0]['boundaryPoints'])
x = len(data['flyZones'][0]['boundaryPoints'])
#print("there are " + str(x) + " boundaryPoints")
i = 0
while i < x:
#print(data['flyZones'][0]['boundaryPoints'][i][lat_long])
items.append(data['flyZones'][0]['boundaryPoints'][i][lat_long])
i = i + 1
#print("End of the " + str(len(items)) + " " + lat_long + " list")
return items
def grid_points(lat_long):
items = []
x = len(data['searchGridPoints'])
#print("there are " + str(x) + " searchGridPoints")
i = 0
while i < x:
#print(data['searchGridPoints'][i][lat_long])
items.append(data['searchGridPoints'][i][lat_long])
i = i + 1
#print("End of the " + str(len(items)) + " " + lat_long + " list")
return items
def lost_comms(lat_long):
#print(data['lostCommsPos'])
x = len(data['lostCommsPos'])
#print("there are " + str(x) + " lostCommsPos")
i = 0
#print(data['lostCommsPos'][lat_long])
items = data['lostCommsPos'][lat_long]
i = i + 1
#print("End of the " + str(len(items)) + " " + lat_long + " list")
return items
def air_drop_boundary(lat_long):
items = []
x = len(data['airDropBoundaryPoints'])
#print("there are " + str(x) + " airDropBoundaryPoints")
i = 0
while i < x:
#print(data['airDropBoundaryPoints'][i][lat_long])
items.append(data['airDropBoundaryPoints'][i][lat_long])
i = i + 1
#print("End of the " + str(len(items)) + " " + lat_long + " list")
return items
def stationaryObstacles(lat_long_radius_height):
items = []
x = len(data['stationaryObstacles'])
#print("there are " + str(x) + " stationaryObstacles for " + str(lat_long_radius_height))
i = 0
if lat_long_radius_height.lower() == 'radius':
while i < x:
#print(data['stationaryObstacles'][i][lat_long_radius_height])
g = data['stationaryObstacles'][i][lat_long_radius_height]
y = float(g/3.281)+1 #adding one meter so that the boundry
#print(str(y) + " meters " + str(i))
items.append(y)
#print(str(items[i]))
i = i + 1
elif lat_long_radius_height.lower() == 'height':
while i < x:
#print(data['stationaryObstacles'][i][lat_long_radius_height])
g = data['stationaryObstacles'][i][lat_long_radius_height]
y = float(g/3.281)+1
#print(str(y) + " meters " + str(i))
items.append(y)
#print(str(items[i]))
i = i + 1
else:
while i < x:
#print(data['stationaryObstacles'][i][lat_long_radius_height])
items.append((data['stationaryObstacles'][i][lat_long_radius_height]))
i = i + 1
#print("End of the " + str(len(items)) + " " + lat_long_radius_height + " list")
return items
def air_drop(lat_long):
items = []
x = len(data['airDropPos'])
i = 0
#print('Airdrop Position')
#print(data['airDropPos'][lat_long])
items.append(data['airDropPos'][lat_long])
i = i + 1
#print("End of the " + str(len(items)) + " " + lat_long + " list")
return items
def home(lat_long):
x = len(data['lostCommsPos'])
i = 0
#print(data['lostCommsPos'][lat_long])
items = data['lostCommsPos'][lat_long]
i = i + 1
#print("End of the " + str(len(items)) + " " + lat_long + " list")
return items
def UGV_drive(lat_long):
items = []
x = len(data['ugvDrivePos'])
i = 0
#print('UGV Drive')
#print(data['ugvDrivePos'][lat_long])
items.append(data['ugvDrivePos'][lat_long])
i = i + 1
#print("End of the " + str(len(items)) + " " + lat_long + " list")
return items
#waypoints('altitude')
#waypoints('latitude')
#waypoints('longitude')
#grid_points('latitude')
#grid_points('longitude')
#boundary('latitude')
#boundary('longitude')
#lost_comms('longitude')
#lost_comms('latitude')
#air_drop_boundary('latitude')
#air_drop_boundary('longitude')
#stationaryObstacles('latitude')
#stationaryObstacles('height')
#air_drop('latitude')
#air_drop('longitude')
#UGV_drive('latitude')
#UGV_drive('longitude')
#home('latitude')