-
Notifications
You must be signed in to change notification settings - Fork 0
/
airport.py
68 lines (46 loc) · 1.88 KB
/
airport.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
---------- airport.py ----------
import networkx as nx
from functions import planTri, isPointInTri, distance
from filesManager import getAirportData
class Taxiway:
def __init__(self, nom, autorisation, sens, points):
self.nom = nom
self.aut = autorisation
self.sens = sens
self.pts = points
def __str__(self):
return str([self.nom, self.aut, self.sens, self.pts])
class Airport:
def __init__(self):
Points, Lignes, Pistes, Altitudes, Noms_Triangles, Coos_Triangles = getAirportData()
self.Points = Points # ['K05' '0' '2741,-243'] = [Nom point, Type, Coordonées]
self.Lignes = Lignes
self.Pistes = Pistes
self.Altitudes = Altitudes
self.Noms_Triangles = Noms_Triangles
self.Coos_Triangles = Coos_Triangles
self.Plans = {}
for T in self.Noms_Triangles:
self.Plans[T] = planTri(self.Coos_Triangles[T])
def triThePointIsIn(self, P):
for T in self.Noms_Triangles:
if isPointInTri(P, self.Coos_Triangles[T]): return T
return -1
def createAirportGraph(self):
G = nx.DiGraph()
for ligne in self.Lignes:
Pts = ligne.pts
G.add_nodes_from(nx.Graph(Pts))
for i in range(0, len(Pts) - 1):
P1, P2 = Pts[i], Pts[i+1]
d = distance(P1, P2)
G.add_edge(P1, P2, distance = d)
if ligne.sens == 'D': G.add_edge(P2, P1, distance = d)
for piste in self.Pistes:
Pts = piste[-2:]
G.add_nodes_from(nx.Graph(Pts))
for i in range(0, len(Pts) - 1):
P1, P2 = Pts[i], Pts[i+1]
d = distance(P1, P2)
G.add_edge(P1, P2, distance = d)
return G