コード例 #1
0
        private void DrawCurveGraph(double a_x, double a_y)
        {
            // 遍历线,求距离
            table = new DataTable();
            //showTable.Columns.Clear();
            list.Clear();
            chart1.Series["管线"].Points.Clear();

            table.Columns.Add("编号", typeof(string));
            table.Columns.Add("管线类型", typeof(string));
            table.Columns.Add("管线编码", typeof(string));
            table.Columns.Add("管径_毫米", typeof(string));
            table.Columns.Add("材质", typeof(string));
            table.Columns.Add("管线埋深", typeof(string));

            object[,] sortIndex = new object[listPoint.Count, 2];
            for (int i = 0; i < listPoint.Count; i++)
            {
                GSOPoint3d geoPoint = (GSOPoint3d)listPoint[i];
                GSOFeature feature  = listFeat[i] as GSOFeature;
                //坐标投影
                int id = GeoScene.Data.GSOProjectManager.AddProject("+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=555484.8092 +y_0=-4114948.631 +ellps=krass +units=m +no_defs");

                GeoScene.Data.GSOPoint2d a_Point = GeoScene.Data.GSOProjectManager.Forward(new GSOPoint2d(a_x, a_y), id);//user画的线的起始点

                GeoScene.Data.GSOPoint2d pt2d   = new GeoScene.Data.GSOPoint2d(geoPoint.X, geoPoint.Y);
                GeoScene.Data.GSOPoint2d result = GeoScene.Data.GSOProjectManager.Forward(pt2d, id);
                B_x = result.X;
                B_y = result.Y;

                double x   = System.Math.Abs(B_x - a_Point.X);
                double y   = System.Math.Abs(B_y - a_Point.Y);
                double Dis = Math.Round(Math.Sqrt(x * x + y * y), 2);
                list.Add(geoPoint.Z);
                sortIndex[i, 0] = Dis;
                sortIndex[i, 1] = i;

                chart1.Series["管线"].Points.AddXY(Dis, geoPoint.Z);//绑定数据

                string pipeType = "";
                if (feature.GetFieldAsInt32("管线编码") >= 6000 && feature.GetFieldAsInt32("管线编码") <= 6203)  // 6100是热力管线的编码
                {
                    pipeType = "热力管线";
                }
                else if (feature.GetFieldAsInt32("管线编码") >= 4000 && feature.GetFieldAsInt32("管线编码") <= 4306)//排水
                {
                    pipeType = "排水管线";
                }
                else if (feature.GetFieldAsInt32("管线编码") >= 3000 && feature.GetFieldAsInt32("管线编码") <= 3513)  // 3000是给力管线的编码
                {
                    pipeType = "给水管线";
                }
                else if (feature.GetFieldAsInt32("管线编码") >= 1000 && feature.GetFieldAsInt32("管线编码") <= 1808)  // 电力管线的编码
                {
                    pipeType = "电力管线";
                }
                else if (feature.GetFieldAsInt32("管线编码") >= 2000 && feature.GetFieldAsInt32("管线编码") <= 2300)  // 通信管线的编码
                {
                    pipeType = "通信管线";
                }
                else if (feature.GetFieldAsInt32("管线编码") >= 5000 && feature.GetFieldAsInt32("管线编码") <= 5200)  // 通信管线的编码
                {
                    pipeType = "燃气管线";
                }
                string number = Convert.ToString(i + 1);

                string material = feature.GetFieldAsString("材质");
                string diameter = feature.GetFieldAsString("管径_毫米");
                table.Rows.Add(new object[] { number, pipeType, feature.Name.ToString(), diameter, material, Convert.ToDecimal(list[i].ToString()).ToString("f2") });//list[i].ToString().Substring(0,list[i].ToString().IndexOf('.')+3) }

                //chart1.Series["管线"].Points[i].Label = number;//管线的标签
                chart1.Series["管线"].Points[i].LegendText = number;
                if (feature.Geometry.Style.GetType() == typeof(GSOPipeLineStyle3D))
                {
                    GSOPipeLineStyle3D style = (GSOPipeLineStyle3D)feature.Geometry.Style;
                    chart1.Series["管线"].Points[i].MarkerBorderColor = style.LineColor;     //点的填充色
                }
                else
                {
                    chart1.Series["管线"].Points[i].MarkerBorderColor = Color.Black;
                }

                chart1.Series["管线"].Points[i].MarkerBorderWidth = 3;                                                                                                                                //边框的宽度
                chart1.Series["管线"].Points[i].MarkerColor       = Color.Transparent;
                chart1.Series["管线"].Points[i].MarkerSize        = Convert.ToInt32(Math.Floor((feature.GetFieldAsDouble("管径_毫米") / 0.35 + chart1.Series["管线"].Points[i].MarkerBorderWidth) / 25.0)); //点的大小
            }

            string htmlCode = "<html><head><style>#hor-minimalist-b " +
                              "{-moz-background-clip:border;" +
                              "-moz-background-inline-policy:continuous;" +
                              "-moz-background-origin:padding;" +
                              "background:#FFFFFF none repeat scroll 0 0;" +
                              "border-collapse:collapse;" +
                              "font-family:'Lucida Sans Unicode','Lucida Grande',Sans-Serif;" +
                              " font-size:12px;" +
                              " margin:10px;" +
                              " text-align:left;" +
                              " width:80%;" +
                              " }" +
                              " #hor-minimalist-b th {" +
                              " border-bottom:2px solid #6678B1;" +
                              " color:#003399;" +
                              " font-size:12px;" +
                              "font-weight:normal;" +
                              "  padding:10px 8px;" +
                              " }" +
                              "  #hor-minimalist-b td {" +
                              " border-bottom:1px solid #CCCCCC;" +
                              " font-size:12px;" +
                              " color:#666699;" +
                              "padding:6px 8px;}" +
                              "#hor-minimalist-b tbody tr:hover td {" +
                              "color:#000099;}" +
                              "</style></head>" +
                              "<body style='border:none;' ><table align='center' summary='Employee Pay Sheet' id='hor-minimalist-b'><thead><tr><th scope='col'>管线类型</th><th scope='col'>管线编码</th><th scope='col'>管径_毫米</th>" +
                              "<th scope='col'>材质</th><th scope='col'>管线埋深</th></tr></thead>" +
                              "<tbody><tr><td>" +
                              "</td><td>" +
                              "</td><td>" +
                              "</td><td>" +
                              "</td><td>" +
                              "</td></tr></tbody></table></body><ml>";

            webBrowser1.DocumentText = htmlCode;
        }
コード例 #2
0
        private void btnCreateModel_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtModelLayer.Text))
                {
                    MessageBox.Show("管线模型文件路径无效!", "提示");
                    return;
                }
                if (File.Exists(txtModelLayer.Text))
                {
                    MessageBox.Show("管线模型文件已存在!", "提示");
                    return;
                }

                GSOLayer ShpSourceLayer = ctl.Globe.Layers[cmbLayer.SelectedIndex];

                GSOLayer pipeModelLayer = ctl.Globe.Layers.Add(txtModelLayer.Text);

                string   pipeRectFile = Path.GetDirectoryName(txtModelLayer.Text) + "\\" + Path.GetFileNameWithoutExtension(txtModelLayer.Text) + "_Rect" + Path.GetExtension(txtModelLayer.Text);
                GSOLayer layer_Rect   = ctl.Globe.Layers.Add(pipeRectFile);
                lgdFilePath = txtModelLayer.Text;

                if (pipeModelLayer != null)
                {
                    GSOFeatures features = ShpSourceLayer.GetAllFeatures();
                    string      message  = "";
                    for (int j = 0; j < features.Length; j++)
                    {
                        GSOFeature f = features[j];

                        GSOFeature newFeature = new GSOFeature();

                        GSOPipeLineStyle3D style = new GSOPipeLineStyle3D();
                        style.LineColor = Color.FromArgb(Convert.ToByte(numericUpDownLineOpaque.Value), btnPipelineColor.BackColor);

                        double       radius        = 0;
                        GSOFieldDefn diameterfield = (GSOFieldDefn)f.GetFieldDefn(cmbRadius.SelectedItem.ToString());
                        if (diameterfield.Type == EnumFieldType.Text)
                        {
                            radius = Convert.ToDouble(f.GetFieldAsString(cmbRadius.SelectedItem.ToString())) / 2000;
                        }
                        else
                        {
                            radius = f.GetFieldAsDouble(cmbRadius.SelectedItem.ToString()) / 2000;  // 探测数据的单位一般是毫米,需换算为米; 管径一般是 直径, 这个需要半径, 所有除以2000
                        }

                        string eventid    = f.GetFieldAsString(cmbID.SelectedItem.ToString());
                        int    num_width  = f.GetFieldAsInt32(cmbWidthNum.SelectedItem.ToString());
                        int    num_height = f.GetFieldAsInt32(cmbHeightNum.SelectedItem.ToString());
                        double interval   = radius * 2;                    //  f.GetFieldAsDouble(cmbInterval.SelectedItem.ToString());
                        double rectWidth  = radius * 2 * num_width + 0.08; // 两端空出0.04
                        double rectHeight = radius * 2 * num_height + 0.08;
                        if (radius == 0)
                        {
                            message += "ID为" + f.ID + "的管线的半径为0  \n  ";
                            continue;
                        }

                        style.Radius           = radius;
                        style.Slice            = int.Parse(txtSlice.Text);
                        style.CornerSliceAngle = Convert.ToDouble(textBoxCornerSliceAngle.Text);

                        f.Geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround;

                        GSOGeoPolyline3D line = f.Geometry as GSOGeoPolyline3D;
                        if (line == null)
                        {
                            message += "ID为" + f.ID + "的管线不是线对象  \n  ";
                            continue;
                        }

                        double deep1 = f.GetFieldAsDouble(cmbFrom.SelectedItem.ToString());
                        double deep2 = f.GetFieldAsDouble(cmbTo.SelectedItem.ToString());

                        if (chkDeep.Checked)
                        {
                            deep1 = 0 - deep1;
                            deep2 = 0 - deep2;
                        }

                        if (cmbReference.SelectedIndex == 0)  //管底
                        {
                            deep1 = deep1 + radius * 2;
                            deep2 = deep2 + radius * 2;
                        }
                        else if (cmbReference.SelectedIndex == 1)  //管顶
                        {
                            deep1 = deep1 - radius * 2;
                            deep2 = deep2 - radius * 2;
                        }
                        for (int n = 0; n < line[0].Count; n++)
                        {
                            GSOPoint3d pt3d       = line[0][n];
                            int        pointcount = line[0].Count;
                            double     radio      = Math.Sqrt(Math.Pow(pt3d.Y - line[0][0].Y, 2) + Math.Pow(pt3d.X - line[0][0].X, 2)) / Math.Sqrt(Math.Pow(line[0][pointcount - 1].Y - line[0][0].Y, 2) + Math.Pow(line[0][pointcount - 1].X - line[0][0].X, 2));
                            pt3d.Z = deep1 + (deep2 - deep1) * radio;

                            if (double.IsInfinity(pt3d.Z))
                            {
                                pt3d.Z = deep2;
                            }
                            line[0][n] = pt3d;
                        }
                        if (num_height == 0 || num_width == 0)  // 直埋
                        {
                            newFeature.Geometry       = line;
                            newFeature.Geometry.Style = style;
                            newFeature.Name           = eventid;
                            pipeModelLayer.AddFeature(newFeature);
                        }
                        else
                        {
                            GSOFeature rectfeat = CreatePipeRect(f, line, rectWidth, rectHeight);
                            if (rectfeat != null)
                            {
                                layer_Rect.AddFeature(rectfeat);
                            }
                            one2Multi(line, num_width, num_height, interval, style, pipeModelLayer, eventid);
                        }
                    }
                    ctl.Refresh();

                    pipeModelLayer.Save();
                    layer_Rect.Save();
                    string strMessage = "shp文件中共" + features.Length + "个对象,实际生成" + (pipeModelLayer.GetAllFeatures().Length + layer_Rect.GetAllFeatures().Length) + "个对象!\n";
                    MessageBox.Show(strMessage + message, "提示");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                Log.PublishTxt(ex);
                MessageBox.Show(ex.Message);
            }
        }
コード例 #3
0
ファイル: MainFrm.cs プロジェクト: StarU/qkKL6Dgf12
        //阀门分析
        private bool NetworkCloseValvesAnalysis(GSOFeature lineFeature, GSOPoint3d pntBreak, GSOLayer lineLayer)
        {
            if (lineLayer == null || lineFeature == null || lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D)
            {
                return false;
            }
            GSODataset curCAYDataset = lineLayer.Dataset;

            if (curCAYDataset == null || curCAYDataset.DataSource == null)
            {
                return false;
            }
            string srName = curCAYDataset.Name;
            GSONetworkDataset curCAYNDataset = curCAYDataset.DataSource.GetDatasetByName(srName + "Network") as GSONetworkDataset;

            if (curCAYNDataset == null)
            {
                MessageBox.Show("该图层没有创建网络拓扑,请先创建网络拓扑信息再进行分析!", "提示");
                return false;
            }
            ClearCloseValvesAnalysisMenuItem_Click(null, null);

            int[] arryResNodeID;
            int[] arryResValveID;
            curCAYNDataset.CloseValveAnalysis(lineFeature.ID, out arryResNodeID, out arryResValveID, false, true);
            if (arryResValveID != null)
            {
                if (lineFeature.GetFieldAsInt32("管线编码") >= 6000 && lineFeature.GetFieldAsInt32("管线编码") <= 6203)  // 6100是热力管线的编码
                {
                    GSOLayer ValveLayer = globeControl1.Globe.Layers.GetLayerByCaption("热力阀门");
                    if (ValveLayer != null)
                    {
                        m_CloseValvesAnalyResFeatures = ValveLayer.GetFeaturesByIDs(arryResValveID);
                    }
                }
                else if (lineFeature.GetFieldAsInt32("管线编码") >= 5000 && lineFeature.GetFieldAsInt32("管线编码") <= 5200)  // 5000是燃气管线的编码
                {
                    GSOLayer ValveLayer = globeControl1.Globe.Layers.GetLayerByCaption("燃气阀门");
                    if (ValveLayer != null)
                    {
                        m_CloseValvesAnalyResFeatures = ValveLayer.GetFeaturesByIDs(arryResValveID);
                    }
                }
                else if (lineFeature.GetFieldAsInt32("管线编码") >= 3000 && lineFeature.GetFieldAsInt32("管线编码") <= 3513)  // 3000是给水管线的编码
                {
                    GSOLayer ValveLayer = globeControl1.Globe.Layers.GetLayerByCaption("给水阀门");
                    if (ValveLayer != null)
                    {
                        m_CloseValvesAnalyResFeatures = ValveLayer.GetFeaturesByIDs(arryResValveID);
                    }
                }
            }
            if (m_CloseValvesAnalyResFeatures == null ||
                m_CloseValvesAnalyResFeatures.Length < 1)
            {
                MessageBox.Show("没有找到要关闭的阀门!");
            }
            else
            {
                int nCount = m_CloseValvesAnalyResFeatures.Length;
                if (nCount > 0)
                {
                    FrmShowValvesNeedClose frm = FrmShowValvesNeedClose.getForm(globeControl1, m_CloseValvesAnalyResFeatures, m_CloseValvesList);
                    frm.setLstValvesName();
                    if (!frm.Visible)
                    {
                        frm.Show(this);
                    }
                }
            }
            return true;
        }