-
Notifications
You must be signed in to change notification settings - Fork 0
/
referencetrackshandler.py
82 lines (58 loc) · 2.37 KB
/
referencetrackshandler.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
import progaconstants
import simplejson as json
from referencetrack import Point3D, ReferenceTrack
import pdb
import cherrypy
"""
The ReferenceTracksHandler provides the information about the stored intents i.e. reference tracks.
It abstracts from the way this information is stored. For the moment reference tracks are stored inside
a json file. they should be in a geographic database, ideally we would use neo4j spatial
"""
class ReferenceTracksHandler(object):
def __init__(self, scenario_name):
allfile = ""
complete_path = "./db/repository_uncertainty_l1.json"
#cherrypy.log("scenario name: %s"%(scenario_name))
if scenario_name == "sc_4_uncertainty_l1":
#cherrypy.log("loading repository for uncertainty l1", context="UNCERTAINTY")
complete_path = "./db/repository_uncertainty_l1.json"
if scenario_name == "sc_4_uncertainty_l2":
#cherrypy.log("loading repository for uncertainty l2", context="UNCERTAINTY")
complete_path = "./db/repository_uncertainty_l2.json"
if scenario_name == "sc_4_uncertainty_l3":
#cherrypy.log("loading repository for uncertainty l3", context="UNCERTAINTY")
complete_path = "./db/repository_uncertainty_l3.json"
#cherrypy.log("loading complete path %s"%(complete_path), context="UNCERTAINTY")
with open(complete_path) as referencetracksfile:
for line in referencetracksfile:
allfile += line
print allfile
self.jsonobj = json.loads(allfile)
"""
Provides all the stored intents and assign them a flight_id which is the given one as parameter
"""
def getAllIntents(self, track_id):
ret = []
reference_tracks = self.jsonobj['reference_tracks']
for rt in reference_tracks:
rt_id = rt['reference_track_id']
points = rt['turning_points']
p_list = []
for p in points:
p_list.append(Point3D(p['lon'],p['lat'],p['h']))
refTrack = ReferenceTrack(p_list,track_id)
#pdb.set_trace()
refTrack.refTrackID = rt_id
ret.append(refTrack)
return ret
def getReferenceTrack(self, referenceTrackID):
reference_tracks = self.jsonobj['reference_tracks']
ret = None
flight_intent_point_list = []
for rt in reference_tracks:
if rt['reference_track_id']==referenceTrackID:
turning_points = rt['turning_points']
for item in turning_points:
flight_intent_point_list.append(Point3D(item['lon'],item['lat'],item['h']))
ret = ReferenceTrack(flight_intent_point_list)
return ret