parse the runways as well

This commit is contained in:
Sven Czarnian
2021-10-12 22:27:02 +02:00
parent c07e767ef8
commit 5e6301f749

View File

@@ -3,6 +3,7 @@
import sys import sys
from aman.types.ArrivalRoute import ArrivalRoute from aman.types.ArrivalRoute import ArrivalRoute
from aman.types.Runway import Runway
from aman.types.Waypoint import Waypoint from aman.types.Waypoint import Waypoint
class SctEseFormat: class SctEseFormat:
@@ -32,9 +33,20 @@ class SctEseFormat:
sys.exit(-1) sys.exit(-1)
return Waypoint(split[nameIdx], Waypoint.dms2dd(split[latitudeIdx]), Waypoint.dms2dd(split[longitudeIdx])) return Waypoint(split[nameIdx], Waypoint.dms2dd(split[latitudeIdx]), Waypoint.dms2dd(split[longitudeIdx]))
def extractWaypoints(self, sctFilepath : str): def parseRunway(runway : str):
split = list(filter(None, runway.split(' ')))
if 9 != len(split) or '' == split[8]:
return None, None, None
waypoint0 = Waypoint(split[0], Waypoint.dms2dd(split[4]), Waypoint.dms2dd(split[5]))
waypoint1 = Waypoint(split[1], Waypoint.dms2dd(split[6]), Waypoint.dms2dd(split[7]))
return split[8], Runway(waypoint0, waypoint1), Runway(waypoint1, waypoint0)
def extractSctInformation(self, sctFilepath : str):
config = SctEseFormat.readFile(sctFilepath) config = SctEseFormat.readFile(sctFilepath)
foundAirports = False foundAirports = False
foundRunways = False
foundVOR = False foundVOR = False
foundNDB = False foundNDB = False
foundFix = False foundFix = False
@@ -48,6 +60,8 @@ class SctEseFormat:
foundFix = True foundFix = True
elif 'AIRPORT' == key: elif 'AIRPORT' == key:
foundAirports = True foundAirports = True
elif 'RUNWAY' == key:
foundRunways = True
if False == foundVOR: if False == foundVOR:
sys.stderr.write('Unable to find VOR-entries in the sector file') sys.stderr.write('Unable to find VOR-entries in the sector file')
@@ -61,6 +75,9 @@ class SctEseFormat:
if False == foundAirports: if False == foundAirports:
sys.stderr.write('Unable to find AIRPORT-entries in the sector file') sys.stderr.write('Unable to find AIRPORT-entries in the sector file')
sys.exit(-1) sys.exit(-1)
if False == foundRunways:
sys.stderr.write('Unable to find RUNWAY-entries in the sector file')
sys.exit(-1)
# extract all waypoints # extract all waypoints
for waypoint in config['VOR']: for waypoint in config['VOR']:
@@ -75,9 +92,18 @@ class SctEseFormat:
# extract the airports # extract the airports
for airport in config['AIRPORT']: for airport in config['AIRPORT']:
airport = SctEseFormat.parseWaypoint(airport,0, 2, 3) airport = SctEseFormat.parseWaypoint(airport, 0, 2, 3)
self.airports.setdefault(airport.name, []).append(airport) self.airports.setdefault(airport.name, []).append(airport)
# extract the runways
for runway in config['RUNWAY']:
airport, runway0, runway1 = SctEseFormat.parseRunway(runway)
if None != airport:
if not airport in self.runways:
self.runways.setdefault(airport, [])
self.runways[airport].append(runway0)
self.runways[airport].append(runway1)
def parseArrivalRoute(self, route : str, airport : Waypoint): def parseArrivalRoute(self, route : str, airport : Waypoint):
# split the route and validate that it is a STAR for the airport # split the route and validate that it is a STAR for the airport
split = route.split(':') split = route.split(':')
@@ -147,6 +173,7 @@ class SctEseFormat:
self.arrivalRoutes = {} self.arrivalRoutes = {}
self.waypoints = {} self.waypoints = {}
self.airports = {} self.airports = {}
self.runways = {}
self.extractWaypoints(sctFilepath) self.extractSctInformation(sctFilepath)
self.extractArrivalRoutes(eseFilepath, airport, allowedRoutes) self.extractArrivalRoutes(eseFilepath, airport, allowedRoutes)