def btnConstruct_Click(self):
        flag = FlightPlanBaseSimpleDlg.btnConstruct_Click(self)
        if not flag:
            return
        num = 0.0
        point3d = Point3D()
        point3d1 = Point3D()
        if not self.method_27(True):
            return


        
        point3d2 = self.parametersPanel.pnlTHR.getPoint3D()
        point3d3 = self.parametersPanel.pnlNavAid.getPoint3D()
        num1 = Unit.ConvertDegToRad(float(self.parametersPanel.txtDirection.Value))
        point3d4 = MathHelper.distanceBearingPoint(point3d2, num1 + 3.14159265358979, 1400)
        num2 = -1
        if MathHelper.smethod_115(point3d3, point3d2, point3d4):
            num2 = 1
        point3d5 = MathHelper.distanceBearingPoint(point3d4, num2 * 1.5707963267949 + num1, 150)
        point3d6 = MathHelper.distanceBearingPoint(point3d5, num1 + 3.14159265358979, 17120)
        if self.parametersPanel.cmbCategory.currentIndex() != 1:
            num = 0.267949192 
        elif self.parametersPanel.cmbCategory.currentIndex() == 1: 
            num = 0.577350269
        point3d7 = MathHelper.distanceBearingPoint(point3d6, num1 - num2 * 1.5707963267949, 150 + num * 17120)
        MathHelper.distanceBearingPoint(point3d5, num1, 150 / num)
        point3d = MathHelper.getIntersectionPoint(point3d3, MathHelper.distanceBearingPoint(point3d3, num1 + 1.5707963267949, 100), point3d2, point3d4)
        if point3d == None:
            raise UserWarning, Messages.ERR_FAILED_TO_CALCULATE_INTERSECTION_POINT
        num3 = MathHelper.calcDistance(point3d3, point3d) / 0.087488664
        if MathHelper.calcDistance(point3d, point3d4) >= num3:
            point3d1 = point3d4
            MathHelper.distanceBearingPoint(point3d6, num1 - num2 * 1.5707963267949, 1525.321791)
        else:
            point3d1 = MathHelper.distanceBearingPoint(point3d, num1 + 3.14159265358979, num3)
            MathHelper.distanceBearingPoint(point3d6, num1 - num2 * 1.5707963267949, 150 + 0.087488664 * (17120 - MathHelper.calcDistance(point3d4, point3d1)))
        MathHelper.distanceBearingPoint(point3d4, num1 + 3.14159265358979, 17120);

        constructionLayer = AcadHelper.createVectorLayer("AAConstruction", QGis.Line)
        AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, PolylineArea([point3d7, point3d4]))
        AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, PolylineArea([point3d1, point3d4, point3d5]))

        QgisHelper.appendToCanvas(define._canvas, [constructionLayer], SurfaceTypes.ApproachAlignment)
        QgisHelper.zoomToLayers([constructionLayer])
        self.resultLayerList = [constructionLayer]
Beispiel #2
0
    def btnConstruct_Click(self):
        flag = FlightPlanBaseSimpleDlg.btnConstruct_Click(self)
        if not flag:
            return

        # mapUnits = define._canvas.mapUnits()
        constructionLayer = None
        if self.parametersPanel.cmbConstructionType.currentText() == "2D":
            constructionLayer = AcadHelper.createVectorLayer(SurfaceTypes.DmeUpdateArea)
        #     if define._mapCrs == None:
        #         if mapUnits == QGis.Meters:
        #             constructionLayer = QgsVectorLayer("linestring?crs=EPSG:32633", SurfaceTypes.DmeUpdateArea, "memory")
        #         else:
        #             constructionLayer = QgsVectorLayer("linestring?crs=EPSG:4326", SurfaceTypes.DmeUpdateArea, "memory")
        #     else:
        #         constructionLayer = QgsVectorLayer("linestring?crs=%s"%define._mapCrs.authid (), SurfaceTypes.DmeUpdateArea, "memory")
        #     shpPath = ""
        #     if define.obstaclePath != None:
        #         shpPath = define.obstaclePath
        #     elif define.xmlPath != None:
        #         shpPath = define.xmlPath
        #     else:
        #         shpPath = define.appPath
        #     er = QgsVectorFileWriter.writeAsVectorFormat(constructionLayer, shpPath + "/" + QString(SurfaceTypes.DmeUpdateArea).replace(" ", "") + ".shp", "utf-8", constructionLayer.crs())
        #     constructionLayer = QgsVectorLayer(shpPath + "/" + QString(SurfaceTypes.DmeUpdateArea).replace(" ", "") + ".shp", SurfaceTypes.DmeUpdateArea, "ogr")

            point3d = self.parametersPanel.pnlDme1.Point3d
            point3d1 = self.parametersPanel.pnlDme2.Point3d
            num = MathHelper.calcDistance(point3d, point3d1)
            num1 = num * 0.5
            num2 = math.sqrt(num * num - num1 * num1)
            num3 = MathHelper.getBearing(point3d, point3d1)
            point3d2 = MathHelper.distanceBearingPoint(point3d, num3, 0.5 * num)
            point3d3 = MathHelper.distanceBearingPoint(point3d2, num3 - 1.5707963267949, num2)
            point3d4 = MathHelper.distanceBearingPoint(point3d2, num3 + 1.5707963267949, num2)
            distance = Distance(float(self.parametersPanel.txtDoc1.text()), DistanceUnits.NM)
            metres = distance.Metres
            distance1 = Distance(float(self.parametersPanel.txtDoc2.text()), DistanceUnits.NM)
            metres1 = distance1.Metres
            
            circlePointList = MathHelper.constructCircle(point3d, metres, 100)
            circlePointList1 = MathHelper.constructCircle(point3d1, metres1, 100)
            
            
            circlePointList2 = MathHelper.constructCircle(point3d3, num, 100)
            circlePointList3 = MathHelper.constructCircle(point3d4, num, 100)
            circlePointList4 = MathHelper.constructCircle(point3d, 1900, 100)
            circlePointList5 = MathHelper.constructCircle(point3d1, 1900, 100)
            
            # constructionLayer.startEditing()
            
            polygon = QgsGeometry.fromPolygon([circlePointList])
    #         feature0 = QgsFeature()
    #         feature0.setGeometry(polygon)
    #         constructionLayer.addFeature(feature0)
            polygon = QgsGeometry.fromPolygon([circlePointList])
            polygon1 = QgsGeometry.fromPolygon([circlePointList1])
            polygon2 = QgsGeometry.fromPolygon([circlePointList2])
            polygon3 = QgsGeometry.fromPolygon([circlePointList3])
            polygon4 = QgsGeometry.fromPolygon([circlePointList4])
            polygon5 = QgsGeometry.fromPolygon([circlePointList5])
            
            polygon0 = polygon.intersection(polygon1)
            polygon0 = polygon0.intersection(polygon2)
            polygon0 = polygon0.difference(polygon3)
            polygon0 = polygon0.difference(polygon4)
            polygon0 = polygon0.difference(polygon5)
            
            pointArray = QgsGeometry.asPolygon(polygon0)
            
            # feature1 = QgsFeature()
            # feature1.setGeometry(QgsGeometry.fromPolyline(pointArray[0]))
            # constructionLayer.addFeature(feature1)
            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, pointArray[0])

            
            polygon0 = polygon.intersection(polygon1)
            polygon0 = polygon0.intersection(polygon3)
            polygon0 = polygon0.difference(polygon2)
            polygon0 = polygon0.difference(polygon4)
            polygon0 = polygon0.difference(polygon5)
            
            pointArray = QgsGeometry.asPolygon(polygon0)
            
            # feature1 = QgsFeature()
            # feature1.setGeometry(QgsGeometry.fromPolyline(pointArray[0]))
            #
            # constructionLayer.addFeature(feature1)
            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, pointArray[0])

            
            
            
            # constructionLayer.commitChanges()
        else:
            constructionLayer = AcadHelper.createVectorLayer(SurfaceTypes.DmeUpdateArea, QGis.Polygon)
            # if define._mapCrs == None:
            #     if mapUnits == QGis.Meters:
            #         constructionLayer = QgsVectorLayer("polygon?crs=EPSG:32633", SurfaceTypes.DmeUpdateArea, "memory")
            #     else:
            #         constructionLayer = QgsVectorLayer("polygon?crs=EPSG:4326", SurfaceTypes.DmeUpdateArea, "memory")
            # else:
            #     constructionLayer = QgsVectorLayer("polygon?crs=%s"%define._mapCrs.authid (), SurfaceTypes.DmeUpdateArea, "memory")
            # shpPath = ""
            # if define.obstaclePath != None:
            #     shpPath = define.obstaclePath
            # elif define.xmlPath != None:
            #     shpPath = define.xmlPath
            # else:
            #     shpPath = define.appPath
            # er = QgsVectorFileWriter.writeAsVectorFormat(constructionLayer, shpPath + "/" + QString(SurfaceTypes.DmeUpdateArea).replace(" ", "") + ".shp", "utf-8", constructionLayer.crs())
            # constructionLayer = QgsVectorLayer(shpPath + "/" + QString(SurfaceTypes.DmeUpdateArea).replace(" ", "") + ".shp", SurfaceTypes.DmeUpdateArea, "ogr")

            point3d = self.parametersPanel.pnlDme1.Point3d
            point3d1 = self.parametersPanel.pnlDme2.Point3d
            num = MathHelper.calcDistance(point3d, point3d1)
            num1 = num * 0.5
            num2 = math.sqrt(num * num - num1 * num1)
            num3 = MathHelper.getBearing(point3d, point3d1)
            point3d2 = MathHelper.distanceBearingPoint(point3d, num3, 0.5 * num)
            point3d3 = MathHelper.distanceBearingPoint(point3d2, num3 - 1.5707963267949, num2)
            point3d4 = MathHelper.distanceBearingPoint(point3d2, num3 + 1.5707963267949, num2)
            distance = Distance(float(self.parametersPanel.txtDoc1.text()), DistanceUnits.NM)
            metres = distance.Metres
            distance1 = Distance(float(self.parametersPanel.txtDoc2.text()), DistanceUnits.NM)
            metres1 = distance1.Metres
            
            circlePointList = MathHelper.constructCircle(point3d, metres, 100)
            circlePointList1 = MathHelper.constructCircle(point3d1, metres1, 100)
            
            
            circlePointList2 = MathHelper.constructCircle(point3d3, num, 100)
            circlePointList3 = MathHelper.constructCircle(point3d4, num, 100)
            circlePointList4 = MathHelper.constructCircle(point3d, 1900, 100)
            circlePointList5 = MathHelper.constructCircle(point3d1, 1900, 100)
            
            # constructionLayer.startEditing()
            
            polygon = QgsGeometry.fromPolygon([circlePointList])
    #         feature0 = QgsFeature()
    #         feature0.setGeometry(polygon)
    #         constructionLayer.addFeature(feature0)
            polygon = QgsGeometry.fromPolygon([circlePointList])
            polygon1 = QgsGeometry.fromPolygon([circlePointList1])
            polygon2 = QgsGeometry.fromPolygon([circlePointList2])
            polygon3 = QgsGeometry.fromPolygon([circlePointList3])
            polygon4 = QgsGeometry.fromPolygon([circlePointList4])
            polygon5 = QgsGeometry.fromPolygon([circlePointList5])
            
            polygon0 = polygon.intersection(polygon1)
            polygon0 = polygon0.intersection(polygon2)
            polygon0 = polygon0.difference(polygon3)
            polygon0 = polygon0.difference(polygon4)
            polygon0 = polygon0.difference(polygon5)
            # feature1 = QgsFeature()
            # feature1.setGeometry(polygon0)
            # constructionLayer.addFeature(feature1)
            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, polygon0.asPolygon()[0])

            
            polygon0 = polygon.intersection(polygon1)
            polygon0 = polygon0.intersection(polygon3)
            polygon0 = polygon0.difference(polygon2)
            polygon0 = polygon0.difference(polygon4)
            polygon0 = polygon0.difference(polygon5)
            # feature2 = QgsFeature()
            # feature2.setGeometry(polygon0)
            # constructionLayer.addFeature(feature2)

            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, polygon0.asPolygon()[0])
            
            
            
            # constructionLayer.commitChanges()
        
        QgisHelper.appendToCanvas(define._canvas, [constructionLayer], SurfaceTypes.DmeUpdateArea)
        self.resultLayerList = [constructionLayer]
        QgisHelper.zoomToLayers([constructionLayer])
    def btnConstruct_Click(self):
        flag = FlightPlanBaseSimpleDlg.btnConstruct_Click(self)
        if not flag:
            return
        constructionLayer = AcadHelper.createVectorLayer(SurfaceTypes.DmeTolerance, QGis.Line)
        point3d1 = self.parametersPanel.pnlDME.Point3d
        circleAreaList = []
        
#         length = self.groundDistance.Metres / 5
# #         rectangle = QgsRectangle(point3d1.get_X() - length / 2, point3d1.get_Y() - length / 2, point3d1.get_X() + length / 2, point3d1.get_Y() + length / 2,)
#         point1 = Point3D(point3d1.get_X() - length / 2, point3d1.get_Y() + length / 2)
#         point2 = Point3D(point3d1.get_X() - length / 2, point3d1.get_Y() - length / 2)
        captionCircleLine = []
        centerPoint = None
        radius = 0.0
        arc = None;
        resultPoint3dArrayList = []
        if (self.groundDistance.Metres > 0):
            metres = self.dmeTolerance.valueMetres / 1.7;
            if (self.parametersPanel.cmbConstructionType.currentIndex() != 0):
                num1 = Unit.ConvertDegToRad(float(self.parametersPanel.pnlRadial.Value));
                num2 = math.asin(min([1 / self.groundDistance.NauticalMiles, 1]));
                num3 = num1 + num2
                num4 = num1 - num2
                # arc = PolylineArea()
                # arc.Add(PolylineAreaPoint(point3d1, self.groundDistance.Metres))
                arc = MathHelper.constructArc(point3d1, self.groundDistance.Metres, num3, num4, 30);
                point3d = MathHelper.distanceBearingPoint(point3d1, num1, self.groundDistance.Metres);
                
                captionCircleLine = [MathHelper.distanceBearingPoint(point3d, MathHelper.getBearing(point3d, point3d1) + math.pi / 2, self.groundDistance.Metres / 20), MathHelper.distanceBearingPoint(point3d, MathHelper.getBearing(point3d, point3d1) - math.pi / 2, self.groundDistance.Metres / 20)]
                num = -num1;
                if (self.parametersPanel.chbDrawRadial.isChecked()):
                    line = PolylineArea([point3d1, point3d]);
                    resultPoint3dArrayList.append([point3d1, point3d])
#                     AcadHelper.smethod_18(transaction, blockTableRecord, line, constructionLayer);
            else:
                arc = MathHelper.constructCircle(point3d1, self.groundDistance.Metres, 50);
                circleAreaList.append(PolylineArea(None, point3d1, self.groundDistance.Metres))
                centerPoint = point3d1
                radius = self.groundDistance.Metres
                point3d = MathHelper.distanceBearingPoint(point3d1, 0, self.groundDistance.Metres);
                
                length = self.groundDistance.Metres / 5
#                 rectangle = QgsRectangle(point3d1.get_X() - length / 2, point3d1.get_Y() - length / 2, point3d1.get_X() + length / 2, point3d1.get_Y() + length / 2,)
                point1 = MathHelper.distanceBearingPoint(point3d, Unit.ConvertDegToRad(270), length / 4)#Point3D(point3d.get_X() - length / 4, point3d.get_Y())
                point2 = MathHelper.distanceBearingPoint(point3d, Unit.ConvertDegToRad(90), length / 4)#Point3D(point3d.get_X() + length / 4, point3d.get_Y())
                captionCircleLine = [point1, point2]
                num = 0;
            resultPoint3dArrayList.append(arc)
#             AcadHelper.smethod_18(transaction, blockTableRecord, arc, constructionLayer);
            if (self.parametersPanel.chbWriteText.isChecked()):
                nauticalMiles = self.groundDistance.NauticalMiles;
#                 DBText dBText = AcadHelper.smethod_138(string.Format("{0} DME", nauticalMiles.ToString("0.#")), point3d, metres, 1);
#                 dBText.set_Rotation(num);
#                 AcadHelper.smethod_18(transaction, blockTableRecord, dBText, constructionLayer);
        if (self.parametersPanel.chbDrawDmeTol.isVisible() and self.parametersPanel.chbDrawDmeTol.isChecked() and self.dmeTolerance.IsValid() and arc != None):
            offsetCurf = QgisHelper.offsetCurve(arc, self.dmeTolerance.Metres)
            if self.parametersPanel.cmbConstructionType.currentIndex() == 0:
                circleAreaList.append(PolylineArea(None, centerPoint, radius + self.dmeTolerance.Metres))
            if (self.parametersPanel.cmbConstructionType.currentIndex() == 0):
                endPoint = offsetCurf[0]
                offsetCurf.append(endPoint)
            resultPoint3dArrayList.append(offsetCurf)
#             foreach (Entity offsetCurf in arc.GetOffsetCurves(self.dmeTolerance.Metres))
#             {
#                 AcadHelper.smethod_19(transaction, blockTableRecord, offsetCurf, constructionLayer, 5);
#             }
            entity = QgisHelper.offsetCurve(arc, -(self.dmeTolerance.Metres + self.slantTolerance.Metres))
            if self.parametersPanel.cmbConstructionType.currentIndex() == 0:
                circleAreaList.append(PolylineArea(None, centerPoint, radius -(self.dmeTolerance.Metres + self.slantTolerance.Metres)))
            if (self.parametersPanel.cmbConstructionType.currentIndex() == 0):
                endPoint = entity[0]
                entity.append(endPoint)
            resultPoint3dArrayList.append(entity)
#             foreach (Entity entity in arc.GetOffsetCurves(-(self.dmeTolerance.Metres + self.slantTolerance.Metres)))
#             {
#                 AcadHelper.smethod_19(transaction, blockTableRecord, entity, constructionLayer, 5);
#             }
#         }
        if (self.parametersPanel.chbDrawSlantTol.isVisible() and self.parametersPanel.chbDrawSlantTol.isChecked() and self.slantTolerance.IsValid() and arc != None):
            offsetCurf1 = QgisHelper.offsetCurve(arc, -self.slantTolerance.Metres)
            if self.parametersPanel.cmbConstructionType.currentIndex() == 0:
                circleAreaList.append(PolylineArea(None, centerPoint, radius -self.slantTolerance.Metres))
            if (self.parametersPanel.cmbConstructionType.currentIndex() == 0):
                endPoint = offsetCurf1[0]
                offsetCurf1.append(endPoint)
            resultPoint3dArrayList.append(offsetCurf1)
#             foreach (Entity offsetCurf1 in arc.GetOffsetCurves(-self.slantTolerance.Metres))
#             {
#                 AcadHelper.smethod_19(transaction, blockTableRecord, offsetCurf1, constructionLayer, 2);
#             }
#         }
        if (self.parametersPanel.chbInsertSymbol.isChecked()):
            length = self.groundDistance.Metres / 5
            rectangle = QgsRectangle(point3d1.get_X() - length / 2, point3d1.get_Y() - length / 2, point3d1.get_X() + length / 2, point3d1.get_Y() + length / 2,)
            point1 = MathHelper.distanceBearingPoint(point3d1, Unit.ConvertDegToRad(315), length / 2)#Point3D(point3d1.get_X() - length / 2, point3d1.get_Y() + length / 2)
            point2 = MathHelper.distanceBearingPoint(point3d1, Unit.ConvertDegToRad(225), length / 2)#Point3D(point3d1.get_X() - length / 2, point3d1.get_Y() - length / 2)
            point3 = MathHelper.distanceBearingPoint(point3d1, Unit.ConvertDegToRad(135), length / 2)#Point3D(point3d1.get_X() + length / 2, point3d1.get_Y() - length / 2)
            point4 = MathHelper.distanceBearingPoint(point3d1, Unit.ConvertDegToRad(45), length / 2)#Point3D(point3d1.get_X() + length / 2, point3d1.get_Y() + length / 2)
            resultPoint3dArrayList.append([point1, point2, point3, point4, point1])
#             Symbol symbol = new Symbol(SymbolType.Dme);
#             AcadHelper.smethod_57(transaction, blockTableRecord, symbol.BlockName, symbol.BlockFileName, point3d1, new Scale3d(1), 0, constructionLayer, None);
#         }

        for point3dArray in resultPoint3dArrayList:
            if (self.parametersPanel.cmbConstructionType.currentIndex() != 0):
                bulge = MathHelper.smethod_60(point3dArray[0], point3dArray[int(len(point3dArray)/2)], point3dArray[len(point3dArray)-1])
                AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, point3dArray, False, {"Bulge":bulge})
        if self.parametersPanel.cmbConstructionType.currentIndex() == 0:
            for area in circleAreaList:
                AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, area)
            if self.parametersPanel.chbInsertSymbol.isChecked():
                AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, [point1, point2, point3, point4, point1])

        
        if (self.parametersPanel.chbWriteText.isChecked()):
            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, captionCircleLine, False, {"Caption":"3DME"} )
        
        palSetting = QgsPalLayerSettings()
        palSetting.readFromLayer(constructionLayer)
        palSetting.enabled = True
        palSetting.fieldName = "Caption"
        palSetting.isExpression = True
        palSetting.placement = QgsPalLayerSettings.Line
        palSetting.placementFlags = QgsPalLayerSettings.AboveLine
        palSetting.setDataDefinedProperty(QgsPalLayerSettings.Size, True, True, '12', "")
        palSetting.writeToLayer(constructionLayer)
        
        QgisHelper.appendToCanvas(define._canvas, [constructionLayer], self.surfaceType, True)
        QgisHelper.zoomToLayers([constructionLayer])
        self.resultLayerList = [constructionLayer]