def buildArrivalPhase(self, initialHeadingDegrees):

        print self.className + "==================== add last turn ==================== "
        if self.isDomestic() or self.isInBound():
            endOfLastGreatCircleWayPoint = self.finalRoute.getLastVertex().getWeight()

            finalHeadingDegrees = self.arrivalRunway.getTrueHeadingDegrees()
            finalHeadingDegrees = math.fmod(finalHeadingDegrees + 180.0, 360.0)
            print self.className + ": runway final heading= {0:.2f} degrees".format(finalHeadingDegrees)

            turnLeg = TurnLeg(
                initialWayPoint=endOfLastGreatCircleWayPoint,
                # finalWayPoint    = self.firstGlideSlopeWayPoint,
                finalWayPoint=self.touchDownWayPoint,
                initialHeadingDegrees=initialHeadingDegrees,
                aircraft=self.aircraft,
                reverse=False,
            )

            distanceStillToFlyMeters = self.flightLengthMeters - self.finalRoute.getLengthMeters()
            distanceToLastFixMeters = self.computeDistanceToLastFixMeters(
                currentPosition=endOfLastGreatCircleWayPoint, fixListIndex=self.flightListIndex
            )
            distanceToLastFixMeters = distanceStillToFlyMeters
            """ for the last turn => final heading towards the runway orientation """
            deltaTimeSeconds = 0.1
            turnLeg.buildTurnLeg(
                deltaTimeSeconds=deltaTimeSeconds,
                elapsedTimeSeconds=endOfLastGreatCircleWayPoint.getElapsedTimeSeconds(),
                distanceStillToFlyMeters=distanceStillToFlyMeters,
                distanceToLastFixMeters=distanceToLastFixMeters,
                finalHeadingDegrees=finalHeadingDegrees,
                lastTurn=True,
                bankAngleDegrees=5.0,
            )
            self.finalRoute.addGraph(turnLeg)

            endOfTurnLegWayPoint = self.finalRoute.getLastVertex().getWeight()
            """ ============= use touch-down way-point to compute distance to fly ============="""
            distanceStillToFlyMeters = endOfTurnLegWayPoint.getDistanceMetersTo(self.touchDownWayPoint)
            print self.className + ": distance still to fly= {0:.2f} nautics".format(
                distanceStillToFlyMeters * Meter2NauticalMiles
            )

            # print '==================== add descent slope ================= '
            descentGlideSlope = DescentGlideSlope(
                runway=self.arrivalRunway,
                aircraft=self.aircraft,
                arrivalAirport=self.arrivalAirport,
                descentGlideSlopeDegrees=3.0,
            )

            flownDistanceMeters = self.finalRoute.getLengthMeters()
            distanceStillToFlyMeters = self.flightLengthMeters - self.finalRoute.getLengthMeters()
            distanceToLastFixMeters = self.computeDistanceToLastFixMeters(
                currentPosition=endOfTurnLegWayPoint, fixListIndex=self.flightListIndex
            )
            distanceToLastFixMeters = distanceStillToFlyMeters

            descentGlideSlope.buildGlideSlope(
                deltaTimeSeconds=self.deltaTimeSeconds,
                elapsedTimeSeconds=endOfTurnLegWayPoint.getElapsedTimeSeconds(),
                initialWayPoint=endOfTurnLegWayPoint,
                flownDistanceMeters=flownDistanceMeters,
                distanceStillToFlyMeters=distanceStillToFlyMeters,
                distanceToLastFixMeters=distanceToLastFixMeters,
            )
            self.finalRoute.addGraph(descentGlideSlope)
            endOfDescentGlideSlope = self.finalRoute.getLastVertex().getWeight()

            # print '================= add arrival ground run ================'
            arrivalGroundRun = GroundRunLeg(
                runway=self.arrivalRunway, aircraft=self.aircraft, airport=self.arrivalAirport
            )
            arrivalGroundRun.buildArrivalGroundRun(
                deltaTimeSeconds=self.deltaTimeSeconds,
                elapsedTimeSeconds=endOfDescentGlideSlope.getElapsedTimeSeconds(),
                initialWayPoint=endOfDescentGlideSlope,
            )
            self.finalRoute.addGraph(arrivalGroundRun)
Пример #2
0
    def buildArrivalPhase(self, initialHeadingDegrees):

        print(
            self.className +
            ': initial heading= {0:.2f} degrees'.format(initialHeadingDegrees))

        print(self.className +
              '==================== add last turn ==================== ')
        if self.isDomestic() or self.isInBound():
            endOfLastGreatCircleWayPoint = self.finalRoute.getLastVertex(
            ).getWeight()

            finalHeadingDegrees = self.arrivalRunway.getTrueHeadingDegrees()
            finalHeadingDegrees = math.fmod(finalHeadingDegrees + 180.0, 360.0)
            print(self.className +
                  ': runway final heading= {0:.2f} degrees'.format(
                      finalHeadingDegrees))

            turnLeg = TurnLeg(
                initialWayPoint=endOfLastGreatCircleWayPoint,
                #finalWayPoint    = self.firstGlideSlopeWayPoint,
                finalWayPoint=self.touchDownWayPoint,
                initialHeadingDegrees=initialHeadingDegrees,
                aircraft=self.aircraft,
                reverse=False)

            distanceStillToFlyMeters = self.flightLengthMeters - self.finalRoute.getLengthMeters(
            )
            distanceToLastFixMeters = self.computeDistanceToLastFixMeters(
                currentPosition=endOfLastGreatCircleWayPoint,
                fixListIndex=self.flightListIndex)
            distanceToLastFixMeters = distanceStillToFlyMeters
            ''' for the last turn => final heading towards the runway orientation '''
            deltaTimeSeconds = 0.1
            turnLeg.buildTurnLeg(
                deltaTimeSeconds=deltaTimeSeconds,
                elapsedTimeSeconds=endOfLastGreatCircleWayPoint.
                getElapsedTimeSeconds(),
                distanceStillToFlyMeters=distanceStillToFlyMeters,
                distanceToLastFixMeters=distanceToLastFixMeters,
                finalHeadingDegrees=finalHeadingDegrees,
                lastTurn=True,
                bankAngleDegrees=5.0,
                arrivalRunway=self.arrivalRunway)
            self.finalRoute.addGraph(turnLeg)

            endOfTurnLegWayPoint = self.finalRoute.getLastVertex().getWeight()
            ''' ============= use touch-down way-point to compute distance to fly ============='''
            distanceStillToFlyMeters = endOfTurnLegWayPoint.getDistanceMetersTo(
                self.touchDownWayPoint)
            print(self.className +
                  ': distance still to fly= {0:.2f} nautics'.format(
                      distanceStillToFlyMeters * Meter2NauticalMiles))

            #print '==================== add descent slope ================= '
            descentGlideSlope = DescentGlideSlope(
                runway=self.arrivalRunway,
                aircraft=self.aircraft,
                arrivalAirport=self.arrivalAirport,
                descentGlideSlopeDegrees=3.0)

            flownDistanceMeters = self.finalRoute.getLengthMeters()
            distanceStillToFlyMeters = self.flightLengthMeters - self.finalRoute.getLengthMeters(
            )
            distanceToLastFixMeters = self.computeDistanceToLastFixMeters(
                currentPosition=endOfTurnLegWayPoint,
                fixListIndex=self.flightListIndex)
            distanceToLastFixMeters = distanceStillToFlyMeters

            descentGlideSlope.buildGlideSlope(
                deltaTimeSeconds=self.deltaTimeSeconds,
                elapsedTimeSeconds=endOfTurnLegWayPoint.getElapsedTimeSeconds(
                ),
                initialWayPoint=endOfTurnLegWayPoint,
                flownDistanceMeters=flownDistanceMeters,
                distanceStillToFlyMeters=distanceStillToFlyMeters,
                distanceToLastFixMeters=distanceToLastFixMeters)
            self.finalRoute.addGraph(descentGlideSlope)
            endOfDescentGlideSlope = self.finalRoute.getLastVertex().getWeight(
            )

            #print '================= add arrival ground run ================'
            arrivalGroundRun = GroundRunLeg(runway=self.arrivalRunway,
                                            aircraft=self.aircraft,
                                            airport=self.arrivalAirport)
            arrivalGroundRun.buildArrivalGroundRun(
                deltaTimeSeconds=self.deltaTimeSeconds,
                elapsedTimeSeconds=endOfDescentGlideSlope.
                getElapsedTimeSeconds(),
                initialWayPoint=endOfDescentGlideSlope)
            self.finalRoute.addGraph(arrivalGroundRun)
    assert runWaysDB.read()

    arrivalRunway = runWaysDB.getFilteredRunWays(
        arrivalAirportCode, 'Landing', aircraft.WakeTurbulenceCategory)
    print(arrivalRunway)

    aircraft.setArrivalAirportElevationMeters(
        arrivalAirport.getFieldElevationAboveSeaLevelMeters())

    CAS = aircraft.computeLandingStallSpeedCasKnots()
    TAS = cas2tas(
        cas=CAS,
        altitude=arrivalAirport.getFieldElevationAboveSeaLevelMeters(),
        temp='std',
        speed_units='kt',
        alt_units='m',
        temp_units=default_temp_units,
    )
    aircraft.initStateVector(elapsedTimeSeconds=0.0,
                             trueAirSpeedMetersSecond=TAS,
                             altitudeMeanSeaLevelMeters=arrivalAirport.
                             getFieldElevationAboveSeaLevelMeters(),
                             deltaDistanceFlownMeters=0.0)
    aircraft.setLandingConfiguration(0.0)
    groundRun = GroundRunLeg(runway=arrivalRunway,
                             aircraft=aircraft,
                             airport=arrivalAirport)

    groundRun.buildArrivalGroundRun(0.0)
    groundRun.createXlsxOutputFile()
    groundRun.createKmlOutputFile()