예제 #1
0
        /// <summary>
        /// 删除字段
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            if (null == this.dataGridView1.SelectedCells ||
                1 > this.dataGridView1.SelectedCells.Count)
            {
                MessageBox.Show("请选择要删除的列。");
                return;
            }
            //新建选择列列表
            List <DataGridViewColumn> colsToDel = new List <DataGridViewColumn>();

            for (int i = 0; i < this.dataGridView1.SelectedCells.Count; i++)
            {
                //获取到datagridView中选中的列信息
                var column = this.dataGridView1.Columns[this.dataGridView1.SelectedCells[i].ColumnIndex];
                if (!colsToDel.Contains(column))
                {
                    //添加列信息
                    colsToDel.Add(column);
                }
            }
            //提示是否删除
            if (MessageBox.Show(string.Format("是否删除{0}字段?\n此操作不可撤销。", string.Join(",", colsToDel.AsEnumerable().Select(c => c.Name))),
                                "消息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                //获得所有要素
                GSOFeatures features = _layer.GetAllFeatures();
                //遍历选中列的列表
                foreach (var item in colsToDel)
                {
                    //遍历所有要素
                    for (int i = 0; i < features.Length; i++)
                    {
                        GSOFeature feature = features[i];
                        //获取选中列在要素属性表中的索引
                        int index = feature.GetFieldIndex(item.Name);
                        //删除该字段
                        feature.DeleteField(index);
                    }
                    //同时删除控件中的列
                    this.dataGridView1.Columns.Remove(item);
                }
                //保存图层
                _layer.Save();
            }
        }
 private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     dataGridView1.EndEdit();
     if (geoLayer != null)
     {
         geoLayer.Save();
     }
 }
예제 #3
0
 //保存
 private void buttonOk_Click(object sender, EventArgs e)
 {
     if (updateFeatures())
     {
         if (MessageBox.Show("确定要保存吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             if (layer != null)
             {
                 layer.Save();
                 this.Close();
             }
             globeControl1.Globe.Refresh();
         }
     }
 }
        private void btn_OK_Click(object sender, EventArgs e)
        {
            bool notFit = false;

            if (this.textBox_BeginX.Text.Trim().Equals(string.Empty) ||
                this.textBox_BeginY.Text.Trim().Equals(string.Empty))
            {
                errorProvider1.SetError(groupBoxBengin, "请获取起点坐标。");
                notFit = true;
            }
            if (this.textBox_EndX.Text.Trim().Equals(string.Empty) ||
                this.textBox_EndY.Text.Trim().Equals(string.Empty))
            {
                errorProvider1.SetError(groupBoxEnd, "请获取目标点坐标。");
                notFit = false;
            }
            if (notFit)
            {
                return;
            }

            //计算X轴位移坐标
            double daltX = double.Parse(this.textBox_EndX.Text.Trim()) - double.Parse(this.textBox_BeginX.Text.Trim());
            //计算Y轴位移坐标
            double daltY = double.Parse(this.textBox_EndY.Text.Trim()) - double.Parse(this.textBox_BeginY.Text.Trim());

            //获取所有的要素
            GSOFeatures features = _layer.GetAllFeatures();

            for (int i = 0; i < features.Length; i++)
            {
                GSOFeature feature = features[i];
                //遍历要素,将Geometry平移(daltX, daltY)坐标
                if (feature.Geometry != null)
                {
                    feature.Geometry.MoveXY(daltX, daltY);
                }
            }
            _layer.Save();
            _glbControl.Refresh();
        }
예제 #5
0
        //导出
        private void button2_Click(object sender, EventArgs e)
        {
            button4_Click(null, null);
            GSOFeatures feats = getFeatures();

            if (feats == null || feats.Length == 0)
            {
                MessageBox.Show("没有符合条件的对象!");
                return;
            }
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter = "(*.lgd)|*.lgd||";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                GSOLayer layer = globeControl1.Globe.Layers.Add(dlg.FileName);
                layer.AddFeatures(feats);
                layer.Visible = false;
                layer.Save();
            }
        }
예제 #6
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (listBoxLayerNames.SelectedItems.Count <= 0)
            {
                MessageBox.Show("请选中要修改图层的名称!", "提示");
                return;
            }
            string modelPath = textBoxModelPath.Text.Trim();

            if (modelPath == "")
            {
                MessageBox.Show("请选择一个模型!", "提示");
                return;
            }
            for (int i = 0; i < listBoxLayerNames.SelectedItems.Count; i++)
            {
                string   layerName = listBoxLayerNames.SelectedItems[i].ToString().Trim();
                GSOLayer layer     = globeControl1.Globe.Layers.GetLayerByCaption(layerName);
                if (layer != null && layer is GSOFeatureLayer)
                {
                    for (int j = 0; j < layer.GetAllFeatures().Length; j++)
                    {
                        GSOFeature feature = layer.GetAt(j);
                        if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoModel)
                        {
                            GSOGeoModel model    = feature.Geometry as GSOGeoModel;
                            GSOGeoModel modelnew = new GSOGeoModel();
                            modelnew.FilePath = modelPath;
                            modelnew.Position = model.Position;

                            feature.Geometry = modelnew;
                        }
                    }
                    layer.Save();
                }
            }
            globeControl1.Globe.Refresh();
            MessageBox.Show("修改成功!", "提示");
            this.Close();
        }
예제 #7
0
 /// <summary>
 /// 文字图层
 /// </summary>
 /// <param name="text">显示的文字</param>
 private void TextTitle(string text)
 {
     if (layerScreenText != null)
     {
         //清除其中所有要素
         layerScreenText.RemoveAllFeature();
         GSOGeoScreenText overlayTextTitle = new GSOGeoScreenText(); //创建屏幕文字
         GSOTextStyle     textStyle        = new GSOTextStyle();     //设置属性
         textStyle.ForeColor        = Color.White;
         textStyle.FontSize         = 36;
         overlayTextTitle.TextStyle = textStyle;
         overlayTextTitle.Align     = EnumAlign.TopLeft;        //设置文字对齐方式
         overlayTextTitle.PosAlign  = EnumAlign.BottomRight;    //设置文字位置
         overlayTextTitle.Name      = "ScreenTextTitle";
         overlayTextTitle.SetOffset(180, 60);                   //设置文字偏移量
         overlayTextTitle.Text = text;                          //设置文字
         GSOFeature feature_ScreenTextTitle = new GSOFeature(); //创建要素
         feature_ScreenTextTitle.Geometry = overlayTextTitle;   //赋予要素
         layerScreenText.AddFeature(feature_ScreenTextTitle);
         layerScreenText.Save();
     }
 }
예제 #8
0
        /// <summary>
        /// 向图层数据中添加要素Feature
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_EditFeature_Click(object sender, EventArgs e)
        {
            //新建要素
            GSOGeoPolygon3D polygon = new GSOGeoPolygon3D();
            GSOPoint3ds     points  = new GSOPoint3ds();

            points.Add(new GSOPoint3d(120, 30, 0));
            points.Add(new GSOPoint3d(120.004, 30, 0));
            points.Add(new GSOPoint3d(120.002, 30.001, 0));
            polygon.AddPart(points);

            GSOFeature feature = new GSOFeature();

            feature.Geometry = polygon;

            _featureLayer.AddFeature(feature);

            _glbControl.Globe.MemoryLayer.AddFeature(feature);
            _glbControl.Globe.FlyToFeature(feature);

            _featureLayer.Save();
        }
예제 #9
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            string fieldName = textBoxFieldName.Text.Trim();

            if (fieldName.Equals(string.Empty))
            {
                MessageBox.Show("字段名不能为空!", "提示");
                return;
            }
            int firstChar = 0;

            if (int.TryParse(fieldName.Substring(0, 1), out firstChar))
            {
                MessageBox.Show("字段名不能以数字开头!", "提示");
                return;
            }
            if (fieldName.Length > 10)
            {
                MessageBox.Show("字段名长度不能大于10!", "提示");
                return;
            }

            EnumFieldType fieldType  = EnumFieldType.None;
            int           fieldWidth = 0;
            string        type       = comboBoxFieldType.Text.Trim();

            if (string.IsNullOrEmpty(type))
            {
                MessageBox.Show("字段类型不能为空!", "提示");
                return;
            }
            else
            {
                switch (type)
                {
                case "Date":
                    fieldType  = EnumFieldType.Date;
                    fieldWidth = 10;
                    break;

                case "Double":
                    fieldType  = EnumFieldType.Double;
                    fieldWidth = 8;
                    break;

                case "INT32":
                    fieldType  = EnumFieldType.INT32;
                    fieldWidth = 4;
                    break;

                case "Text":
                    fieldType  = EnumFieldType.Text;
                    fieldWidth = 8000;
                    break;

                default:
                    MessageBox.Show("字段类型不匹配!", "提示");
                    return;
                }
            }

            if (layer != null)
            {
                GSOFieldDefn fieldDef = new GSOFieldDefn()
                {
                    //设置字段名称
                    Name = fieldName,
                    //设置字段类型
                    Type = fieldType,
                    //设置字段长度
                    Width = fieldWidth
                };

                var features = layer.GetAllFeatures();
                //遍历图层将字段信息添加到每个feature中
                for (int i = 0; i < features.Length; i++)
                {
                    var feature = features[i];
                    feature.AddField(fieldDef);
                }

                //保存图层
                layer.Save();

                //将新建列添加到数据表中
                dataGridView1.Columns.Add(fieldName, fieldName);
            }
            this.Close();
        }
        private void btnCreateModel_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtModelLayer.Text))
                {
                    MessageBox.Show("kml文件路径无效!", "提示");
                    return;
                }
                if (File.Exists(txtModelLayer.Text))
                {
                    MessageBox.Show("kml文件已存在!", "提示");
                    return;
                }

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

                GSOLayer layer = ctl.Globe.Layers.Add(txtModelLayer.Text);
                lgdFilePath = txtModelLayer.Text;
                if (layer != null)
                {
                    GSOFeatures features = sourceLayer.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 field  = (GSOFieldDefn)(f.GetFieldDefn(cmbRadius.SelectedItem.ToString()));
                        if (field.Type == EnumFieldType.Text)
                        {
                            string temp   = f.GetFieldAsString(cmbRadius.SelectedItem.ToString());
                            double outNum = 0;
                            bool   num    = double.TryParse(temp, out outNum);
                            if (num)
                            {
                                radius = outNum / 2000;
                            }
                        }
                        else if (field.Type == EnumFieldType.Double)
                        {
                            radius = f.GetFieldAsDouble(cmbRadius.SelectedItem.ToString()) / 2000;  // 探测数据的单位一般是毫米,需换算为米; 管径一般是 直径, 这个需要半径, 所有除以2000
                        }
                        string eventid = f.GetFieldAsString(cmbID.SelectedItem.ToString());

                        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;
                            line[0][n] = pt3d;
                        }

                        newFeature.Geometry       = line; // f.Geometry;
                        newFeature.Geometry.Style = style;
                        newFeature.Name           = eventid;
                        layer.AddFeature(newFeature);
                    }
                    ctl.Refresh();
                    layer.Save();
                    ctl.Globe.Layers.Remove(layer);
                    string strMessage = "shp文件中共" + features.Length + "个对象,实际生成" + layer.GetAllFeatures().Length + "个对象!\n";
                    MessageBox.Show(strMessage + message, "提示");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                Log.PublishTxt(ex);
                MessageBox.Show(ex.Message);
            }
        }
예제 #11
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);
            }
        }
예제 #12
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 sourceLayer = ctl.Globe.Layers[cmbLayer.SelectedIndex];

                GSOLayer layer = ctl.Globe.Layers.Add(txtModelLayer.Text);
                lgdFilePath = txtModelLayer.Text;
                if (layer != null)
                {
                    GSOFeatures features = sourceLayer.GetAllFeatures();

                    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  = f.GetFieldAsDouble(cmbRadius.SelectedIndex) / 1000; // 单位
                        string eventid = f.GetFieldAsString(cmbID.SelectedItem.ToString());

                        style.Radius           = radius;
                        style.CornerSliceAngle = Convert.ToDouble(textBoxCornerSliceAngle.Text);


                        f.Geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround;

                        GSOGeoPolyline3D line = f.Geometry as GSOGeoPolyline3D;
                        if (line == null)
                        {
                            return;
                        }



                        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;
                            deep2 = deep2 + radius;
                        }
                        else if (cmbReference.SelectedIndex == 1)  //管顶
                        {
                            deep1 = deep1 - radius;
                            deep2 = deep2 - radius;
                        }
                        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;
                            line[0][n] = pt3d;
                        }

                        newFeature.Geometry       = line; // f.Geometry;
                        newFeature.Geometry.Style = style;
                        newFeature.Name           = eventid;
                        //newFeature.CustomID = f.ID;
                        layer.AddFeature(newFeature);
                    }
                }
                ctl.Refresh();

                layer.Save();

                ctl.Globe.Layers.Remove(layer);
                this.Close();
            }
            catch (Exception ex)
            {
                Log.PublishTxt(ex);
                MessageBox.Show(ex.Message);
            }
        }
예제 #13
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 sourceLayer = ctl.Globe.Layers[cmbLayer.SelectedIndex];

                GSOLayer layer = ctl.Globe.Layers.Add(txtModelLayer.Text);
                lgdFilePath = txtModelLayer.Text;
                if (layer != null)
                {
                    GSOFeatures features = sourceLayer.GetAllFeatures();

                    for (int j = 0; j < features.Length; j++)
                    {
                        GSOFeature f          = features[j];
                        GSOFeature newFeature = new GSOFeature();

                        string text = "";
                        if (combLabel.SelectedItem != null)
                        {
                            text = f.GetFieldAsString(combLabel.SelectedItem.ToString());
                        }
                        if (listFields.CheckedItems.Count > 0)
                        {
                            newFeature.Description = GetBubbleInfo(f, numWidth.Value.ToString(), numHeight.Value.ToString());
                        }

                        if (f.Geometry is GSOGeoPoint3D)
                        {
                            GSOGeoMarker marker = new GSOGeoMarker();
                            marker.Position = f.Geometry.GeoCenterPoint;
                            marker.Text     = text;
                            GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                            style.IconPath      = Application.StartupPath + "\\Resource\\ddd.png";
                            marker.Style        = style;
                            newFeature.Geometry = marker;
                        }
                        else if (f.Geometry.Type == EnumGeometryType.GeoPolyline3D)
                        {
                            GSOGeoPolyline3D line  = (GSOGeoPolyline3D)f.Geometry.Clone();
                            GSOLabel         label = new GSOLabel();
                            label.Text = text;
                            GSOLabelStyle style = new GSOLabelStyle();
                            style.HasTracktionLine   = false;
                            style.OutlineColor       = Color.Transparent;
                            style.MaxVisibleDistance = 100000;
                            label.Style         = style;
                            line.Label          = label;
                            newFeature.Geometry = line;
                        }
                        else if (f.Geometry.Type == EnumGeometryType.GeoPolygon3D)
                        {
                            GSOGeoPolygon3D polygon = (GSOGeoPolygon3D)f.Geometry.Clone();
                            GSOLabel        label   = new GSOLabel();
                            label.Text = text;
                            GSOLabelStyle style = new GSOLabelStyle();
                            style.HasTracktionLine   = false;
                            style.OutlineColor       = Color.Transparent;
                            style.MaxVisibleDistance = 100000;
                            label.Style         = style;
                            polygon.Label       = label;
                            newFeature.Geometry = polygon;
                        }
                        newFeature.Name = text;
                        layer.AddFeature(newFeature);
                    }
                }
                ctl.Refresh();
                layer.Save();

                //ctl.Globe.Layers.Remove(layer);

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        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 sourceLayer = ctl.Globe.Layers[cmbLayer.SelectedIndex];

                GSOLayer layer = ctl.Globe.Layers.Add(txtModelLayer.Text);
                lgdFilePath = txtModelLayer.Text;
                if (layer != null)
                {
                    GSOFeatures features = sourceLayer.GetAllFeatures();
                    string      message  = "";
                    for (int j = 0; j < features.Length; j++)
                    {
                        GSOFeature f = features[j];

                        GSOFeature newFeature = new GSOFeature();

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

                        double       width = 0;
                        GSOFieldDefn field = (GSOFieldDefn)(f.GetFieldDefn(cmbWidth.SelectedItem.ToString()));
                        if (field.Type == EnumFieldType.Text)
                        {
                            string temp   = f.GetFieldAsString(cmbWidth.SelectedItem.ToString());
                            double outNum = 0;
                            bool   num    = double.TryParse(temp, out outNum);
                            if (num)
                            {
                                width = outNum;
                            }
                        }
                        else if (field.Type == EnumFieldType.Double)
                        {
                            width = f.GetFieldAsDouble(cmbWidth.SelectedItem.ToString());
                        }


                        double height = 0;
                        field = (GSOFieldDefn)(f.GetFieldDefn(cmbHeight.SelectedItem.ToString()));
                        if (field.Type == EnumFieldType.Text)
                        {
                            string temp   = f.GetFieldAsString(cmbHeight.SelectedItem.ToString());
                            double outNum = 0;
                            bool   num    = double.TryParse(temp, out outNum);
                            if (num)
                            {
                                height = outNum;
                            }
                        }
                        else if (field.Type == EnumFieldType.Double)
                        {
                            height = f.GetFieldAsDouble(cmbHeight.SelectedItem.ToString());
                        }

                        string eventid = f.GetFieldAsString(cmbID.SelectedItem.ToString());

                        if (width == 0 || height == 0)
                        {
                            message += "ID为" + f.ID + "的对象的沟宽或者沟高字段的值为0 \n";
                            continue;
                        }
                        GSOPoint3ds sectionpts = new GSOPoint3ds();
                        sectionpts.Add(new GSOPoint3d(width / -2, height / 2, 0));
                        sectionpts.Add(new GSOPoint3d(width / -2, height / -2, 0));
                        sectionpts.Add(new GSOPoint3d(width / 2, height / -2, 0));
                        sectionpts.Add(new GSOPoint3d(width / 2, height / 2, 0));

                        style.SetSectionPoints(sectionpts);
                        style.IsClosed = false;
                        style.SetAnchorByAlign(EnumAlign.BottomCenter);

                        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;
                        }

                        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;
                            line[0][n] = pt3d;
                        }

                        newFeature.Geometry       = line; // f.Geometry;
                        newFeature.Geometry.Style = style;
                        newFeature.Name           = eventid;
                        layer.AddFeature(newFeature);
                    }
                    ctl.Refresh();
                    layer.Save();
                    ctl.Globe.Layers.Remove(layer);
                    string strMessage = "shp文件中共" + features.Length + "个对象,实际生成" + layer.GetAllFeatures().Length + "个对象!\n";
                    MessageBox.Show(strMessage + message, "提示");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                Log.PublishTxt(ex);
                MessageBox.Show(ex.Message);
            }
        }