Exemple #1
0
    def buildFixList(self):
        '''
        from the route build a fix list and from the fix list build a way point list
        '''
        self.wayPointsDict = {}
        wayPointsDb = WayPointsDatabase()
        assert (wayPointsDb.read())

        airportsDb = AirportsDatabase()
        assert airportsDb.read()

        runwaysDb = RunWayDataBase()
        assert runwaysDb.read()

        self.createFixList()
        for fix in self.getFix():
            wayPoint = wayPointsDb.getWayPoint(fix)
            if not (wayPoint is None) and isinstance(wayPoint, WayPoint):
                #print wayPoint
                self.wayPointsDict[fix] = wayPoint
            else:
                self.deleteFix(fix)

        self.arrivalRunway = runwaysDb.getFilteredRunWays(
            airportICAOcode=self.arrivalAirportICAOcode,
            runwayName=self.arrivalRunwayName)
        assert (not (self.arrivalRunway is None)
                and isinstance(self.arrivalRunway, RunWay))

        self.arrivalAirport = airportsDb.getAirportFromICAOCode(
            ICAOcode=self.arrivalAirportICAOcode)
        assert (not (self.arrivalAirport is None)
                and isinstance(self.arrivalAirport, Airport))

        self.departureRunway = runwaysDb.getFilteredRunWays(
            airportICAOcode=self.departureAirportICAOcode,
            runwayName=self.departureRunwayName)
        assert (not (self.departureRunway is None)
                and isinstance(self.departureRunway, RunWay))

        self.departureAirport = airportsDb.getAirportFromICAOCode(
            ICAOcode=self.departureAirportICAOcode)
        assert (not (self.departureAirport is None)
                and isinstance(self.departureAirport, Airport))

        #print self.className + ': fix list= ' + str(self.fixList)
        assert (self.allAnglesLessThan90degrees(minIntervalNautics=10.0))
            
            print '==================== aircraft found  ==================== '+ time.strftime("%c")
            acA320 =BadaAircraft(aircraftICAOcode, 
                                    acBd.getAircraftPerformanceFile(aircraftICAOcode),
                                    atmosphere,
                                    earth)
            print acA320
    
    print '====================  airport database ==================== '+ time.strftime("%c")
    airportsDB = AirportsDatabase()
    assert not(airportsDB is None)
    
    wayPointsDb = WayPointsDatabase()
    assert (wayPointsDb.read())

    initialWayPoint = wayPointsDb.getWayPoint('TOU')
    finalWayPoint = wayPointsDb.getWayPoint('ALIVA')
    print initialWayPoint.getBearingDegreesTo(finalWayPoint)
    print finalWayPoint.getBearingDegreesTo(initialWayPoint)
    
    ''' departure ground run => initial speed is null '''
    trueAirSpeedMetersSecond = 70.0
    elapsedTimeSeconds = 0.0
    acA320.setTrueAirSpeedMetersSecond(elapsedTimeSeconds, trueAirSpeedMetersSecond)
    acA320.setCurrentAltitudeSeaLevelMeters(elapsedTimeSeconds, 0.0) 
    
    greatCircle = GreatCircleRoute(initialWayPoint = initialWayPoint, 
                                    finalWayPoint = finalWayPoint,
                                    aircraft = acA320)
    greatCircle.computeGreatCircle()
    greatCircle.createKmlOutputFile()
    def buildFixList(self):
        '''
        from the route build a fix list and from the fix list build a way point list
        '''
        
        self.wayPointsDict = {}
        wayPointsDb = WayPointsDatabase()
        assert (wayPointsDb.read())
        
        airportsDb = AirportsDatabase()
        assert airportsDb.read()
        
        runwaysDb = RunWayDataBase()
        assert runwaysDb.read()
        
        #print self.className + ': ================ get Fix List ================='
        self.fixList = []
        index = 0
        for fix in self.strRoute.split('-'):
            fix = str(fix).strip()
            ''' first item is the Departure Airport '''
            if str(fix).startswith('ADEP'):
                ''' fix is the departure airport '''
                if index == 0:
                    ''' ADEP is the first fix of the route '''
                    if len(str(fix).split('/')) >= 2:
                        self.departureAirportIcaoCode = str(fix).split('/')[1]
                        self.departureAirport = airportsDb.getAirportFromICAOCode(ICAOcode = self.departureAirportIcaoCode)
                        print self.className + ': departure airport= {0}'.format( self.departureAirport)
    
                    self.departureRunwayName = ''
                    if len(str(fix).split('/')) >= 3:
                        self.departureRunwayName = str(fix).split('/')[2]
                        
                    if not(self.departureAirport is None):
                        self.departureRunway = runwaysDb.getFilteredRunWays(airportICAOcode = self.departureAirportIcaoCode, 
                                                                            runwayName = self.departureRunwayName)
                        print self.className + ': departure runway= {0}'.format(self.departureRunway)
                else:
                    raise ValueError (self.className + ': ADEP must be the first fix in the route!!!')

                
            elif  str(fix).startswith('ADES'):
                if index == (len(self.strRoute.split('-'))-1):
                    ''' ADES is the last fix of the route '''
                    if len(str(fix).split('/')) >= 2:
                        self.arrivalAirportIcaoCode = str(fix).split('/')[1]
                        self.arrivalAirport = airportsDb.getAirportFromICAOCode(ICAOcode = self.arrivalAirportIcaoCode)
                        print self.className + ': arrival airport= {0}'.format( self.arrivalAirport)
                    
                    self.arrivalRunwayName = ''
                    if len(str(fix).split('/')) >= 3:
                        self.arrivalRunwayName = str(fix).split('/')[2]
                    
                    if not(self.arrivalAirport is None):
                        self.arrivalRunway =  runwaysDb.getFilteredRunWays(airportICAOcode = self.arrivalAirportIcaoCode, 
                                                                           runwayName = self.arrivalRunwayName)
                        print self.className + ': arrival runway= {0}'.format(self.arrivalRunway)
                else:
                    raise ValueError (self.classeName + ': ADES must be the last fix of the route!!!' )

            else:
                ''' do not take the 1st one (ADEP) and the last one (ADES) '''
                constraintFound, levelConstraint, speedConstraint = analyseConstraint(index, fix)
                #print self.className + ': constraint found= {0}'.format(constraintFound)
                if constraintFound == True:
                    constraint = {}
                    constraint['fixIndex'] = index
                    constraint['level'] = levelConstraint
                    constraint['speed'] = speedConstraint
                    self.constraintsList.append(constraint)
                else:
                    self.fixList.append(fix)
                    wayPoint = wayPointsDb.getWayPoint(fix)
                    if not(wayPoint is None):
                        #print wayPoint
                        self.wayPointsDict[fix] = wayPoint
                    else:
                        ''' do not insert way point names when there is no known latitude - longitude '''
                        self.fixList.pop()
                
            index += 1             
        #print self.className + ': fix list= ' + str(self.fixList)
        assert (self.allAnglesLessThan90degrees(minIntervalNautics = 10.0))
Exemple #4
0
    def test_TurnLeg(self):

        print '==================== Turn Leg ==================== ' + time.strftime(
            "%c")
        atmosphere = Atmosphere()
        earth = Earth()

        acBd = BadaAircraftDatabase()
        aircraftICAOcode = 'A320'
        assert acBd.read()
        assert acBd.aircraftExists(aircraftICAOcode)
        assert acBd.aircraftPerformanceFileExists(aircraftICAOcode)

        print '==================== aircraft found  ==================== ' + time.strftime(
            "%c")
        aircraft = BadaAircraft(
            ICAOcode=aircraftICAOcode,
            aircraftFullName=acBd.getAircraftFullName(aircraftICAOcode),
            badaPerformanceFilePath=acBd.getAircraftPerformanceFile(
                aircraftICAOcode),
            atmosphere=atmosphere,
            earth=earth)
        aircraft.dump()

        print '==================== Get Airport ==================== ' + time.strftime(
            "%c")
        airportsDB = AirportsDatabase()
        assert airportsDB.read()

        print '==================== Get Arrival Airport ==================== ' + time.strftime(
            "%c")
        Lisbonne = airportsDB.getAirportFromICAOCode('LPPT')
        print Lisbonne

        print '====================  find the run-ways ==================== ' + time.strftime(
            "%c")
        runWaysDatabase = RunWayDataBase()
        if runWaysDatabase.read():
            print 'runways DB correctly read'

        print '====================  take off run-way ==================== ' + time.strftime(
            "%c")
        arrivalRunway = runWaysDatabase.getFilteredRunWays(
            airportICAOcode='LPPT', runwayName='')
        print arrivalRunway

        print '==================== Ground run ==================== ' + time.strftime(
            "%c")
        groundRun = GroundRunLeg(runway=arrivalRunway,
                                 aircraft=aircraft,
                                 airport=Lisbonne)

        touchDownWayPoint = groundRun.computeTouchDownWayPoint()
        print touchDownWayPoint
        groundRun.buildDepartureGroundRun(deltaTimeSeconds=1.0,
                                          elapsedTimeSeconds=0.0,
                                          distanceStillToFlyMeters=0.0,
                                          distanceToLastFixMeters=0.0)
        print '==================== Climb Ramp ==================== ' + time.strftime(
            "%c")

        initialWayPoint = groundRun.getLastVertex().getWeight()

        descentGlideSlope = DescentGlideSlope(runway=arrivalRunway,
                                              aircraft=aircraft,
                                              arrivalAirport=Lisbonne,
                                              descentGlideSlopeDegrees=3.0)
        ''' if there is a fix nearer to 5 nautics of the touch-down then limit size of simulated glide slope '''

        descentGlideSlope.buildSimulatedGlideSlope(
            descentGlideSlopeSizeNautics=5.0)
        descentGlideSlope.createKmlOutputFile()

        firstGlideSlopeWayPoint = descentGlideSlope.getVertex(v=0).getWeight()

        print '==================== Climb Ramp ==================== ' + time.strftime(
            "%c")
        initialWayPoint = groundRun.getLastVertex().getWeight()

        print ' ================== turn leg end =============== '
        wayPointsDb = WayPointsDatabase()
        assert (wayPointsDb.read())
        Exona = wayPointsDb.getWayPoint('EXONA')
        Rosal = wayPointsDb.getWayPoint('ROSAL')

        print Rosal.getBearingDegreesTo(Exona)
        initialHeadingDegrees = arrivalRunway.getTrueHeadingDegrees()

        lastTurnLeg = TurnLeg(initialWayPoint=firstGlideSlopeWayPoint,
                              finalWayPoint=Exona,
                              initialHeadingDegrees=initialHeadingDegrees,
                              aircraft=aircraft,
                              reverse=True)
        deltaTimeSeconds = 1.0
        lastTurnLeg.buildNewSimulatedArrivalTurnLeg(
            deltaTimeSeconds=deltaTimeSeconds,
            elapsedTimeSeconds=0.0,
            distanceStillToFlyMeters=0.0,
            simulatedAltitudeSeaLevelMeters=firstGlideSlopeWayPoint.
            getAltitudeMeanSeaLevelMeters(),
            flightPathAngleDegrees=3.0)
        lastTurnLeg.createKmlOutputFile()
        descentGlideSlope.addGraph(lastTurnLeg)
        #descentGlideSlope.createXlsxOutputFile()
        descentGlideSlope.createKmlOutputFile()

        print ' ================== turn leg end =============== '
 def test_Two(self):  
 
     t0 = time.clock()
     print ( " ========== Great Circle ======= time start= ", t0 )
     atmosphere = Atmosphere()
     earth = Earth()
     
     print ( '==================== Great Circle ==================== '+ time.strftime("%c") )
     acBd = BadaAircraftDatabase()
     aircraftICAOcode = 'A320'
     if acBd.read():
         if ( acBd.aircraftExists(aircraftICAOcode) 
              and acBd.aircraftPerformanceFileExists(aircraftICAOcode)):
             
             print ( '==================== aircraft found  ==================== '+ time.strftime("%c") )
             aircraft = BadaAircraft(ICAOcode = aircraftICAOcode, 
                                         aircraftFullName = acBd.getAircraftFullName(aircraftICAOcode),
                                         badaPerformanceFilePath = acBd.getAircraftPerformanceFile(aircraftICAOcode),
                                         atmosphere = atmosphere,
                                         earth = earth)
             print ( aircraft )
     
     else:
         
         print ( '====================  airport database ==================== '+ time.strftime("%c") )
         airportsDB = AirportsDatabase()
         assert not(airportsDB is None)
         
         wayPointsDb = WayPointsDatabase()
         assert (wayPointsDb.read())
     
         initialWayPoint = wayPointsDb.getWayPoint('TOU')
         finalWayPoint = wayPointsDb.getWayPoint('ALIVA') 
         print ( initialWayPoint.getBearingDegreesTo(finalWayPoint) )
         print ( finalWayPoint.getBearingDegreesTo(initialWayPoint) )
         
         ''' departure ground run => initial speed is null '''
         trueAirSpeedMetersSecond = 70.0
         elapsedTimeSeconds = 0.0
 
         aircraft.setCurrentAltitudeSeaLevelMeters( 
                                          elapsedTimeSeconds = 0.0 , 
                                          altitudeMeanSeaLevelMeters = 0.0,
                                          lastAltitudeMeanSeaLevelMeters = 0.0,
                                          targetCruiseAltitudeMslMeters = 10000.0)
                
         aircraft.initStateVector( 
                         elapsedTimeSeconds = 0.0,
                         trueAirSpeedMetersSecond = 70.0,
                         airportFieldElevationAboveSeaLevelMeters = 152.0)
         
         aircraft.setTargetCruiseFlightLevel(RequestedFlightLevel = 310, 
                                    departureAirportAltitudeMSLmeters = 152.0)
         
         print ( "=========== simulated descent glide slope  =========== " + time.strftime("%c") )
         MarseilleMarignane = airportsDB.getAirportFromICAOCode('LFML')
         
         
         print ( '==================== runways database ==================== '+ time.strftime("%c") )
         runWaysDatabase = RunWayDataBase()
         assert runWaysDatabase.read()
         runway = runWaysDatabase.getFilteredRunWays(airportICAOcode = 'LFML', runwayName = '')
 
         arrivalGroundRun = GroundRunLeg( runway   = runway,
                                          aircraft = aircraft,
                                          airport  = MarseilleMarignane )
         
         touchDownWayPoint = arrivalGroundRun.computeTouchDownWayPoint()
         aircraft.setArrivalRunwayTouchDownWayPoint(touchDownWayPoint)
 
         threeDegreesGlideSlope = DescentGlideSlope(runway = runway, 
                                                    aircraft = aircraft, 
                                                    arrivalAirport = MarseilleMarignane )
         threeDegreesGlideSlope.buildSimulatedGlideSlope(descentGlideSlopeSizeNautics = 5.0)
         approachWayPoint = threeDegreesGlideSlope.getLastVertex().getWeight()
         
         aircraft.setTargetApproachWayPoint(approachWayPoint)
         
         ''' =================================='''
         greatCircle = GreatCircleRoute(initialWayPoint = initialWayPoint, 
                                         finalWayPoint = finalWayPoint,
                                         aircraft = aircraft)
         
         distanceStillToFlyMeters = initialWayPoint.getDistanceMetersTo(approachWayPoint)
 
         greatCircle.computeGreatCircle( 
                            deltaTimeSeconds = 0.1,
                            elapsedTimeSeconds = 0.0,
                            distanceStillToFlyMeters = distanceStillToFlyMeters,
                            distanceToLastFixMeters = distanceStillToFlyMeters)
         
         print ( 'main great circle length= ' + str(greatCircle.computeLengthMeters()) + ' meters' )
 
         greatCircle.createKmlOutputFile()
         greatCircle.createXlsxOutputFile()
    def test_TurnLeg(self):

        print '==================== Turn Leg ==================== '+ time.strftime("%c")
        atmosphere = Atmosphere()
        earth = Earth()
        
        acBd = BadaAircraftDatabase()
        aircraftICAOcode = 'A320'
        assert acBd.read()
        assert acBd.aircraftExists(aircraftICAOcode) 
        assert acBd.aircraftPerformanceFileExists(aircraftICAOcode)
                
        print '==================== aircraft found  ==================== '+ time.strftime("%c")
        aircraft = BadaAircraft(ICAOcode = aircraftICAOcode, 
                                aircraftFullName = acBd.getAircraftFullName(aircraftICAOcode),
                                badaPerformanceFilePath = acBd.getAircraftPerformanceFile(aircraftICAOcode),
                                atmosphere = atmosphere,
                                earth = earth)
        aircraft.dump()
                
        print '==================== Get Airport ==================== '+ time.strftime("%c")
        airportsDB = AirportsDatabase()
        assert airportsDB.read()
        
        print '==================== Get Arrival Airport ==================== '+ time.strftime("%c")
        Lisbonne = airportsDB.getAirportFromICAOCode('LPPT')
        print Lisbonne
        
        print '====================  find the run-ways ==================== '+ time.strftime("%c")
        runWaysDatabase = RunWayDataBase()
        if runWaysDatabase.read():
            print 'runways DB correctly read'
            
        print '====================  take off run-way ==================== '+ time.strftime("%c")
        arrivalRunway = runWaysDatabase.getFilteredRunWays(
                                                           airportICAOcode = 'LPPT', 
                                                           runwayName = '')
        print arrivalRunway
        
        print '==================== Ground run ==================== '+ time.strftime("%c")
        groundRun = GroundRunLeg(runway = arrivalRunway, 
                                 aircraft = aircraft,
                                 airport = Lisbonne)
        
        touchDownWayPoint = groundRun.computeTouchDownWayPoint()
        print touchDownWayPoint
        groundRun.buildDepartureGroundRun(deltaTimeSeconds = 1.0,
                                          elapsedTimeSeconds = 0.0,
                                          distanceStillToFlyMeters = 0.0,
                                          distanceToLastFixMeters = 0.0)
        print '==================== Climb Ramp ==================== '+ time.strftime("%c")
        
        initialWayPoint = groundRun.getLastVertex().getWeight()
    
        descentGlideSlope = DescentGlideSlope( runway   = arrivalRunway,
                                                aircraft = aircraft,
                                                arrivalAirport = Lisbonne ,
                                                descentGlideSlopeDegrees = 3.0)
        ''' if there is a fix nearer to 5 nautics of the touch-down then limit size of simulated glide slope '''
    
        descentGlideSlope.buildSimulatedGlideSlope(descentGlideSlopeSizeNautics = 5.0)
        descentGlideSlope.createKmlOutputFile()
        
        firstGlideSlopeWayPoint = descentGlideSlope.getVertex(v=0).getWeight()
    
        print '==================== Climb Ramp ==================== '+ time.strftime("%c")
        initialWayPoint = groundRun.getLastVertex().getWeight()
    
        print ' ================== turn leg end =============== '
        wayPointsDb = WayPointsDatabase()
        assert (wayPointsDb.read())
        Exona = wayPointsDb.getWayPoint('EXONA')
        Rosal = wayPointsDb.getWayPoint('ROSAL')
    
        print Rosal.getBearingDegreesTo(Exona) 
        initialHeadingDegrees = arrivalRunway.getTrueHeadingDegrees()
        
        lastTurnLeg = TurnLeg( initialWayPoint = firstGlideSlopeWayPoint, 
                               finalWayPoint = Exona,
                               initialHeadingDegrees = initialHeadingDegrees, 
                               aircraft = aircraft,
                               reverse = True)
        deltaTimeSeconds = 1.0
        lastTurnLeg.buildNewSimulatedArrivalTurnLeg(deltaTimeSeconds = deltaTimeSeconds,
                                                     elapsedTimeSeconds = 0.0,
                                                     distanceStillToFlyMeters = 0.0,
                                                     simulatedAltitudeSeaLevelMeters = firstGlideSlopeWayPoint.getAltitudeMeanSeaLevelMeters(),
                                                     flightPathAngleDegrees = 3.0)
        lastTurnLeg.createKmlOutputFile()
        descentGlideSlope.addGraph(lastTurnLeg)
        #descentGlideSlope.createXlsxOutputFile()
        descentGlideSlope.createKmlOutputFile()
        
        print ' ================== turn leg end =============== '
    def test_compute_great_circle(self):
        # print(
        #     '==================== departure airport ==================== ' + time.strftime(
        #         "%c"))
        # airportsDB = AirportsDatabase()
        # assert (airportsDB.read())
        #
        # CharlesDeGaulle = airportsDB.getAirportFromICAOCode('LFPG')
        # print(CharlesDeGaulle)
        #
        # print(
        #     '==================== arrival airport ==================== ' + time.strftime(
        #         "%c"))
        #
        # MarseilleMarignane = airportsDB.getAirportFromICAOCode('LFML')
        # print(MarseilleMarignane)

        wayPointsDb = WayPointsDatabase()
        assert (wayPointsDb.read())
        Exona = wayPointsDb.getWayPoint('EXONA')
        Rosal = wayPointsDb.getWayPoint('ROSAL')
        Santa = wayPointsDb.getWayPoint('SANTA')

        print('==================== Great Circle ==================== ' +
              time.strftime("%c"))

        self.aircraft.setCurrentAltitudeSeaLevelMeters(
            elapsedTimeSeconds=0.0,
            altitudeMeanSeaLevelMeters=0.0,
            lastAltitudeMeanSeaLevelMeters=0.0,
            targetCruiseAltitudeMslMeters=10000.0)

        self.aircraft.initStateVector(
            elapsedTimeSeconds=0.0,
            trueAirSpeedMetersSecond=70.0,
            airportFieldElevationAboveSeaLevelMeters=152.0)

        self.aircraft.setTargetCruiseFlightLevel(
            RequestedFlightLevel=310, departureAirportAltitudeMSLmeters=152.0)

        print('==================== runways database ==================== ' +
              time.strftime("%c"))
        # runWaysDatabase = RunWayDataBase()
        # assert runWaysDatabase.read()
        # arrivalRunway = runWaysDatabase.getFilteredRunWays(
        #     airportICAOcode='LFML', runwayName='')

        print('==================== Compute touch down ==================== ' +
              time.strftime("%c"))

        # arrivalGroundRun = GroundRunLeg(runway=arrivalRunway,
        #                                 aircraft=self.aircraft,
        #                                 airport=MarseilleMarignane)
        # touchDownWayPoint = arrivalGroundRun.computeTouchDownWayPoint()
        # self.aircraft.setArrivalRunwayTouchDownWayPoint(touchDownWayPoint)

        print("=========== simulated descent glide slope  =========== " +
              time.strftime("%c"))

        # threeDegreesGlideSlope = DescentGlideSlope(runway=arrivalRunway,
        #                                            aircraft=self.aircraft,
        #                                            arrivalAirport=MarseilleMarignane)
        # threeDegreesGlideSlope.buildSimulatedGlideSlope(
        #     descentGlideSlopeSizeNautics=5.0)
        # approachWayPoint = threeDegreesGlideSlope.getLastVertex().getWeight()
        # self.aircraft.setTargetApproachWayPoint(approachWayPoint)

        print('==================== Great Circle ==================== ' +
              time.strftime("%c"))

        greatCircle = GreatCircleRoute(initialWayPoint=Exona,
                                       finalWayPoint=Rosal,
                                       aircraft=self.aircraft)

        distanceStillToFlyMeters = Exona.getDistanceMetersTo(Rosal)
        greatCircle.computeGreatCircle(
            deltaTimeSeconds=1.0,
            elapsedTimeSeconds=0.0,
            distanceStillToFlyMeters=distanceStillToFlyMeters,
            distanceToLastFixMeters=distanceStillToFlyMeters)

        greatCircle2 = GreatCircleRoute(initialWayPoint=Rosal,
                                        finalWayPoint=Santa,
                                        aircraft=self.aircraft)

        distanceStillToFlyMeters = Rosal.getDistanceMetersTo(Santa)
        greatCircle2.computeGreatCircle(
            deltaTimeSeconds=1.0,
            elapsedTimeSeconds=0.0,
            distanceStillToFlyMeters=distanceStillToFlyMeters,
            distanceToLastFixMeters=distanceStillToFlyMeters)

        greatCircle.addVertex(greatCircle2)
        print('main great circle length= ' +
              str(greatCircle.computeLengthMeters()) + ' meters')

        greatCircle.createKmlOutputFile()
        greatCircle.createXlsxOutputFile()
    def test_turn_leg_fly_by_waypoint(self):
        wayPointsDb = WayPointsDatabase()
        assert (wayPointsDb.read())
        # Exona = wayPointsDb.getWayPoint('EXONA')
        # Rosal = wayPointsDb.getWayPoint('ROSAL')
        # Santa = wayPointsDb.getWayPoint('SANTA')

        p1 = wayPointsDb.getWayPoint('LAMSO')
        p2 = wayPointsDb.getWayPoint('EVELI')
        # p2 = wayPointsDb.getWayPoint('BASNO')
        # p3 = wayPointsDb.getWayPoint('PAMPUS')
        # ret = wayPointsDb.insertWayPoint('ENKOS', "N31°40'58.50" + '"', "N31°40'58.50" + '"')
        # ret = wayPointsDb.insertWayPoint('ENKOS', "N52°40'41.26" + '"', "E5°14'35.75" + '"')
        # if wayPointsDb.hasWayPoint('ENKOS'):
        #     self.assertFalse(ret, 'insertion not done')
        #     exit(1)
        # else:
        #     self.assertTrue(ret, 'insertion correct')
        p3 = wayPointsDb.getWayPoint('ENKOS')

        print(p1)
        print(p2)
        print(p3)
        # print(p4)

        self.aircraft.aircraftCurrentConfiguration = 'cruise'

        self.aircraft.initStateVector(
            elapsedTimeSeconds=0.0,
            trueAirSpeedMetersSecond=70.0,
            airportFieldElevationAboveSeaLevelMeters=10000.0)

        self.aircraft.setTargetCruiseFlightLevel(
            RequestedFlightLevel=310, departureAirportAltitudeMSLmeters=0.0)

        greatCircle = GreatCircleRoute(initialWayPoint=p1,
                                       finalWayPoint=p2,
                                       aircraft=self.aircraft)

        distanceStillToFlyMeters = p1.getDistanceMetersTo(p2)
        greatCircle.computeGreatCircle(
            deltaTimeSeconds=self.deltaTimeSeconds,
            elapsedTimeSeconds=p1.getElapsedTimeSeconds(),
            distanceStillToFlyMeters=distanceStillToFlyMeters,
            distanceToLastFixMeters=distanceStillToFlyMeters)
        finalRoute = greatCircle

        initialHeadingDegrees = p1.getBearingDegreesTo(p2)
        turn_leg = TurnLeg(initialWayPoint=p2,
                           finalWayPoint=p3,
                           initialHeadingDegrees=initialHeadingDegrees,
                           aircraft=self.aircraft,
                           reverse=False)

        last_gc_vertex = finalRoute.getLastVertex().getWeight()
        distance_to_fly = last_gc_vertex.getDistanceMetersTo(p3)
        turn_leg.buildTurnLeg(
            deltaTimeSeconds=self.deltaTimeSeconds,
            elapsedTimeSeconds=last_gc_vertex.getElapsedTimeSeconds(),
            distanceStillToFlyMeters=distance_to_fly,
            distanceToLastFixMeters=distance_to_fly)
        finalRoute.addGraph(turn_leg)

        last_turn_leg_vertex = turn_leg.getLastVertex().getWeight()
        # last_turn_leg_vertex = p2
        greatCircle2 = GreatCircleRoute(initialWayPoint=last_turn_leg_vertex,
                                        finalWayPoint=p3,
                                        aircraft=self.aircraft)
        distanceStillToFlyMeters = last_turn_leg_vertex.getDistanceMetersTo(p3)
        greatCircle2.computeGreatCircle(
            deltaTimeSeconds=self.deltaTimeSeconds,
            elapsedTimeSeconds=last_turn_leg_vertex.getElapsedTimeSeconds(),
            distanceStillToFlyMeters=distanceStillToFlyMeters,
            distanceToLastFixMeters=distanceStillToFlyMeters)
        finalRoute.addGraph(greatCircle2)

        finalRoute.createKmlOutputFile()
        finalRoute.createXlsxOutputFile()
        self.aircraft.createStateVectorOutputFile(
            filePrefix='turn-leg-great-circle')
Exemple #9
0
                "%c")
            acA320 = BadaAircraft(
                aircraftICAOcode,
                acBd.getAircraftPerformanceFile(aircraftICAOcode), atmosphere,
                earth)
            print acA320

    print '====================  airport database ==================== ' + time.strftime(
        "%c")
    airportsDB = AirportsDatabase()
    assert not (airportsDB is None)

    wayPointsDb = WayPointsDatabase()
    assert (wayPointsDb.read())

    initialWayPoint = wayPointsDb.getWayPoint('TOU')
    finalWayPoint = wayPointsDb.getWayPoint('ALIVA')
    print initialWayPoint.getBearingDegreesTo(finalWayPoint)
    print finalWayPoint.getBearingDegreesTo(initialWayPoint)
    ''' departure ground run => initial speed is null '''
    trueAirSpeedMetersSecond = 70.0
    elapsedTimeSeconds = 0.0
    acA320.setTrueAirSpeedMetersSecond(elapsedTimeSeconds,
                                       trueAirSpeedMetersSecond)
    acA320.setCurrentAltitudeSeaLevelMeters(elapsedTimeSeconds, 0.0)

    greatCircle = GreatCircleRoute(initialWayPoint=initialWayPoint,
                                   finalWayPoint=finalWayPoint,
                                   aircraft=acA320)
    greatCircle.computeGreatCircle()
    greatCircle.createKmlOutputFile()