def autoCalcFinishMagVar(self):
        try:
            if self.parametersPanel.chbAutoFinishMagVar.Checked:
                finishPt = None
                finishLat = None
                finishLon = None
                degree3 = None
                num = None
                result, degree, degree1 = self.parametersPanel.pnlStartPosP.method_3(
                )
                if (result):
                    value = float(self.parametersPanel.txtForwardTP.Value)
                    value1 = float(self.parametersPanel.txtForwardTP.Value)
                    distance = self.parametersPanel.txtDistanceP.Value
                    result1, degree2, degree3, num = Geo.smethod_6(
                        self.parametersPanel.cmbCalculationTypeP.SelectedItem,
                        degree, degree1, value, distance)
                    if (result1):
                        finishPt = Point3D(degree3, degree2)

                        finishLat = degree2
                        finishLon = degree3
                if finishPt != None and self.model != None and self.date != None:
                    # result, degree, degree1 = self.parametersPanel.pnlStartPosP.method_3();
                    result2, degree2 = Geo.smethod_7(finishLat, finishLon,
                                                     Altitude(0), self.model,
                                                     self.date)
                    if (result2):
                        degree2 = round(degree2, 2)
                        self.parametersPanel.pnlVarFinishP.Value = degree2
        except:
            pass
    def setPosition(self, x, y):
        degreeLat = None
        degreeLon = None
        if (math.fabs(x) >= 89.99999999 and math.fabs(y) >= 180):
            self.txtPointX.setText(str(x))
            self.txtPointY.setText(str(y))
            try:
                flag, degreeLat, degreeLon = Geo.smethod_2(
                    float(self.txtPointX.text()), float(self.txtPointY.text()))
                self.txtLat.Value = degreeLat.ToString()
                if len(str(int(degreeLon.value))) == 3:
                    self.txtLong.Value = degreeLon.ToString("dddmmss.ssssH")
                else:
                    self.txtLong.Value = degreeLon.ToString("ddmmss.ssssH")
            except:
                pass
        else:
            degreeLat = Degrees(y, None, None, DegreesType.Latitude)
            degreeLon = Degrees(x, None, None, DegreesType.Longitude)
            self.txtLat.Value = degreeLat.ToString()
            if len(str(int(degreeLon.value))) == 3:
                self.txtLong.Value = degreeLon.ToString("dddmmss.ssssH")
            else:
                self.txtLong.Value = degreeLon.ToString("ddmmss.ssssH")

            flag, xVal, yVal = Geo.smethod_3(degreeLat, degreeLon)
            if flag:
                self.txtPointX.setText(str(xVal))
                self.txtPointY.setText(str(yVal))
        if self.alwwaysShowString == "Degree":
            self.resultPoint3d = Point3D(degreeLon.value, degreeLat.value)
        else:
            self.resultPoint3d = Point3D(x, y)
        self.setAnnotation()
    def setPoint3D(self, point_0):
        degreeLon = None
        degreeLat = None
        if point_0 == None:
            self.txtPointX.setText("")
            self.txtPointY.setText("")
            self.txtLat.Value = ""
            self.txtLong.Value = ""
            self.txtAltitudeM.setText("0.0")
            self.resultPoint3d = None
            return
        else:
            if (math.fabs(point_0.get_X()) >= 89.99999999
                    and math.fabs(point_0.get_Y()) >= 180):
                self.txtPointX.setText(str(point_0.get_X()))
                self.txtPointY.setText(str(point_0.get_Y()))
                try:
                    flag, degreeLat, degreeLon = Geo.smethod_2(
                        float(self.txtPointX.text()),
                        float(self.txtPointY.text()))
                    self.txtLat.Value = degreeLat.ToString()
                    if len(str(int(degreeLon.value))) == 3:
                        self.txtLong.Value = degreeLon.ToString(
                            "dddmmss.ssssH")
                    else:
                        self.txtLong.Value = degreeLon.ToString("ddmmss.ssssH")
                except:
                    pass
            else:
                degreeLat = Degrees(point_0.get_Y(), None, None,
                                    DegreesType.Latitude)
                degreeLon = Degrees(point_0.get_X(), None, None,
                                    DegreesType.Longitude)
                self.txtLat.Value = degreeLat.ToString()
                if len(str(int(degreeLon.value))) == 3:
                    self.txtLong.Value = degreeLon.ToString("dddmmss.ssssH")
                else:
                    self.txtLong.Value = degreeLon.ToString("ddmmss.ssssH")

                flag, xVal, yVal = Geo.smethod_3(degreeLat, degreeLon)
                if flag:
                    self.txtPointX.setText(str(xVal))
                    self.txtPointY.setText(str(yVal))
            self.txtAltitudeM.setText(str(point_0.get_Z()))
            if isinstance(point_0, Point3D):
                self.txtID.setText(point_0.ID)
            if self.alwwaysShowString == "Degree" or define._units != QGis.Meters:
                self.resultPoint3d = Point3D(degreeLon.value, degreeLat.value,
                                             point_0.get_Z())
            else:
                self.resultPoint3d = Point3D(float(self.txtPointX.text()),
                                             float(self.txtPointY.text()),
                                             point_0.get_Z())
            self.setAnnotation()
    def resultPointValueListMethod(self, resultValueList):
        degreeLat = None
        degreeLon = None
        if len(resultValueList) > 0:
            self.id = resultValueList[0]
            if define._units == QGis.Meters:
                self.txtPointX.setText(resultValueList[1])
                self.txtPointY.setText(resultValueList[2])
                try:
                    flag, degreeLat, degreeLon = Geo.smethod_2(
                        float(self.txtPointX.text()),
                        float(self.txtPointY.text()))
                    self.txtLat.Value = degreeLat.ToString()
                    if len(str(int(degreeLon.value))) == 3:
                        self.txtLong.Value = degreeLon.ToString(
                            "dddmmss.ssssH")
                    else:
                        self.txtLong.Value = degreeLon.ToString("ddmmss.ssssH")
                except:
                    pass
            else:
                degreeLat = Degrees(float(resultValueList[2]), None, None,
                                    DegreesType.Latitude)
                degreeLon = Degrees(float(resultValueList[1]), None, None,
                                    DegreesType.Longitude)
                self.txtLat.Value = degreeLat.ToString()
                if len(str(int(degreeLon.value))) == 3:
                    self.txtLong.Value = degreeLon.ToString("dddmmss.ssssH")
                else:
                    self.txtLong.Value = degreeLon.ToString("ddmmss.ssssH")

                flag, xVal, yVal = Geo.smethod_3(degreeLat, degreeLon)
                if flag:
                    self.txtPointX.setText(str(xVal))
                    self.txtPointY.setText(str(yVal))

            # self.txtPointX.setText(resultValueList[1])
            # self.txtPointY.setText(resultValueList[2])
            if self.alwwaysShowString == "Degree":
                self.resultPoint3d = Point3D(degreeLon.value, degreeLat.value,
                                             float(resultValueList[3]))
            else:
                self.resultPoint3d = Point3D(float(resultValueList[1]),
                                             float(resultValueList[2]),
                                             float(resultValueList[3]))
            self.resultPoint3d.ID = self.id
            self.txtAltitudeM.setText(str(round(float(resultValueList[3]))))
            self.txtID.setText(resultValueList[0])
            self.setAnnotation()
        self.emit(SIGNAL("captureFinished"), self)
        self.emit(SIGNAL("positionChanged"), self)
    def calculateMVD(self):
        degree = None
        degree1 = None
        degree2 = None

        result, degree, degree1 = self.parametersPanel.pnlPositionMVD.method_3(
        )
        # position.method_1(out degree, out degree1);
        altitude = self.parametersPanel.pnlPositionMVD.Altitude()
        result, degree2 = Geo.smethod_7(
            degree, degree1, altitude,
            self.parametersPanel.cmbModel.SelectedIndex,
            self.parametersPanel.dtpDate.date())
        if (result):
            self.parametersPanel.txtResult.Value = str(round(
                degree2, 4))  #.method_1(Formats.VariationFormat);
            date = self.parametersPanel.dtpDate.date()
            dataList = []
            dataList.append([
                "Latitude", "Longitude", "Altitude  (m)", "Altitude (ft)",
                "Date", "Magnetic Model", "Magnetic Variation"
            ])
            dataList.append([
                str(degree),
                str(degree1),
                str(altitude.Metres),
                str(altitude.Feet),
                date.toString(), self.parametersPanel.cmbModel.SelectedItem,
                self.parametersPanel.txtResult.Value
            ])
            GeoDetermineDlg.HistoryDataMV.append(dataList)
            self.setDataInHistoryModel(dataList)
예제 #6
0
 def method_0(self):
     if (self.xy):
         xlatValue = self.xlat
         ylonValue = self.ylon
         return True, xlatValue, ylonValue
     result, ylonValue, xlatValue = Geo.smethod_3(Degrees.smethod_1(self.xlat), Degrees.smethod_5(self.ylon))
     return result, xlatValue, ylonValue
예제 #7
0
    def resultPointValueListMethod(resultValueList, dataBaseProcedureData_0,
                                   point3d_0, procEntityListType_0, parent):
        if len(resultValueList) > 0:
            lat = None
            lon = None
            if define._units == QGis.Meters:
                point3d = QgisHelper.CrsTransformPoint(
                    float(resultValueList[1]), float(resultValueList[2]),
                    define._xyCrs, define._latLonCrs)

                lat = Degrees(point3d.get_Y(), None, None,
                              DegreesType.Latitude)
                lon = Degrees(point3d.get_X(), None, None,
                              DegreesType.Longitude)
            else:
                lat = Degrees(float(resultValueList[2]), None, None,
                              DegreesType.Latitude)
                lon = Degrees(float(resultValueList[1]), None, None,
                              DegreesType.Longitude)
            str0 = lon.method_1("dddmmss.ssssH")
            textString = lat.method_1("ddmmss.ssssH")
            procEntityBases = DlgAixmSelectPosition.smethod_1(
                dataBaseProcedureData_0, procEntityListType_0, point3d_0,
                textString, str0)
            dlgAixmSelectPosition = DlgAixmSelectPosition()
            naN = None
            degree = None
            result, naN, degree = Geo.smethod_2(point3d_0.get_X(),
                                                point3d_0.get_Y())
            if (result):
                dataBaseProcedureData_0.method_60(procEntityBases,
                                                  procEntityListType_0,
                                                  naN.ToString(),
                                                  degree.ToString())
            dlgAixmSelectPosition.lstItems.Sorted = True
            for procEntityBase in procEntityBases:
                dlgAixmSelectPosition.lstItems.Add(procEntityBase)
            if (procEntityListType_0 != ProcEntityListType.CentersEx
                    and procEntityListType_0 != ProcEntityListType.FixesEx):
                dlgAixmSelectPosition.btnNewPCP.setEnabled(False)
                dlgAixmSelectPosition.btnNewPCP.setVisible(False)
            resultDlg = dlgAixmSelectPosition.exec_()
            procEntityBase_0 = None
            if (resultDlg != 1):
                if dlgAixmSelectPosition.newTypeSelected == NewDbEntryType.DPN:
                    flag, procEntityBase_0 = DlgAixmNewDPN.smethod_0(
                        dataBaseProcedureData_0, naN, degree)
                elif dlgAixmSelectPosition.newTypeSelected == NewDbEntryType.PCP:
                    flag, procEntityBase_0 = DlgAixmNewPCP.smethod_0(
                        dataBaseProcedureData_0, naN, degree)
                else:
                    flag = False
            else:
                procEntityBase_0 = dlgAixmSelectPosition.lstItems.SelectedItem
                flag = True
            QObject.emit(parent,
                         SIGNAL("DlgAixmSelectPosition_Smethod_0_Event"), flag,
                         procEntityBase_0)
            return
    def method_30_BD(self):
        degree = None
        degree1 = None
        degree2 = None
        if (self.parametersPanel.pnlFinishPosBD.IsValid()):

            result, degree, degree1 = self.parametersPanel.pnlFinishPosBD.method_3(
            )
            result, degree2 = Geo.smethod_7(degree, degree1, Altitude(0),
                                            self.modelBD, self.dateBD)
            if (result):
                degree2 = round(degree2, 2)
                self.parametersPanel.pnlVarFinishBD.Value = degree2
예제 #9
0
 def get_Point3d(self):
     if (not self.IsValid):
         raise Messages.ERR_INVALID_OR_INCOMPLETE_POSITION
     if (self.xy):
         if (self.altitude == None or math.isinf(self.altitude)):
             return Point3D(self.xlat, self.ylon, 0)
         return Point3D(self.xlat, self.ylon, self.altitude)
     result, num, num1 = Geo.smethod_3(Degrees.smethod_1(self.xlat), Degrees.smethod_5(self.ylon))
     if (not result):
         raise "Geo.LastError"
     if (self.altitude == None or math.isinf(self.altitude)):
         return Point3D(num, num1, 0)
     return Point3D(num, num1, self.altitude)
예제 #10
0
    def method_5(self, degrees_0, degrees_1):
        num = None
        num1 = None
        self.txtLat.Value = degrees_0.ToString()
        if len(str(int(degrees_1))) == 3:
            self.txtLong.Value = degrees_1.ToString("dddmmss.ssssH")
        else:
            self.txtLong.Value = degrees_1.ToString("ddmmss.ssssH")

        flag, xVal, yVal = Geo.smethod_3(degrees_0, degrees_1)
        if flag:
            self.txtPointX.setText(str(xVal))
            self.txtPointY.setText(str(yVal))
        self.resultPoint3d.ID = self.id
        self.txtAltitudeM.setText(str(0.0))
        self.resultPoint3d = Point3D(degrees_1.value, degrees_0.value)
        self.txtID.setText("")
        return True
    def __init__(self, parent):
        FlightPlanBaseDlg.__init__(self, parent)
        self.setObjectName("HoldingRnavDlg")
        self.surfaceType = SurfaceTypes.GeoDetermine
        self.initParametersPan()
        self.setWindowTitle(SurfaceTypes.GeoDetermine)
        self.resize(540, 550)
        self.surfaceList = None

        self.date = QDate.currentDate()
        self.model = MagneticModel.WMM2010
        geo = Geo()

        self.resultLayerList = []
        self.resultPoint3d = None

        self.resultLat = None
        self.resultLon = None
 def method_32_P(self):
     startPos = self.parametersPanel.pnlStartPosP.Point3d
     result, self.date, self.model = DlgMagneticVariationParameters.smethod_0(
         self.date, self.model)
     if self.parametersPanel.pnlStartPosP.IsValid() and result:
         result, degree, degree1 = self.parametersPanel.pnlStartPosP.method_3(
         )
         result, degree2 = Geo.smethod_7(degree, degree1, Altitude(0),
                                         self.model, self.date)
         if (result):
             degree2 = round(degree2, 2)
             self.parametersPanel.pnlVarStartP.Value = degree2
             try:
                 self.parametersPanel.txtForwardMP.Value = MathHelper.smethod_3(
                     float(self.parametersPanel.txtForwardTP.Value) -
                     degree2)
             except:
                 self.parametersPanel.txtForwardMP.Value = 0.0
             self.method_29_P()
예제 #13
0
    def positionXYChanged(self):
        try:
            if self.flag1 == 0:
                self.flag1 = 1
            if self.flag1 == 2:
                self.flag1 = 0
            if self.flag1 == 1:
                try:
                    flag, degreeLat, degreeLon = Geo.smethod_2(
                        float(self.txtPointX.text()),
                        float(self.txtPointY.text()))
                    self.txtLat.Value = degreeLat.ToString()
                    if len(str(int(degreeLon.value))) == 3:
                        self.txtLong.Value = degreeLon.ToString(
                            "dddmmss.ssssH")
                    else:
                        self.txtLong.Value = degreeLon.ToString("ddmmss.ssssH")

                    if self.alwwaysShowString == "Degree":
                        self.resultPoint3d = Point3D(
                            degreeLon.value, degreeLat.value,
                            float(self.txtAltitudeM.text()))
                    else:
                        if define._units == QGis.Meters:
                            self.resultPoint3d = Point3D(
                                float(self.txtPointX.text()),
                                float(self.txtPointY.text()),
                                float(self.txtAltitudeM.text()))
                        else:
                            self.resultPoint3d = Point3D(
                                degreeLon.value, degreeLat.value,
                                float(self.txtAltitudeM.text()))

                except:
                    pass
            self.emit(SIGNAL("positionChanged"), self)
        except:
            raise "This plan coordinate can not be converted to geodetic coordinate."
예제 #14
0
 def method_1(self):
     if (self.xy):
         return Geo.smethod_2(self.xlat, self.ylon)
     degreesLat = Degrees.smethod_1(self.xlat)
     degreesLon = Degrees.smethod_5(self.ylon)
     return True, degreesLat, degreesLon
    def calculateBD(self):
        degree = None
        degree1 = None
        degree2 = None
        degree3 = None
        num = None
        result, degree, degree1 = self.parametersPanel.pnlStartPosBD.method_3()
        if (result):
            num2 = self.parametersPanel.pnlVarStartBD.Value
            result1, degree2, degree3 = self.parametersPanel.pnlFinishPosBD.method_3(
            )
            if (result1):
                num3 = self.parametersPanel.pnlVarFinishBD.Value
                result2, distance, num, num1 = Geo.smethod_4(
                    self.parametersPanel.cmbCalculationTypeBD.SelectedItem,
                    degree, degree1, degree2, degree3)
                if define._units == QGis.Meters:
                    QgisHelper.convertMeasureUnits(QGis.Degrees)
                    distance = Distance(
                        MathHelper.calcDistance(
                            self.parametersPanel.pnlStartPosBD.Point3d,
                            self.parametersPanel.pnlFinishPosBD.Point3d))
                    QgisHelper.convertMeasureUnits(QGis.Meters)
                else:
                    distance = Distance(
                        MathHelper.calcDistance(
                            self.parametersPanel.pnlStartPosBD.Point3d,
                            self.parametersPanel.pnlFinishPosBD.Point3d))
                if result2:
                    num4 = MathHelper.smethod_3(num - num2)
                    num5 = MathHelper.smethod_3(num1 - num3)
                    self.method_31_BD()

                    self.resultModelBD.setItem(
                        0, 0, QStandardItem(Captions.FORWARD_TRUE_BEARING))
                    self.resultModelBD.setItem(
                        0, 1, QStandardItem(str(round(num, 4))))

                    self.resultModelBD.setItem(
                        1, 0, QStandardItem(Captions.FORWARD_MAGNETIC_BEARING))
                    self.resultModelBD.setItem(
                        1, 1, QStandardItem(str(round(num4, 4))))

                    self.resultModelBD.setItem(
                        2, 0, QStandardItem(Captions.REVERSE_TRUE_BEARING))
                    self.resultModelBD.setItem(
                        2, 1, QStandardItem(str(round(num1, 4))))

                    self.resultModelBD.setItem(
                        3, 0, QStandardItem(Captions.REVERSE_MAGNETIC_BEARING))
                    self.resultModelBD.setItem(
                        3, 1, QStandardItem(str(round(num5, 4))))

                    self.resultModelBD.setItem(
                        4, 0,
                        QStandardItem(Captions.DISTANCE_BETWEEN_POSITIONS))
                    self.resultModelBD.setItem(
                        4, 1,
                        QStandardItem(
                            str(round(distance.NauticalMiles, 4)) + " nm"))

                    self.resultModelBD.setItem(
                        5, 0,
                        QStandardItem(Captions.DISTANCE_BETWEEN_POSITIONS))
                    self.resultModelBD.setItem(
                        5, 1,
                        QStandardItem(
                            str(round(distance.Kilometres, 4)) + " km"))

                    dataList = []
                    dataList.append([
                        "ID (Start)", "Latitude (Start)", "Longitude (Start)",
                        "Variation (Start)", "ID (Finish)",
                        "Latitude (Finish)", "Longitude (Finish)",
                        "Variation (Finish)", "Forward (° T)", "Forward (° M)",
                        "Reverse (° T)", "Reverse (° M)", "Distance (nm)",
                        "Distance (km)"
                    ])
                    dataList.append([
                        self.parametersPanel.pnlStartPosBD.ID,
                        str(degree),
                        str(degree1),
                        str(self.parametersPanel.pnlVarStartBD.Value),
                        self.parametersPanel.pnlFinishPosBD.ID,
                        str(degree2),
                        str(degree3),
                        str(self.parametersPanel.pnlVarFinishBD.Value),
                        str(num),
                        str(num4),
                        str(round(num, 4)),
                        str(round(num2, 4)),
                        str(distance.NauticalMiles),
                        str(distance.Kilometres)
                    ])
                    GeoDetermineDlg.HistoryDataBD.append(dataList)
                    self.setDataInHistoryModel(dataList)
                    self.method_28_BD()
    def calculateP(self):
        degree = None
        degree1 = None
        degree2 = None
        degree3 = None
        num = None
        result, degree, degree1 = self.parametersPanel.pnlStartPosP.method_3()
        if (result):
            # self.pnlVarStart.Value.smethod_17();
            num1 = float(self.parametersPanel.pnlVarFinishP.Value)
            value = float(self.parametersPanel.txtForwardTP.Value)
            value1 = float(self.parametersPanel.txtForwardTP.Value)
            distance = self.parametersPanel.txtDistanceP.Value
            result, degree2, degree3, num = Geo.smethod_6(
                self.parametersPanel.cmbCalculationTypeP.SelectedItem, degree,
                degree1, value, distance)
            if (result):
                num2 = MathHelper.smethod_3(num - num1)
                self.method_29_P()
                self.resultPoint3d = Point3D(degree3, degree2)

                self.resultLat = degree2
                self.resultLon = degree3

                latStr = Degrees(degree2, None, None,
                                 DegreesType.Latitude).ToString()

                self.resultModelP.setItem(0, 0,
                                          QStandardItem(Captions.LATITUDE))
                self.resultModelP.setItem(0, 1, QStandardItem(latStr))

                lonStr = Degrees(degree3, None, None,
                                 DegreesType.Longitude).ToString()
                if String.Str2QString(lonStr).mid(0, 1) == "0":
                    lonStr = String.Str2QString(lonStr).mid(
                        1,
                        String.Str2QString(lonStr).length() - 1)

                self.resultModelP.setItem(1, 0,
                                          QStandardItem(Captions.LONGITUDE))
                self.resultModelP.setItem(1, 1, QStandardItem(lonStr))

                self.resultModelP.setItem(
                    2, 0, QStandardItem(Captions.REVERSE_TRUE_BEARING))
                self.resultModelP.setItem(2, 1,
                                          QStandardItem(str(round(num, 4))))

                self.resultModelP.setItem(
                    3, 0, QStandardItem(Captions.REVERSE_MAGNETIC_BEARING))
                self.resultModelP.setItem(3, 1,
                                          QStandardItem(str(round(num2, 4))))

                dataList = []
                dataList.append([
                    "Latitude (Start)", "Longitude (Start)",
                    "Variation (Start)", "Forward (° T)", "Forward (° M)",
                    "Distance (nm)", "Distance (km)", "Latitude (Finish)",
                    "Longitude (Finish)", "Variation (Finish)",
                    "Reverse (° T)", "Reverse (° M)"
                ])
                dataList.append([
                    str(degree),
                    str(degree1),
                    str(self.parametersPanel.pnlVarStartP.Value),
                    str(self.parametersPanel.txtForwardTP.Value),
                    str(self.parametersPanel.txtForwardMP.Value),
                    str(distance.NauticalMiles),
                    str(distance.Kilometres),
                    str(degree2),
                    str(degree3),
                    str(self.parametersPanel.pnlVarFinishP.Value),
                    str(round(num, 4)),
                    str(round(num2, 4))
                ])
                GeoDetermineDlg.HistoryDataP.append(dataList)
                self.setDataInHistoryModel(dataList)
                self.method_28_P(degree2, degree3)