Exemplo n.º 1
0
    def makeVector(self, f_iVal):
        """
        DOCUMENT ME!
        """
        # logger
        # M_LOG.info("makeVector:>>")

        # check input
        # assert f_control

        # M_LOG.debug("f_iVal....: " + str(f_iVal))
        # M_LOG.debug("aoAircraft: " + str(len(self.__dct_flight)))

        # verifica se o índice é válido
        if (f_iVal < 0) or (f_iVal >= len(self.__dct_flight)):

            # logger
            # M_LOG.info("makeVector:<E01. índice inválido.")

            # cai fora...
            return

        # get mouse position
        l_XY = pxy.CPosXY(self._iMouseX, self._iMouseY)
        assert l_XY is not None

        # converte as coordenadas de tela para mapa
        l_pos = self.__viewport.translate_xy(l_XY)

        self.__f_radar_vector = tMath.track(self.__dct_flight[f_iVal].radarPosition(), l_pos) + self.__airspace.variation()

        l_iRem = int(self.__f_radar_vector * 10.) % 50

        self.__f_radar_vector = int(self.__f_radar_vector) - (int(self.__f_radar_vector) % 5)

        if l_iRem >= 25:
            self.__f_radar_vector += 5.

        if self.__f_radar_vector > 360.:
            self.__f_radar_vector -= 360.

        if 0. == self.__f_radar_vector:
            self.__f_radar_vector = 360.

        self.__i_lateral_mode = self.C_LMODE_HDG
Exemplo n.º 2
0
    def radar_magnetic_track(self):
        """
        determine magnetic track from radar history
        """
        if len(self.__lst_trail) < 3:
            # return
            return 0

        # determine magnetic track
        l_tr = round(
            tmath.track(self.__lst_trail[-1], self.pos) +
            self.__airspace.f_variation, 0)

        # need normalize ?
        if l_tr < 0:
            # normalize angle
            l_tr += 360

        # return
        return l_tr
Exemplo n.º 3
0
    def makeApproach(self):
        """
        DOCUMENT ME!
        """
        # logger
        # M_LOG.info("makeApproach:>>")

        # check input
        # assert f_control

        l_oXY = pxy.CPosXY(self._iMouseX, self._iMouseY)
        assert l_oXY is not None

        pos = self.__viewport.translate_xy(l_oXY)

        l_fClosest_r = 1000000
        l_sClosest = ""

        i = 0

        while (self.__airspace.arrivalRunway(i)):
            pos1 = self.__airspace.getPosition(self.__airspace.arrivalRunway(i))

            d = tMath.distLL(pos, pos1)
            a = tMath.trackDelta(self.__airspace.runway(self.__airspace.arrivalRunway(i)).track(),
                tMath.track(pos,pos1))

            r = d * tMath.dsin(abs(a))

            if ((r < l_fClosest_r) and (abs(a) < 90)):
                l_sClosest = self.__airspace.arrivalRunway(i)
                l_fClosest_r = r

            i += 1

        self.__s_approach = l_sClosest
        self.__i_lateral_mode = self.C_LMODE_APP
Exemplo n.º 4
0
    def makeRoute(self):
        """
        DOCUMENT ME!
        """
        # logger
        # M_LOG.info("makeRoute:>>")

        # check input
        # assert f_control

        # get mouse position
        l_oXY = pxy.CPosXY(self._iMouseX, self._iMouseY)
        assert l_oXY is not None

        # converte as coordenadas de tela para mapa
        pos = self.__viewport.translate_xy(l_oXY)

        # inicia variáveis
        l_sClosest = ""
        l_fClosest_r = 1000000

        # first arrival
        i = 0
        srt = self.__airspace.arrival(0)

        # scan all arrival's
        while srt is not None:
            # init flag
            apply = False

            # first runway
            rw = 0

            # scan all runway's
            while self.__airspace.arrivalRunway(rw):
                # arrival belongs to runway ?
                if srt.belongsToRunway(self.__airspace.arrivalRunway(rw)):
                    # ok, found
                    apply = True

                # next runway
                rw += 1

            # no found any runway ?
            if not apply:
                # next arrival
                i += 1
                srt = self.__airspace.arrival(i)

                # next loop
                continue

            n = 0
            while srt.item(n) is not None:
                pos1 = self.__airspace.getPosition(srt.item(n)._sName)
                r = tMath.distLL(pos, pos1)

                if srt.item(n + 1):
                    pos2 = self.__airspace.getPosition(srt.item(n + 1)._sName)
                    rttrk = tMath.track(pos1, pos2)
                    rtdist = tMath.distLL(pos1, pos2)
                    mstrk = tMath.track(pos1, pos)
                    tdelta = tMath.trackDelta(rttrk, mstrk)
                    prog = tMath.distLL(pos, pos1) * tMath.dcos(tdelta)

                    if ((prog > 0) and (prog < rtdist)):
                        r = tMath.distLL(pos, pos1) * tMath.dsin(abs(tdelta))

                # distância menor que a anterior ?
                if r < l_fClosest_r:
                    # this is the new closest element
                    l_sClosest = srt.getName()
                    l_fClosest_r = r

                n += 1

            # next arrival
            i += 1
            srt = self.__airspace.arrival(i)

        # first transition
        i = 0
        srt = self.__airspace.transition(0)

        # scan all transitions
        while srt is not None:
            # init flag
            apply = False

            # first runway
            rw = 0

            # scan all runway's
            while self.__airspace.arrivalRunway(rw):
                # transition belongs to runway ?
                if srt.belongsToRunway(self.__airspace.arrivalRunway(rw)):
                    # ok, found
                    apply = True

                # next runway
                rw += 1

            # no found any transition ?
            if not apply:
                # next transition
                i += 1
                srt = self.__airspace.transition(i)

                # next loop
                continue

            n = 0
            while srt.item(n):
                pos1 = self.__airspace.getPosition(srt.item(n)._sName)
                r = tMath.distLL(pos, pos1)

                if srt.item(n + 1):
                    pos2 = self.__airspace.getPosition(srt.item(n + 1)._sName)
                    rttrk = tMath.track(pos1, pos2)
                    rtdist = tMath.distLL(pos1, pos2)
                    mstrk = tMath.track(pos1, pos)
                    tdelta = tMath.trackDelta(rttrk, mstrk)
                    prog = tMath.distLL(pos, pos1) * tMath.dcos(tdelta)

                    if ((prog > 0) and (prog < rtdist)):
                        r = tMath.distLL(pos, pos1) * tMath.dsin(abs(tdelta))

                if r < l_fClosest_r:
                    l_sClosest = srt._sName()
                    l_fClosest_r = r

                n += 1

            # next transition
            i += 1
            srt = self.__airspace.transition(i)

        self.__s_route = l_sClosest
        self.__i_lateral_mode = self.C_LMODE_RTE