def btnConstruct_Click(self): qgsLayerTreeView = define._mLayerTreeView groupName = self.surfaceType layerTreeModel = qgsLayerTreeView.layerTreeModel() layerTreeGroup = layerTreeModel.rootGroup() rowCount = layerTreeModel.rowCount() groupExisting = False if rowCount > 0: for i in range(rowCount): qgsLayerTreeNode = layerTreeModel.index2node( layerTreeModel.index(i, 0)) if qgsLayerTreeNode.nodeType() == 0: qgsLayerTreeNode._class_ = QgsLayerTreeGroup if isinstance(qgsLayerTreeNode, QgsLayerTreeGroup ) and qgsLayerTreeNode.name() == groupName: groupExisting = True if groupExisting: if len(self.resultLayerList) > 0: QgisHelper.removeFromCanvas(define._canvas, self.resultLayerList) self.resultLayerList = [] else: QMessageBox.warning( self, "Warning", "Please remove \"" + self.surfaceType + "\" layer group from LayerTreeView.") return False return True
def btnConstruct_Click(self): if len(self.resultLayerList) > 0: QgisHelper.removeFromCanvas(define._canvas, self.resultLayerList) self.resultLayerList = [] try: point3d = self.parametersPanel.pnlTHR.getPoint3D() try: num = MathHelper.smethod_4( Unit.ConvertDegToRad( float(self.parametersPanel.txtRwyDir.Value) + 180)) except ValueError: raise UserWarning, "Runway Direction is invalide!" altitude = self.parametersPanel.pnlOCAH.method_3( Altitude(point3d.get_Z())) metres = altitude.Metres if (metres < 10): raise UserWarning, Messages.ERR_INSUFFICIENT_MINIMUM_ALTITUDE try: res, point3dCollection = self.method_37( point3d, num, metres, metres / math.tan( Unit.ConvertDegToRad( float(self.parametersPanel.txtDescAngle.Value. Degrees) - 1.12))) except ValueError: raise UserWarning, "DescAngle is invalide!" if (not res): return self.surfaceArea = PrimaryObstacleArea( PolylineArea(point3dCollection)) layer = AcadHelper.createVectorLayer("Visual Segment Surface") if (self.parametersPanel.cmbConstructionType.SelectedIndex != ConstructionType.Construct2D): face = [ point3dCollection.get_Item(0), point3dCollection.get_Item(1), point3dCollection.get_Item(2), point3dCollection.get_Item(3), point3dCollection.get_Item(0) ] AcadHelper.setGeometryAndAttributesInLayer(layer, face) # layer = QgisHelper.createPolylineLayer("Visual Segment Surface 3D", [(face, [])], []) else: face = point3dCollection face.append(point3dCollection[0]) AcadHelper.setGeometryAndAttributesInLayer(layer, face) # layer = QgisHelper.createPolylineLayer("Visual Segment Surface 2D", [(face, [])], []) QgisHelper.appendToCanvas(define._canvas, [layer], SurfaceTypes.VisualSegmentSurface) QgisHelper.zoomToLayers([layer]) self.resultLayerList = [layer] self.ui.btnEvaluate.setEnabled(True) except UserWarning as e: QMessageBox.warning(self, "Error", e.message)
def DrawCanvas(self): qgsLayerTreeView = define._mLayerTreeView groupName = self.surfaceType layerTreeModel = qgsLayerTreeView.layerTreeModel() layerTreeGroup = layerTreeModel.rootGroup() rowCount = layerTreeModel.rowCount() groupExisting = False if rowCount > 0: for i in range(rowCount): qgsLayerTreeNode = layerTreeModel.index2node( layerTreeModel.index(i, 0)) if qgsLayerTreeNode.nodeType() == 0: qgsLayerTreeNode._class_ = QgsLayerTreeGroup if isinstance(qgsLayerTreeNode, QgsLayerTreeGroup ) and qgsLayerTreeNode.name() == groupName: groupExisting = True if groupExisting: if len(self.resultLayerList) > 0: QgisHelper.removeFromCanvas(define._canvas, self.resultLayerList) self.resultLayerList = [] else: QtGui.QMessageBox.warning( self, "Warning", "Please remove \"" + self.surfaceType + "\" layer group from LayerTreeView.") return constructionLayer = AcadHelper.createVectorLayer(self.surfaceType) if self.comboBox.currentIndex( ) == ProtectionAreaType.Primary or self.comboBox.currentIndex( ) == ProtectionAreaType.Secondary: AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, self.area.PreviewArea, True) elif self.comboBox.currentIndex( ) == ProtectionAreaType.PrimaryAndSecondary: AcadHelper.setGeometryAndAttributesInLayer( constructionLayer, self.area.primaryArea.PreviewArea, True) AcadHelper.setGeometryAndAttributesInLayer( constructionLayer, self.area.secondaryArea1.PreviewArea, True) AcadHelper.setGeometryAndAttributesInLayer( constructionLayer, self.area.secondaryArea2.PreviewArea, True) else: for obstacleArea in self.area: AcadHelper.setGeometryAndAttributesInLayer( constructionLayer, obstacleArea.PreviewArea, True) QgisHelper.appendToCanvas(define._canvas, [constructionLayer], self.surfaceType) self.resultLayerList = [constructionLayer]
def btnConstruct2_Click(self): qgsLayerTreeView = define._mLayerTreeView groupName = self.surfaceType2 layerTreeModel = qgsLayerTreeView.layerTreeModel() layerTreeGroup = layerTreeModel.rootGroup() rowCount = layerTreeModel.rowCount() groupExisting = False if rowCount > 0: for i in range(rowCount): qgsLayerTreeNode = layerTreeModel.index2node( layerTreeModel.index(i, 0)) if qgsLayerTreeNode.nodeType() == 0: qgsLayerTreeNode._class_ = QgsLayerTreeGroup if isinstance(qgsLayerTreeNode, QgsLayerTreeGroup ) and qgsLayerTreeNode.name() == groupName: groupExisting = True if groupExisting: if len(self.resultLayerList2) > 0: QgisHelper.removeFromCanvas(define._canvas, self.resultLayerList2) self.resultLayerList2 = [] else: QMessageBox.warning( self, "Warning", "Please remove \"" + self.surfaceType2 + "\" layer group from LayerTreeView.") return num = None num1 = None line = None polyline = None point3d = None point3d1 = None point3d2 = None point3d3 = None point3d4 = None point3d5 = None point3d6 = None point3d7 = None point3d8 = None ficorResult = None point = [] value = None resultPolylineAreaList = [] # if (!AcadHelper.Ready) # { # return; # } # if (!self.method_27(true)) # { # return; # } # string constructionLayer = base.ConstructionLayer; point3d9 = self.parametersPanel.pnlTrackingPosition.Point3d point3d10 = self.parametersPanel.pnlIntersectingPosition.Point3d value1 = float(self.parametersPanel.txtTrackingRadialTrack.Value) value2 = float(self.parametersPanel.txtIntersectingRadialTrack.Value) num2 = Unit.ConvertDegToRad(value1) num3 = Unit.ConvertDegToRad(value2) if (self.parametersPanel.cmbTrackingType.currentIndex() != 0): num = Unit.ConvertDegToRad(2.4) if ( self.parametersPanel.cmbTrackingType.currentIndex() != 1 ) else Unit.ConvertDegToRad(6.9) else: num = Unit.ConvertDegToRad(5.2) num1 = Unit.ConvertDegToRad(6.2) if ( self.parametersPanel.cmbIntersectingType.currentIndex() != 0 ) else Unit.ConvertDegToRad(4.5) num4 = num2 + num point3d11 = MathHelper.distanceBearingPoint(point3d9, num4, 100) num5 = num2 - num point3d12 = MathHelper.distanceBearingPoint(point3d9, num5, 100) point3d13 = MathHelper.distanceBearingPoint(point3d9, num2, 100) point3d = MathHelper.getIntersectionPoint( point3d9, point3d13, point3d10, MathHelper.distanceBearingPoint(point3d10, num3, 100)) if (self.parametersPanel.cmbIntersectingType.currentIndex() >= 2): metres = Distance( float(self.parametersPanel.txtIntersectingDistance.text()), DistanceUnits.NM).Metres if (self.parametersPanel.chb0dmeAtThr.isChecked()): value = Distance( float(self.parametersPanel.txtDmeOffset.text())) metres = metres + value.Metres num6 = 460 + metres * 0.0125 num7 = metres + num6 num8 = metres - num6 if (MathHelper.smethod_102(point3d9, point3d10)): point3d14 = MathHelper.distanceBearingPoint( point3d9, num4, num8) point3d15 = MathHelper.distanceBearingPoint( point3d9, num2, num8) point3d16 = MathHelper.distanceBearingPoint( point3d9, num5, num8) point3d17 = MathHelper.distanceBearingPoint( point3d9, num5, num7) point3d18 = MathHelper.distanceBearingPoint( point3d9, num2, num7) point3d19 = MathHelper.distanceBearingPoint( point3d9, num4, num7) point = [point3d14, point3d16, point3d17, point3d19] polyline = AcadHelper.smethod_126(point) polyline.SetBulgeAt( 0, MathHelper.smethod_60(point3d14, point3d15, point3d16)) polyline.SetBulgeAt( 2, MathHelper.smethod_60(point3d17, point3d18, point3d19)) polyline.set_Closed(True) resultPolylineAreaList.append(polyline) # AcadHelper.smethod_18(transaction, blockTableRecord, polyline, constructionLayer); point3d14 = MathHelper.distanceBearingPoint( point3d9, num2, num8) point3d15 = MathHelper.distanceBearingPoint( point3d9, num2, num7) resultPolylineAreaList.append( PolylineArea([point3d14, point3d15])) # line = new Line(point3d14, point3d15); # AcadHelper.smethod_18(transaction, blockTableRecord, line, constructionLayer); point3d14 = MathHelper.distanceBearingPoint( point3d9, num4, metres) point3d15 = MathHelper.distanceBearingPoint( point3d9, num2, metres) point3d16 = MathHelper.distanceBearingPoint( point3d9, num5, metres) point = [point3d14, point3d16] polyline = AcadHelper.smethod_126(point) polyline.SetBulgeAt( 0, MathHelper.smethod_60(point3d14, point3d15, point3d16)) resultPolylineAreaList.append(polyline) # AcadHelper.smethod_18(transaction, blockTableRecord, polyline, constructionLayer); else: ficorResult1 = self.method_37(point3d10, num2, point3d9, point3d13, num8, FicorInput.C) ficorResult2 = self.method_37(point3d10, num2, point3d9, point3d13, metres, FicorInput.C) ficorResult3 = self.method_37(point3d10, num2, point3d9, point3d13, num7, FicorInput.C) if (ficorResult1.Status != FicorStatus.TWO and ficorResult2.Status != FicorStatus.TWO): if (ficorResult3.Status == FicorStatus.TWO): ficorResult = FicorResult(None, FicorStatus.TWO) else: ficorResult = FicorResult(None, ficorResult2.Status) else: ficorResult = FicorResult(None, FicorStatus.TWO) if (ficorResult.Status != FicorStatus.NID): ficorInput = FicorInput.F num9 = 1 if (ficorResult.Status == FicorStatus.TWO): QMessageBox.warning( self, "Infomation", Messages.TWO_POSSIBLE_FIX_POSITIONS) ficorInput = FicorInput.L num9 = 2 num10 = 0 while (num10 < num9): ficorResult4 = self.method_37(point3d10, num4, point3d9, point3d11, num8, ficorInput) ficorResult5 = self.method_37(point3d10, num2, point3d9, point3d13, num8, ficorInput) ficorResult6 = self.method_37(point3d10, num5, point3d9, point3d12, num8, ficorInput) ficorResult7 = self.method_37(point3d10, num4, point3d9, point3d11, metres, ficorInput) ficorResult8 = self.method_37(point3d10, num2, point3d9, point3d13, metres, ficorInput) ficorResult9 = self.method_37(point3d10, num5, point3d9, point3d12, metres, ficorInput) ficorResult10 = self.method_37(point3d10, num4, point3d9, point3d11, num7, ficorInput) ficorResult11 = self.method_37(point3d10, num2, point3d9, point3d13, num7, ficorInput) ficorResult12 = self.method_37(point3d10, num5, point3d9, point3d12, num7, ficorInput) if (ficorResult4.Status == FicorStatus.NID or ficorResult5.Status == FicorStatus.NID or ficorResult6.Status == FicorStatus.NID or ficorResult7.Status == FicorStatus.NID or ficorResult9.Status == FicorStatus.NID or ficorResult10.Status == FicorStatus.NID or ficorResult11.Status == FicorStatus.NID or ficorResult12.Status == FicorStatus.NID or ficorResult8.Status == FicorStatus.NID): eRRFAILEDTOCONSTRUCTTHEFIXAUTOMATICALLY = Messages.ERR_FAILED_TO_CONSTRUCT_THE_FIX_AUTOMATICALLY value = Distance( float(self.parametersPanel. txtIntersectingDistance.text()), DistanceUnits.NM) str000 = str(round(value.Metres, 4)) + "m" value = str(round(Distance(num6).Metres, 4)) + "m" QMessageBox.warning( self, "Error", eRRFAILEDTOCONSTRUCTTHEFIXAUTOMATICALLY % (str000, value)) # ErrorMessageBox.smethod_0(self, string.Format(eRRFAILEDTOCONSTRUCTTHEFIXAUTOMATICALLY, str, value.method_0(":m"))); return elif (MathHelper.calcDistance(point3d9, ficorResult8.Point) < MathHelper.calcDistance( ficorResult5.Point, ficorResult8.Point)): QMessageBox.warning( self, "Error", Messages. ERR_FIX_TOO_CLOSE_USE_OVERHEAD_TOLERANCE) # ErrorMessageBox.smethod_0(self, Messages.ERR_FIX_TOO_CLOSE_USE_OVERHEAD_TOLERANCE); return else: point = [ ficorResult4.Point, ficorResult6.Point, ficorResult12.Point, ficorResult10.Point ] polyline = AcadHelper.smethod_126(point) polyline.SetBulgeAt( 0, MathHelper.smethod_60(ficorResult4.Point, ficorResult5.Point, ficorResult6.Point)) polyline.SetBulgeAt( 2, MathHelper.smethod_60(ficorResult12.Point, ficorResult11.Point, ficorResult10.Point)) polyline.set_Closed(True) resultPolylineAreaList.append(polyline) # AcadHelper.smethod_18(transaction, blockTableRecord, polyline, constructionLayer); resultPolylineAreaList.append( PolylineArea( [ficorResult5.Point, ficorResult11.Point])) # line = new Line(ficorResult5.Point, ficorResult11.Point); # AcadHelper.smethod_18(transaction, blockTableRecord, line, constructionLayer); point = [ficorResult7.Point, ficorResult9.Point] polyline = AcadHelper.smethod_126(point) polyline.SetBulgeAt( 0, MathHelper.smethod_60(ficorResult7.Point, ficorResult8.Point, ficorResult9.Point)) resultPolylineAreaList.append(polyline) # AcadHelper.smethod_18(transaction, blockTableRecord, polyline, constructionLayer); if (ficorResult.Status == FicorStatus.TWO): ficorInput = FicorInput.S num10 += 1 else: QMessageBox.warning( self, "Error", Messages. ERR_RADIAL_TRACK_DME_DISTANCE_DO_NOT_INTERSECT) # ErrorMessageBox.smethod_0(self, Messages.ERR_RADIAL_TRACK_DME_DISTANCE_DO_NOT_INTERSECT); return elif (point3d == None): QMessageBox.warning(self, "Error", Messages.ERR_RADIALS_TRACKS_ARE_PARALLEL) # ErrorMessageBox.smethod_0(self, Messages.ERR_RADIALS_TRACKS_ARE_PARALLEL); return elif (MathHelper.smethod_99(MathHelper.getBearing(point3d9, point3d), num2, 0.001)): point3d20 = MathHelper.distanceBearingPoint( point3d10, num3 + num1, 100) point3d21 = MathHelper.distanceBearingPoint( point3d10, num3 - num1, 100) point3d1 = MathHelper.getIntersectionPoint(point3d9, point3d12, point3d10, point3d20) point3d2 = MathHelper.getIntersectionPoint(point3d9, point3d12, point3d10, point3d21) point3d3 = MathHelper.getIntersectionPoint(point3d9, point3d11, point3d10, point3d21) point3d4 = MathHelper.getIntersectionPoint(point3d9, point3d11, point3d10, point3d20) point3d5 = MathHelper.getIntersectionPoint(point3d9, point3d, point3d10, point3d20) point3d6 = MathHelper.getIntersectionPoint(point3d9, point3d, point3d10, point3d21) point3d7 = MathHelper.getIntersectionPoint(point3d9, point3d11, point3d10, point3d) point3d8 = MathHelper.getIntersectionPoint(point3d9, point3d12, point3d10, point3d) if (MathHelper.calcDistance(point3d9, point3d) < MathHelper.calcDistance(point3d5, point3d) or MathHelper.calcDistance(point3d10, point3d) < MathHelper.calcDistance(point3d5, point3d) or MathHelper.calcDistance(point3d9, point3d) < MathHelper.calcDistance(point3d8, point3d) or MathHelper.calcDistance(point3d10, point3d) < MathHelper.calcDistance(point3d8, point3d)): QMessageBox.warning( self, "Error", Messages.ERR_FIX_TOO_CLOSE_USE_OVERHEAD_TOLERANCE) # ErrorMessageBox.smethod_0(self, Messages.ERR_FIX_TOO_CLOSE_USE_OVERHEAD_TOLERANCE); return else: resultPolylineAreaList.append( PolylineArea([point3d5, point3d6])) # line = new Line(point3d5, point3d6); # AcadHelper.smethod_18(transaction, blockTableRecord, line, constructionLayer); resultPolylineAreaList.append( PolylineArea([point3d7, point3d8])) # line = new Line(point3d7, point3d8); # AcadHelper.smethod_18(transaction, blockTableRecord, line, constructionLayer); point = [point3d1, point3d2, point3d3, point3d4] polyline = AcadHelper.smethod_126(point) polyline.set_Closed(True) resultPolylineAreaList.append(polyline) # AcadHelper.smethod_18(transaction, blockTableRecord, polyline, constructionLayer); else: QMessageBox.warning(self, "Error", Messages.ERR_RADIALS_TRACKS_DO_NOT_INTERSECT) # ErrorMessageBox.smethod_0(self, Messages.ERR_RADIALS_TRACKS_DO_NOT_INTERSECT); return mapUnits = define._canvas.mapUnits() constructionLayer = AcadHelper.createVectorLayer( SurfaceTypes.FixConstruction, QGis.Line) for polylinrArea0 in resultPolylineAreaList: AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, polylinrArea0) QgisHelper.appendToCanvas(define._canvas, [constructionLayer], SurfaceTypes.FixConstruction, True) self.resultLayerList2 = [constructionLayer] QgisHelper.zoomToLayers(self.resultLayerList2)
def btnConstruct_Click(self): qgsLayerTreeView = define._mLayerTreeView groupName = self.surfaceType1 layerTreeModel = qgsLayerTreeView.layerTreeModel() layerTreeGroup = layerTreeModel.rootGroup() rowCount = layerTreeModel.rowCount() groupExisting = False if rowCount > 0: for i in range(rowCount): qgsLayerTreeNode = layerTreeModel.index2node( layerTreeModel.index(i, 0)) if qgsLayerTreeNode.nodeType() == 0: qgsLayerTreeNode._class_ = QgsLayerTreeGroup if isinstance(qgsLayerTreeNode, QgsLayerTreeGroup ) and qgsLayerTreeNode.name() == groupName: groupExisting = True if groupExisting: if len(self.resultLayerList1) > 0: QgisHelper.removeFromCanvas(define._canvas, self.resultLayerList1) self.resultLayerList1 = [] else: QMessageBox.warning( self, "Warning", "Please remove \"" + self.surfaceType1 + "\" layer group from LayerTreeView.") return num = None num1 = None num2 = None num3 = None point3d = None resultPolylineAreaList = [] # if (!AcadHelper.Ready) # { # return; # } # if (!self.method_27(true)) # { # return; # } # string constructionLayer = base.ConstructionLayer; point3d1 = self.parametersPanel.pnlNavAid.Point3d value = float(self.parametersPanel.txtTrackRadial.Value) metres = Altitude(float(self.parametersPanel.txtAltitude.text()), AltitudeUnits.FT).Metres z = metres - point3d1.get_Z() if (self.parametersPanel.cmbNavAidType.currentIndex() != 0): num = 450 - value + 90 num1 = 15 num2 = 25 num3 = z * 0.839099631 else: num = 450 - value + 90 num1 = 5 num2 = 15 num3 = z * 1.191753593 num4 = Unit.ConvertDegToRad(num1) num5 = Unit.ConvertDegToRad(360 - num1) num6 = Unit.ConvertDegToRad(180 - num2) num7 = Unit.ConvertDegToRad(180 + num2) num8 = 0 num9 = Unit.ConvertDegToRad(180) point3d2 = MathHelper.distanceBearingPoint(point3d1, num4, num3) point3d3 = MathHelper.distanceBearingPoint(point3d1, num5, num3) point3d = MathHelper.smethod_68( point3d2, MathHelper.distanceBearingPoint(point3d1, num8, num3), point3d3) if (point3d == None): QMessageBox.warning(self, "Error", Messages.ERR_FAILED_TO_CALCULATE_CENTER_POINT) return # throw new Exception(Messages.ERR_FAILED_TO_CALCULATE_CENTER_POINT); num10 = MathHelper.smethod_55( point3d2, point3d3, MathHelper.calcDistance(point3d2, point3d)) point3d2 = MathHelper.distanceBearingPoint(point3d1, num6, num3) point3d3 = MathHelper.distanceBearingPoint(point3d1, num7, num3) point3d = MathHelper.smethod_68( point3d2, MathHelper.distanceBearingPoint(point3d1, num9, num3), point3d3) if (point3d == None): QMessageBox.warning(self, "Error", Messages.ERR_FAILED_TO_CALCULATE_CENTER_POINT) # throw new Exception(Messages.ERR_FAILED_TO_CALCULATE_CENTER_POINT); num11 = MathHelper.smethod_55( point3d2, point3d3, MathHelper.calcDistance(point3d2, point3d)) matrix3d = Matrix3d.Rotation(Unit.ConvertDegToRad(num), Vector3d(0, 0, 1), point3d1) point3d2 = MathHelper.distanceBearingPoint(point3d1, num8, num3) point3d3 = MathHelper.distanceBearingPoint(point3d1, num9, num3) line = PolylineArea([point3d2, point3d3]) resultPolylineAreaList.append( self.TransformBy(line, Unit.ConvertDegToRad(value), self.parametersPanel.pnlNavAid.Point3d) ) #.TransformBy(matrix3d)) point3d2 = MathHelper.distanceBearingPoint(point3d1, num6, num3) point3d3 = MathHelper.distanceBearingPoint(point3d1, num4, num3) point3d4 = MathHelper.distanceBearingPoint(point3d1, num5, num3) point3d5 = MathHelper.distanceBearingPoint(point3d1, num7, num3) point3dArray = [point3d2, point3d3, point3d4, point3d5, point3d2] polyline = AcadHelper.smethod_126(point3dArray) if self.parametersPanel.cmbNavAidType.currentIndex() == 0: num10 = 0.0436609429083 num11 = 0.131652497586 else: num10 = 0.131652497586 num11 = 0.221694662642 polyline.SetBulgeAt(1, num10) polyline.SetBulgeAt(3, num11) # polyline.set_Elevation(point3d1.get_Z()); resultPolylineAreaList.append( self.TransformBy(polyline, Unit.ConvertDegToRad(value), self.parametersPanel.pnlNavAid.Point3d) ) #polyline.TransformBy(matrix3d)) # polyline.TransformBy(matrix3d); # AcadHelper.smethod_18(transaction, blockTableRecord, polyline, constructionLayer); # transaction.Commit(); # AcadHelper.smethod_5(); mapUnits = define._canvas.mapUnits() constructionLayer = AcadHelper.createVectorLayer( SurfaceTypes.OverheadTolerance, QGis.Line) for polylinrArea0 in resultPolylineAreaList: AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, polylinrArea0) QgisHelper.appendToCanvas(define._canvas, [constructionLayer], SurfaceTypes.OverheadTolerance, True) self.resultLayerList1 = [constructionLayer] QgisHelper.zoomToLayers(self.resultLayerList1)