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 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 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 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."
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