/// <summary>
        /// 获取图层中的所有feature对象,包括featureFolder下面的feature对象
        /// </summary>
        /// <param name="layer"></param>
        /// <returns></returns>
        public static GSOFeatures getRealFeaturesByLayer(GSOLayer layer)
        {
            GSOFeatures realFeatures = new GSOFeatures();

            if (layer != null)
            {
                for (int i = 0; i < layer.GetAllFeatures().Length; i++)
                {
                    GSOFeature feature = layer.GetAt(i);
                    if (feature != null)
                    {
                        if (feature.Type == EnumFeatureType.FeatureFolder)
                        {
                            GSOFeatureFolder featureFolder = feature as GSOFeatureFolder;
                            getRealFeatureByFeatures(featureFolder.Features, ref realFeatures);
                        }
                        else
                        {
                            realFeatures.Add(feature);
                        }
                    }
                }
            }
            return(realFeatures);
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            islabel     = !islabel;
            label3.Text = string.Format("标注:{0}", islabel ? "开" : "关");
            GSOLayer layer = globeControl1.Globe.MemoryLayer;

            for (int i = 0; i < layer.GetAllFeatures().Length; i++)
            {
                GSOFeature feature = layer.GetAt(i);
                GSOLabel   label   = new GSOLabel();
                label.Text         = feature.Name; //设置显示的文本信息
                label.Style        = new GSOLabelStyle();
                label.Style.Opaque = 0.8;          //设置标注的透明度,取值区间是0-1

                //设置引线的类型,可以是实线、虚线等。
                label.Style.TracktionLineType = EnumTracktionLineType.Dot;

                //设置字体大小
                label.Style.TextStyle.FontHeight = 20;

                //设置字体类型
                label.Style.TextStyle.FontName = "黑体";

                //设置标注的位置,默认标注在要素的正上方,下面80,60的单位是像素
                //label.Style.TractionLineEndPos = new GSOPoint2d(80, 60);
                label.Style.TractionLineEndPos = new GSOPoint2d(0, 60);

                //设置是否为斜体
                label.Style.TextStyle.Italic = true;

                //设置标注的边框颜色
                label.Style.OutlineColor = Color.Red;

                //设置标注的边框粗细
                label.Style.OutlineWidth = 1;

                //设置标注的引线粗细
                label.Style.TracktionLineWidth = 1;

                //设置标注矩形区的颜色渐变
                label.Style.BackBeginColor = Color.Orange;
                label.Style.BackEndColor   = Color.PaleGreen;

                //label.BKImage = @"D:\图片资源\国旗.jpg";

                ////该属性如果设置为空,标注只显示图片,如果不为空,那么在图片之上显示文字。
                //label.Text = "";

                feature.Label = islabel ? label : null;

                globeControl1.Globe.Refresh();
            }
        }
Example #3
0
        /// <summary>
        /// 刷新节点
        /// </summary>
        private void RefreshTreeNode()
        {
            treeView1.Nodes.Clear();
            GSOLayer layer = globeControl1.Globe.MemoryLayer;

            for (int i = 0; i < layer.GetAllFeatures().Length; i++)
            {
                GSOFeature feature = layer.GetAt(i);
                if (feature != null)
                {
                    TreeNode tempNode = new TreeNode();
                    tempNode.Text    = feature.Name;
                    tempNode.Checked = feature.Visible;
                    tempNode.Tag     = feature;
                    if (feature.Geometry != null)
                    {
                        treeView1.Nodes.Add(tempNode);
                    }
                }
            }
        }
Example #4
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();
        }
 private void FrmDeleteFieldFromLayer_Load(object sender, EventArgs e)
 {
     if (layer != null)
     {
         textBoxLayerCaption.Text = layer.Caption.Trim();
         if (layer.GetAllFeatures().Length > 0)
         {
             GSOFeature feature = layer.GetAt(0);
             if (feature != null)
             {
                 for (int i = 0; i < feature.GetFieldCount(); i++)
                 {
                     GSOFieldDefn field = (GSOFieldDefn)feature.GetFieldDefn(i);
                     if (field != null)
                     {
                         listViewFields.Items.Add(field.Name.Trim());
                     }
                 }
             }
         }
     }
 }
Example #6
0
 private void valiYBdata(GSOLayer layer)
 {
     txtMessage.Text = "";
     if (layer != null)
     {
         GSOFeatureDataset featDataSet = layer.Dataset as GSOFeatureDataset;
         List<string> lstField = new List<string>();
         List<string> listFieldType_Text = new List<string>();
         for (int i = 0; i < featDataSet.FieldCount; i++)
         {
             string fieldName = featDataSet.GetField(i).Name;
             lstField.Add(fieldName);
             if (yb_types.ContainsKey(fieldName))
             {
                 string fieldType = yb_types[fieldName].ToString().ToUpper();
                 switch (featDataSet.GetField(i).Type)
                 {
                     case EnumFieldType.Text:
                         if (fieldType != "string".ToUpper())
                         {
                             txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                         }
                         listFieldType_Text.Add(fieldName);
                         break;
                     case EnumFieldType.INT32:
                         if (fieldType != "int".ToUpper() && fieldType != "double".ToUpper())
                         {
                             txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                         }
                         break;
                     case EnumFieldType.INT16:
                         if (fieldType != "int".ToUpper() && fieldType != "double".ToUpper())
                         {
                             txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                         }
                         break;
                     case EnumFieldType.Double:
                         if (fieldType != "double".ToUpper())
                         {
                             txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                         }
                         break;
                     case EnumFieldType.Date:
                         if (fieldType != "date".ToUpper())
                         {
                             txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                         }
                         break;
                 }
             }
             else
             {
                 txtMessage.Text += "警告:配置文件中不包含\"" + fieldName + "\"字段\r\n";
             }
         }
         if (!lstField.Contains("编号"))
         {
             txtMessage.Text += "编号字段不存在!\r\n";
         }
         if (!lstField.Contains("管线点编码"))
         {
             txtMessage.Text += "管线点编码字段不存在!\r\n";
         }
         if (!lstField.Contains("井深"))
         {
             txtMessage.Text += "井深字段不存在!\r\n";
         }
         else
         {
             GSOFieldAttr fieldZ = featDataSet.GetField("井深");
             if (fieldZ.Type != EnumFieldType.Double && fieldZ.Type != EnumFieldType.Float && fieldZ.Type != EnumFieldType.INT16 && fieldZ.Type != EnumFieldType.INT32)
             {
                 txtMessage.Text += "\"井深\"字段必须为数值类型 \r\n";
             }
         }
         if (!lstField.Contains("旋转角度"))
         {
             txtMessage.Text += "旋转角度字段不存在!\r\n";
         }
         else
         {
             GSOFieldAttr fieldZ = featDataSet.GetField("旋转角度");
             if (fieldZ.Type != EnumFieldType.Double && fieldZ.Type != EnumFieldType.Float && fieldZ.Type != EnumFieldType.INT16 && fieldZ.Type != EnumFieldType.INT32)
             {
                 txtMessage.Text += "\"旋转角度\"字段必须为数值类型 \r\n";
             }
         }
         for (int i = 0; i < layer.GetAllFeatures().Length; i++)
         {
             GSOFeature f = layer.GetAt(i);
             for (int j = 0; j < listFieldType_Text.Count; j++)
             {
                 string fieldName = listFieldType_Text[j];
                 if (yb_types.ContainsKey(fieldName))
                 {
                     if (f.GetValue(fieldName).ToString().Trim().Length > 8000)
                     {
                         txtMessage.Text += "名称为" + f.Name + "的要素的字段" + fieldName + "的长度大于8000 !\r\n";
                     }
                 }
             }
         }
     }
 }
Example #7
0
 private void valiPipedata(GSOLayer layer)
 {
     txtMessage.Text = "";
     if (layer != null)
     {
         GSOFeatureDataset featDataSet = layer.Dataset as GSOFeatureDataset;
         List<string> lstField = new List<string>();
         List<string> listFieldType_Text = new List<string>();
         for (int i = 0; i < featDataSet.FieldCount; i++)
         {
             string fieldName = featDataSet.GetField(i).Name;
             lstField.Add(fieldName);
             if (fields_types.ContainsKey(fieldName))
             {
                 string fieldType = fields_types[fieldName].ToString().ToUpper();
                 switch (featDataSet.GetField(i).Type)
                 {
                     case EnumFieldType.Text:
                         if (fieldType != "string".ToUpper())
                         {
                             txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                         }
                         listFieldType_Text.Add(fieldName);
                         break;
                     case EnumFieldType.INT32:
                         if (fieldType != "int".ToUpper() && fieldType != "double".ToUpper())
                         {
                             txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                         }
                         break;
                     case EnumFieldType.INT16:
                         if (fieldType != "int".ToUpper() && fieldType != "double".ToUpper())
                         {
                             txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                         }
                         break;
                     case EnumFieldType.Double:
                         if (fieldType != "double".ToUpper())
                         {
                             txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                         }
                         break;
                     case EnumFieldType.Date:
                         if (fieldType != "date".ToUpper())
                         {
                             txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                         }
                         break;
                 }
             }
             else
             {
                 txtMessage.Text += "警告:配置文件中不包含\"" + fieldName + "\"字段\r\n";
             }
         }
         if (!lstField.Contains("Deep1"))
         {
             txtMessage.Text += "Deep1字段不存在!\r\n";
         }
         else
         {
             GSOFieldAttr fieldDeep1 = featDataSet.GetField("Deep1");
             if (fieldDeep1.Type != EnumFieldType.Double && fieldDeep1.Type != EnumFieldType.Float && fieldDeep1.Type != EnumFieldType.INT16 && fieldDeep1.Type != EnumFieldType.INT32)
             {
                 txtMessage.Text += "Deep1字段必须为数值类型\r\n";
             }
         }
         if (!lstField.Contains("Deep2"))
         {
             txtMessage.Text += "Deep2字段不存在!\r\n";
         }
         else
         {
             GSOFieldAttr fieldDeep1 = featDataSet.GetField("Deep2");
             if (fieldDeep1.Type != EnumFieldType.Double && fieldDeep1.Type != EnumFieldType.Float && fieldDeep1.Type != EnumFieldType.INT16 && fieldDeep1.Type != EnumFieldType.INT32)
             {
                 txtMessage.Text += "Deep2字段必须为数值类型\r\n";
             }
         }
         if (!lstField.Contains("Diameter"))
         {
             txtMessage.Text += "Diameter字段不存在!\r\n";
         }
         else
         {
             GSOFieldAttr fieldDeep1 = featDataSet.GetField("Diameter");
             if (fieldDeep1.Type != EnumFieldType.Double && fieldDeep1.Type != EnumFieldType.Float && fieldDeep1.Type != EnumFieldType.INT16 && fieldDeep1.Type != EnumFieldType.INT32)
             {
                 txtMessage.Text += "Diameter字段必须为数值类型\r\n";
             }
         }
         if (!lstField.Contains("Handle"))
         {
             txtMessage.Text += "Handle字段不存在!\r\n";
         }
         List<string> lstHandle = new List<string>();
         for (int i = 0; i < layer.GetAllFeatures().Length; i++)
         {
             GSOFeature f = layer.GetAt(i);
             for (int j = 0; j < listFieldType_Text.Count; j++)
             {
                 string fieldName = listFieldType_Text[j];
                 if (fields_types.ContainsKey(fieldName))
                 {
                     if (f.GetValue(fieldName).ToString().Trim().Length > 8000)
                     {
                         txtMessage.Text += "ID为" + f.ID + "的要素的字段" + fieldName + "的长度大于8000 !\r\n";
                     }
                 }
             }
             if (f.GetFieldAsFloat("Diameter") <= 0)
             {
                 txtMessage.Text += "ID为" + f.ID + "\"Diameter\"字段中的值必须大于0 \r\n";
             }
             if (!lstHandle.Contains(f.GetFieldAsString("Handle")))
             {
                 lstHandle.Add(f.GetFieldAsString("Handle"));
             }
             else
             {
                 txtMessage.Text += "ID为" + f.ID + "的\"Handle\"字段中的值重复\r\n";
             }
         }
     }
 }
Example #8
0
        private void valiPipedata(GSOLayer layer)
        {
            txtMessage.Text = "";
            if (layer != null)
            {
                GSOFeatureDataset featDataSet        = layer.Dataset as GSOFeatureDataset;
                List <string>     lstField           = new List <string>();
                List <string>     listFieldType_Text = new List <string>();
                for (int i = 0; i < featDataSet.FieldCount; i++)
                {
                    string fieldName = featDataSet.GetField(i).Name;
                    lstField.Add(fieldName);
                    if (fields_types.ContainsKey(fieldName))
                    {
                        string fieldType = fields_types[fieldName].ToString().ToUpper();
                        switch (featDataSet.GetField(i).Type)
                        {
                        case EnumFieldType.Text:
                            if (fieldType != "string".ToUpper())
                            {
                                txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                            }
                            listFieldType_Text.Add(fieldName);
                            break;

                        case EnumFieldType.INT32:
                            if (fieldType != "int".ToUpper() && fieldType != "double".ToUpper())
                            {
                                txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                            }
                            break;

                        case EnumFieldType.INT16:
                            if (fieldType != "int".ToUpper() && fieldType != "double".ToUpper())
                            {
                                txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                            }
                            break;

                        case EnumFieldType.Double:
                            if (fieldType != "double".ToUpper())
                            {
                                txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                            }
                            break;

                        case EnumFieldType.Date:
                            if (fieldType != "date".ToUpper())
                            {
                                txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                            }
                            break;
                        }
                    }
                    else
                    {
                        txtMessage.Text += "警告:配置文件中不包含\"" + fieldName + "\"字段\r\n";
                    }
                }
                if (!lstField.Contains("Deep1"))
                {
                    txtMessage.Text += "Deep1字段不存在!\r\n";
                }
                else
                {
                    GSOFieldAttr fieldDeep1 = featDataSet.GetField("Deep1");
                    if (fieldDeep1.Type != EnumFieldType.Double && fieldDeep1.Type != EnumFieldType.Float && fieldDeep1.Type != EnumFieldType.INT16 && fieldDeep1.Type != EnumFieldType.INT32)
                    {
                        txtMessage.Text += "Deep1字段必须为数值类型\r\n";
                    }
                }
                if (!lstField.Contains("Deep2"))
                {
                    txtMessage.Text += "Deep2字段不存在!\r\n";
                }
                else
                {
                    GSOFieldAttr fieldDeep1 = featDataSet.GetField("Deep2");
                    if (fieldDeep1.Type != EnumFieldType.Double && fieldDeep1.Type != EnumFieldType.Float && fieldDeep1.Type != EnumFieldType.INT16 && fieldDeep1.Type != EnumFieldType.INT32)
                    {
                        txtMessage.Text += "Deep2字段必须为数值类型\r\n";
                    }
                }
                if (!lstField.Contains("Diameter"))
                {
                    txtMessage.Text += "Diameter字段不存在!\r\n";
                }
                else
                {
                    GSOFieldAttr fieldDeep1 = featDataSet.GetField("Diameter");
                    if (fieldDeep1.Type != EnumFieldType.Double && fieldDeep1.Type != EnumFieldType.Float && fieldDeep1.Type != EnumFieldType.INT16 && fieldDeep1.Type != EnumFieldType.INT32)
                    {
                        txtMessage.Text += "Diameter字段必须为数值类型\r\n";
                    }
                }
                if (!lstField.Contains("Handle"))
                {
                    txtMessage.Text += "Handle字段不存在!\r\n";
                }
                List <string> lstHandle = new List <string>();
                for (int i = 0; i < layer.GetAllFeatures().Length; i++)
                {
                    GSOFeature f = layer.GetAt(i);
                    for (int j = 0; j < listFieldType_Text.Count; j++)
                    {
                        string fieldName = listFieldType_Text[j];
                        if (fields_types.ContainsKey(fieldName))
                        {
                            if (f.GetValue(fieldName).ToString().Trim().Length > 8000)
                            {
                                txtMessage.Text += "ID为" + f.ID + "的要素的字段" + fieldName + "的长度大于8000 !\r\n";
                            }
                        }
                    }
                    if (f.GetFieldAsFloat("Diameter") <= 0)
                    {
                        txtMessage.Text += "ID为" + f.ID + "\"Diameter\"字段中的值必须大于0 \r\n";
                    }
                    if (!lstHandle.Contains(f.GetFieldAsString("Handle")))
                    {
                        lstHandle.Add(f.GetFieldAsString("Handle"));
                    }
                    else
                    {
                        txtMessage.Text += "ID为" + f.ID + "的\"Handle\"字段中的值重复\r\n";
                    }
                }
            }
        }
Example #9
0
        private void valiGongJingdata(GSOLayer layer)
        {
            txtMessage.Text = "";
            if (layer != null)
            {
                GSOFeatureDataset featDataSet        = layer.Dataset as GSOFeatureDataset;
                List <string>     lstField           = new List <string>();
                List <string>     listFieldType_Text = new List <string>();
                for (int i = 0; i < featDataSet.FieldCount; i++)
                {
                    string fieldName = featDataSet.GetField(i).Name;
                    lstField.Add(fieldName);
                    if (gj_types.ContainsKey(fieldName))
                    {
                        string fieldType = gj_types[fieldName].ToString().ToUpper();
                        switch (featDataSet.GetField(i).Type)
                        {
                        case EnumFieldType.Text:
                            if (fieldType != "string".ToUpper())
                            {
                                txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                            }
                            listFieldType_Text.Add(fieldName);
                            break;

                        case EnumFieldType.INT32:
                            if (fieldType != "int".ToUpper() && fieldType != "double".ToUpper())
                            {
                                txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                            }
                            break;

                        case EnumFieldType.INT16:
                            if (fieldType != "int".ToUpper() && fieldType != "double".ToUpper())
                            {
                                txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                            }
                            break;

                        case EnumFieldType.Double:
                            if (fieldType != "double".ToUpper())
                            {
                                txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                            }
                            break;

                        case EnumFieldType.Date:
                            if (fieldType != "date".ToUpper())
                            {
                                txtMessage.Text += "" + fieldName + "数据类型不正确\r\n";
                            }
                            break;
                        }
                    }
                    else
                    {
                        txtMessage.Text += "警告:配置文件中不包含\"" + fieldName + "\"字段\r\n";
                    }
                    //if (fieldName == "井深")
                    //{
                    //    if (featDataSet.GetField(i).Type != EnumFieldType.Double)
                    //    {
                    //        txtMessage.Text += "井深字段数据类型不正确!\r\n";
                    //    }
                    //}
                    //if (fieldName == "管线点编码")
                    //{
                    //    if (featDataSet.GetField(i).Type != EnumFieldType.Double)
                    //    {
                    //        txtMessage.Text += "管线点编码字段数据类型不正确!\r\n";
                    //    }
                    //}
                }
                if (!lstField.Contains("编号"))
                {
                    txtMessage.Text += "编号字段不存在!\r\n";
                }
                if (!lstField.Contains("管线点编码"))
                {
                    txtMessage.Text += "管线点编码字段不存在!\r\n";
                }
                if (!lstField.Contains("井深"))
                {
                    txtMessage.Text += "井深字段不存在!\r\n";
                }
                else
                {
                    GSOFieldAttr fieldZ = featDataSet.GetField("井深");
                    if (fieldZ.Type != EnumFieldType.Double && fieldZ.Type != EnumFieldType.Float && fieldZ.Type != EnumFieldType.INT16 && fieldZ.Type != EnumFieldType.INT32)
                    {
                        txtMessage.Text += "\"井深\"字段必须为数值类型 \r\n";
                    }
                }
                for (int i = 0; i < layer.GetAllFeatures().Length; i++)
                {
                    GSOFeature f = layer.GetAt(i);
                    for (int j = 0; j < listFieldType_Text.Count; j++)
                    {
                        string fieldName = listFieldType_Text[j];
                        if (gj_types.ContainsKey(fieldName))
                        {
                            if (f.GetValue(fieldName).ToString().Trim().Length > 8000)
                            {
                                txtMessage.Text += "名称为" + f.Name + "的要素的字段" + fieldName + "的长度大于8000 !\r\n";
                            }
                        }
                    }
                }
            }
        }
Example #10
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            string layerPath = textBoxLayerPath.Text.Trim();

            if (layerPath == "")
            {
                MessageBox.Show("请选择目标文件!", "提示");
                return;
            }
            string featureMinLength = textBoxFeatureMinLength.Text.Trim();
            double minLength        = 0;

            if (!double.TryParse(featureMinLength, out minLength))
            {
                MessageBox.Show("请输入正确的最小长度值!", "提示");
                return;
            }
            string featureMaxLength = textBoxFeatureMaxLength.Text.Trim();
            double maxLength        = 0;

            if (!double.TryParse(featureMaxLength, out maxLength))
            {
                MessageBox.Show("请输入正确的最大长度值!", "提示");
                return;
            }
            string featureCount = textBoxFeatureCount.Text.Trim();
            int    count        = 0;

            if (checkBoxFeatureCount.Checked)
            {
                if (!int.TryParse(featureCount, out count))
                {
                    MessageBox.Show("请输入正确的要素个数值!", "提示");
                    return;
                }
            }

            GSOLayer layer = globeControl1.Globe.Layers.Add(layerPath);

            if (layer != null)
            {
                do
                {
                    for (int i = layer.GetAllFeatures().Length - 1; i >= 0; i--)
                    {
                        GSOFeature feature = layer.GetAt(i);
                        if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
                        {
                            GSOGeoPolyline3D line   = feature.Geometry as GSOGeoPolyline3D;
                            double           length = line.GetSpaceLength(false, 6378137.0);
                            if (length >= minLength && length <= maxLength)
                            {
                                feature.Delete();
                            }
                        }
                        //else
                        //{
                        //    feature.Delete();
                        //}
                    }
                    maxLength++;
                }while (checkBoxFeatureCount.Checked && layer.GetAllFeatures().Length > 30000);
                layer.SaveAs(Path.GetDirectoryName(textBoxLayerPath.Text.Trim()) + "/" + layer.Caption + "-处理后" + Path.GetExtension(textBoxLayerPath.Text.Trim()));
                MessageBox.Show("删除成功!", "提示");
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (comboBoxLayers.Text == "")
            {
                MessageBox.Show("请选择一个图层!");
                return;
            }
            GSOLayer layer = mGlobeControl.Globe.Layers.GetLayerByCaption(comboBoxLayers.Text.Trim());

            if (layer == null)
            {
                MessageBox.Show("您选择的图层不存在!");
                return;
            }

            string iconPath = textBoxIconPath.Text.Trim();

            if (iconPath == "")
            {
                iconPath = Application.StartupPath + "\\Resource\\DefaultIcon.png";
            }

            Color  lineColor     = textBoxLineColor.BackColor;
            string strLineWidth  = textBoxLineWidth.Text.Trim();
            double lineWidth     = 1;
            bool   blIsLineWidth = double.TryParse(strLineWidth, out lineWidth);

            Color  outlineColor     = textBoxOutlineColor.BackColor;
            string strOutlineWidth  = textBoxOutlineWidth.Text.Trim();
            double outlineWidth     = 1;
            bool   blIsOutlineWidth = double.TryParse(strOutlineWidth, out outlineWidth);
            Color  polygonColor     = textBoxPolygonColor.BackColor;
            string strPolygonAlpha  = textBoxPolygonAlpha.Text.Trim();
            int    polygonAlpha     = 255;
            bool   blIsPolygonAlpha = int.TryParse(strPolygonAlpha, out polygonAlpha);

            polygonColor = Color.FromArgb(polygonAlpha, polygonColor);

            for (int i = 0; i < layer.GetAllFeatures().Length; i++)
            {
                GSOFeature feature = layer.GetAt(i);
                if (feature.Geometry != null)
                {
                    switch (feature.Geometry.Type)
                    {
                    case EnumGeometryType.GeoPoint3D:
                        if (panelPoints.Enabled)
                        {
                            GSOGeoPoint3D point  = (GSOGeoPoint3D)feature.Geometry;
                            GSOGeoMarker  marker = new GSOGeoMarker();
                            marker.Position    = point.Position;
                            marker.Name        = point.Name;
                            marker.CameraState = point.CameraState;
                            marker.Label       = point.Label;

                            GSOFeature newFeature = new GSOFeature();
                            newFeature.Name     = feature.Name;
                            newFeature.Geometry = marker;

                            layer.RemoveAt(i);
                            layer.AddFeature(newFeature);
                            i--;
                        }
                        break;

                    case EnumGeometryType.GeoMarker:
                        if (panelPoints.Enabled)
                        {
                            GSOGeoMarker     marker = (GSOGeoMarker)feature.Geometry;
                            GSOMarkerStyle3D style  = null;

                            if (marker.Style == null)
                            {
                                style = new GSOMarkerStyle3D();
                            }
                            else
                            {
                                style = (GSOMarkerStyle3D)marker.Style;
                            }

                            style.TextVisible = !checkBoxHideLabelOfMarker.Checked;
                            style.IconPath    = iconPath.Trim();

                            marker.Style = style;
                        }
                        break;

                    case EnumGeometryType.GeoPolyline3D:
                        if (panelLines.Enabled)
                        {
                            GSOGeoPolyline3D line = (GSOGeoPolyline3D)feature.Geometry;
                            if (line.Label != null)
                            {
                                line.Label.Visible = !checkBoxHideLabelOfLine.Checked;
                            }
                            if (line.Style == null)
                            {
                                GSOSimpleLineStyle3D styleLine = new GSOSimpleLineStyle3D();
                                styleLine.LineColor = lineColor;
                                styleLine.LineWidth = lineWidth;
                                line.Style          = styleLine;
                            }
                            else
                            {
                                GSOSimpleLineStyle3D styleLine = (GSOSimpleLineStyle3D)line.Style;
                                if (styleLine == null)
                                {
                                    GSOPipeLineStyle3D pipeStyle = (GSOPipeLineStyle3D)line.Style;
                                    if (pipeStyle != null)
                                    {
                                        pipeStyle.LineColor = lineColor;
                                        pipeStyle.Radius    = lineWidth / 2;
                                        line.Style          = pipeStyle;
                                    }
                                }
                                else
                                {
                                    styleLine.LineColor = lineColor;
                                    styleLine.LineWidth = lineWidth;
                                    line.Style          = styleLine;
                                }
                            }
                        }
                        break;

                    case EnumGeometryType.GeoPolygon3D:
                        if (panelPolygons.Enabled)
                        {
                            GSOGeoPolygon3D polygon = (GSOGeoPolygon3D)feature.Geometry;
                            if (polygon.Label != null)
                            {
                                polygon.Label.Visible = !checkBoxHideLabelOfPolygon.Checked;
                            }
                            GSOSimplePolygonStyle3D stylePolygon = (polygon.Style == null ? new GSOSimplePolygonStyle3D() : (GSOSimplePolygonStyle3D)polygon.Style);
                            stylePolygon.FillColor      = polygonColor;
                            stylePolygon.OutLineVisible = true;
                            GSOSimpleLineStyle3D styleOutline = (GSOSimpleLineStyle3D)stylePolygon.OutlineStyle;
                            if (styleOutline == null)
                            {
                                styleOutline = new GSOSimpleLineStyle3D();
                            }
                            styleOutline.LineWidth    = outlineWidth;
                            styleOutline.LineColor    = outlineColor;
                            stylePolygon.OutlineStyle = styleOutline;
                            polygon.Style             = stylePolygon;
                        }
                        break;
                    }
                }
            }
            mGlobeControl.Globe.Refresh();
            this.Close();
        }
        private bool valiValvedata()
        {
            if (comboBoxShpLayerList.SelectedItem == null)
            {
                MessageBox.Show("请选择一个shp图层!");
                return(false);
            }
            GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxShpLayerList.SelectedItem.ToString().Trim());

            if (layer == null)
            {
                MessageBox.Show("选择的图层为空!");
                return(false);
            }
            if (layer != null)
            {
                GSOFeatureDataset featDataSet = layer.Dataset as GSOFeatureDataset;

                if (featDataSet.FieldCount <= 0)
                {
                    MessageBox.Show("图层中字段数必须大于0");
                    return(false);
                }
                GSOFieldAttr fieldID = featDataSet.GetField("编号");
                if (fieldID == null)
                {
                    MessageBox.Show("编号 字段不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                GSOFieldAttr fieldModelPath = featDataSet.GetField("模型路径");
                if (fieldModelPath == null)
                {
                    MessageBox.Show("模型路径 字段不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                GSOFieldAttr fieldZ = featDataSet.GetField("Z坐标");
                if (fieldZ.Type != EnumFieldType.Double && fieldZ.Type != EnumFieldType.Float && fieldZ.Type != EnumFieldType.INT16 && fieldZ.Type != EnumFieldType.INT32)
                {
                    MessageBox.Show("Z坐标 必须为数值类型", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }

                for (int i = 0; i < layer.GetAllFeatures().Length; i++)
                {
                    GSOFeature f = layer.GetAt(i);
                    for (int j = 0; j < featDataSet.FieldCount; j++)
                    {
                        GSOFieldAttr field = featDataSet.GetField(j);
                        if (field.Type == EnumFieldType.Text)
                        {
                            if (f.GetValue(j).ToString().Trim().Length > 5000)
                            {
                                MessageBox.Show("ID为" + f.ID + "的要素的字段" + field.Name + "的长度大于5000 !\r\n", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                return(false);
                            }
                        }
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #13
0
        //查询
        private void buttonConditionSelect_Click(object sender, EventArgs e)
        {
            if (layer == null)
            {
                MessageBox.Show("请选择一个图层!");
                return;
            }
            if (comboBoxConditionFieldName.Text == "" || comboBoxConditionFieldValue.Text == "" || comboBoxCondition.Text == "")
            {
                MessageBox.Show("请输入完整的查询条件!", "提示");
                return;
            }
            GSOFeatureDataset featureDataset   = layer.Dataset as GSOFeatureDataset;
            EnumFieldType     currentFieldType = EnumFieldType.Text;

            if (featureDataset != null)
            {
                GSOFieldAttr field = featureDataset.GetField(comboBoxConditionFieldName.Text);
                if (field != null)
                {
                    switch (field.Type)
                    {
                    case EnumFieldType.Double:
                    case EnumFieldType.INT32:
                        currentFieldType = EnumFieldType.Double;
                        break;

                    case EnumFieldType.Date:
                        currentFieldType = EnumFieldType.Date;
                        break;
                    }
                }
            }

            try
            {
                switch (comboBoxCondition.Text)
                {
                case "=":
                    for (int i = 0; i < layer.GetAllFeatures().Length; i++)
                    {
                        GSOFeature feature = layer.GetAt(i);
                        if (feature != null && feature.GetValue(comboBoxConditionFieldName.Text).ToString() == comboBoxConditionFieldValue.Text)
                        {
                            features.Add(feature);
                        }
                    }
                    break;

                case ">=":
                    for (int i = 0; i < layer.GetAllFeatures().Length; i++)
                    {
                        GSOFeature feature = layer.GetAt(i);
                        if (currentFieldType == EnumFieldType.Double)
                        {
                            if (feature != null && Double.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) >= Double.Parse(comboBoxConditionFieldValue.Text))
                            {
                                features.Add(feature);
                            }
                        }
                        else if (currentFieldType == EnumFieldType.Date)
                        {
                            if (feature != null && DateTime.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) >= DateTime.Parse(comboBoxConditionFieldValue.Text))
                            {
                                features.Add(feature);
                            }
                        }
                    }
                    break;

                case "<=":
                    for (int i = 0; i < layer.GetAllFeatures().Length; i++)
                    {
                        GSOFeature feature = layer.GetAt(i);
                        if (currentFieldType == EnumFieldType.Double)
                        {
                            if (feature != null && Double.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) <= Double.Parse(comboBoxConditionFieldValue.Text))
                            {
                                features.Add(feature);
                            }
                        }
                        else if (currentFieldType == EnumFieldType.Date)
                        {
                            if (feature != null && DateTime.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) <= DateTime.Parse(comboBoxConditionFieldValue.Text))
                            {
                                features.Add(feature);
                            }
                        }
                    }
                    break;

                case ">":
                    for (int i = 0; i < layer.GetAllFeatures().Length; i++)
                    {
                        GSOFeature feature = layer.GetAt(i);
                        if (currentFieldType == EnumFieldType.Double)
                        {
                            if (feature != null && Double.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) > Double.Parse(comboBoxConditionFieldValue.Text))
                            {
                                features.Add(feature);
                            }
                        }
                        else if (currentFieldType == EnumFieldType.Date)
                        {
                            if (feature != null && DateTime.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) > DateTime.Parse(comboBoxConditionFieldValue.Text))
                            {
                                features.Add(feature);
                            }
                        }
                    }
                    break;

                case "<":
                    for (int i = 0; i < layer.GetAllFeatures().Length; i++)
                    {
                        GSOFeature feature = layer.GetAt(i);
                        if (currentFieldType == EnumFieldType.Double)
                        {
                            if (feature != null && Double.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) < Double.Parse(comboBoxConditionFieldValue.Text))
                            {
                                features.Add(feature);
                            }
                        }
                        else if (currentFieldType == EnumFieldType.Date)
                        {
                            if (feature != null && DateTime.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) < DateTime.Parse(comboBoxConditionFieldValue.Text))
                            {
                                features.Add(feature);
                            }
                        }
                    }
                    break;
                }
                if (features == null)
                {
                    MessageBox.Show("请重新输入查询条件!", "提示");
                    return;
                }
                if (features.Length == 0)
                {
                    MessageBox.Show("没有找到符合查询条件的对象!", "提示");
                    return;
                }
                SetDataTable(features);
            }
            catch (Exception ex)
            {
                Log.PublishTxt(ex);
                MessageBox.Show(ex.Message, "提示");
                return;
            }
        }
        //应用
        private void buttonApply_Click(object sender, EventArgs e)
        {
            if (comboBoxLayerCaption.SelectedItem == null)
            {
                MessageBox.Show("请选择一个管线图层!", "提示");
                return;
            }
            if (comboBoxLayerValveCaption.SelectedItem == null)
            {
                MessageBox.Show("请选择一个工井图层!", "提示");
                return;
            }
            if (textBoxValueIndented.Text.Trim() == "")
            {
                MessageBox.Show("请输入缩进距离!", "提示");
                return;
            }
            if (textBoxAllowance.Text.Trim() == "")
            {
                MessageBox.Show("请输入容限值!", "提示");
                return;
            }

            double valueAllowance = 0.0;

            if (double.TryParse(textBoxAllowance.Text.Trim(), out valueAllowance) == false)
            {
                MessageBox.Show("请输入一个正确的容限值!", "提示");
                return;
            }

            float valueIndented = 0.0f;

            if (float.TryParse(textBoxValueIndented.Text.Trim(), out valueIndented) == false)
            {
                MessageBox.Show("请输入一个正确的缩进值!", "提示");
                return;
            }

            string   layerCaption      = comboBoxLayerCaption.SelectedItem.ToString().Trim();
            string   valveLayerCaption = comboBoxLayerValveCaption.SelectedItem.ToString().Trim();
            GSOLayer layer             = globeControl1.Globe.Layers.GetLayerByCaption(layerCaption);
            GSOLayer valveLayer        = globeControl1.Globe.Layers.GetLayerByCaption(valveLayerCaption);

            if (layer != null && valveLayerCaption != null)
            {
                featuresIndented.RemoveAll();
                cancelHighLight(layer.GetAllFeatures());


                for (int i = 0; i < layer.GetAllFeatures().Length; i++)
                {
                    GSOFeature feature = layer.GetAt(i);
                    if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
                    {
                        GSOGeoPolyline3D line       = feature.Geometry as GSOGeoPolyline3D;
                        double           lineLenght = line.GetSpaceLength(false, 6378137.0);
                        if (lineLenght <= valueIndented * 2)
                        {
                            continue;
                        }

                        featuresIndented.Add(feature);//缩进的管线集合
                        featuresInit.Add(feature.Clone());

                        //头缩进
                        GSOPoint3d       headPoint = line[0][0];
                        GSOGeoPolyline3D newline   = new GSOGeoPolyline3D();
                        GSOPoint3ds      part      = new GSOPoint3ds();
                        part.Add(headPoint);
                        headPoint.X = headPoint.X - 0.0000000005;
                        part.Add(headPoint);
                        newline.AddPart(part);
                        GSOGeoPolygon3D buffer   = newline.CreateBuffer(valueAllowance, true, 5, true, false);
                        GSOFeatures     features = valveLayer.FindFeaturesInPolygon(buffer, false);
                        if (features.Length > 0)
                        {
                            feature.HighLight = true;
                            if (line.Style != null && line.Style is GSOPipeLineStyle3D)
                            {
                                GSOPipeLineStyle3D style = line.Style as GSOPipeLineStyle3D;
                                style.HeadJointParam        = new GSOPipeJointParam();
                                style.HeadJointParam.Extent = -valueIndented;
                            }
                        }

                        //尾缩进
                        GSOPoint3d tailPoint = line[line.PartCount - 1][line[line.PartCount - 1].Count - 1];
                        newline = new GSOGeoPolyline3D();
                        part    = new GSOPoint3ds();
                        part.Add(tailPoint);
                        tailPoint.X = tailPoint.X - 0.0000000005;
                        part.Add(tailPoint);
                        newline.AddPart(part);
                        buffer   = newline.CreateBuffer(valueAllowance, true, 5, true, false);
                        features = valveLayer.FindFeaturesInPolygon(buffer, false);
                        if (features.Length > 0)
                        {
                            feature.HighLight = true;
                            if (line.Style != null && line.Style is GSOPipeLineStyle3D)
                            {
                                GSOPipeLineStyle3D style = line.Style as GSOPipeLineStyle3D;
                                style.TailJointParam        = new GSOPipeJointParam();
                                style.TailJointParam.Extent = -valueIndented;
                            }
                        }
                    }
                }
            }
            globeControl1.Globe.Refresh();
        }
Example #15
0
        private List <DataTable> CollisionAnalysis()
        {
            List <DataTable> listTable = new List <DataTable>();
            GSOPoint3d       pntIntersect1;
            GSOPoint3d       pntIntersect2;
            int layerCount = listBox1.SelectedItems.Count;

            for (int i = 0; i < layerCount; i++)//遍历所有的图层
            {
                GSOLayer layer1 = globeControl1.Globe.Layers.GetLayerByCaption(listBox1.SelectedItems[i].ToString().Trim());
                if (layer1 != null)
                {
                    DataTable dt = new DataTable();
                    if (layer1.GetAllFeatures().Length > 0)
                    {
                        for (int fieldName = 0; fieldName < layer1.GetAt(0).GetFieldCount(); fieldName++)
                        {
                            GSOFieldDefn field = (GSOFieldDefn)layer1.GetAt(0).GetFieldDefn(fieldName);
                            dt.Columns.Add(field.Name);
                        }
                    }
                    listTable.Add(dt);
                }
            }

            if (listTable.Count > 0 && listTable.Count == layerCount)
            {
                for (int i = 0; i < layerCount; i++)//遍历所有的图层
                {
                    GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(listBox1.SelectedItems[i].ToString().Trim());
                    if (layer.Caption.Contains("管线")) //过滤出管线图层
                    {
                        GSOFeatureLayer   flayer   = layer as GSOFeatureLayer;
                        GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset;
                        GSOFeatures       feats    = flayer.GetAllFeatures();


                        for (int m = 0; m < feats.Length; m++) //遍历图层中的所有管线
                        {
                            GSOFeature feat = feats[m];

                            GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D;
                            if (line1 == null)
                            {
                                continue;
                            }
                            GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D;
                            if (pipeStyle1 == null)
                            {
                                continue;
                            }
                            for (int j = i; j < layerCount; j++)
                            {
                                GSOLayer        layer2  = globeControl1.Globe.Layers.GetLayerByCaption(listBox1.SelectedItems[j].ToString().Trim());
                                GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer;
                                if (layer2.Caption.Contains("管线"))
                                {
                                    GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset;
                                    GSOFeatures       feats2    = flayer2.GetAllFeatures();
                                    for (int n = 0; n < feats2.Length; n++)//遍历图层中的所有管线
                                    {
                                        if (i == j)
                                        {
                                            if (m >= n)
                                            {
                                                continue;
                                            }
                                        }
                                        GSOFeature       feat2 = feats2[n];
                                        GSOGeoPolyline3D line2 = feat2.Geometry as GSOGeoPolyline3D;
                                        if (line2 == null)
                                        {
                                            continue;
                                        }
                                        GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D;
                                        if (pipeStyle2 == null)
                                        {
                                            continue;
                                        }
                                        double dHonLen;
                                        double dVerLen;
                                        double dNoIntersectStartRatio = 0;
                                        // 计算两条线的距离和交点,若果失败返回-1
                                        // 若在同一直线上,并且有交点,返回0
                                        // 若不在同一平面,返回最近两点的距离,并且计算最近两点
                                        double dDist = globeControl1.Globe.Analysis3D.ComputeTwoGeoPolylineDistance(line1, line2, out pntIntersect1, out pntIntersect2, out dHonLen, out dVerLen, false, false, dNoIntersectStartRatio);
                                        if (dDist > -1)
                                        {
                                            if (dDist != 0)
                                            {
                                                dDist = dDist - pipeStyle1.Radius - pipeStyle2.Radius;
                                                if (dDist < 0) //发生碰撞,把发生碰撞的管线名称添加到DataTable里
                                                {
                                                    DataRow newRow = listTable[i].NewRow();
                                                    for (int fieldName = 0; fieldName < feats[m].GetFieldCount(); fieldName++)
                                                    {
                                                        newRow[fieldName] = feats[m].GetValue(fieldName);
                                                    }
                                                    if (newRow != null)
                                                    {
                                                        listTable[i].Rows.Add(newRow);
                                                    }

                                                    DataRow newRow1 = listTable[j].NewRow();
                                                    for (int fieldName = 0; fieldName < feats2[n].GetFieldCount(); fieldName++)
                                                    {
                                                        newRow1[fieldName] = feats2[n].GetValue(fieldName);
                                                    }
                                                    if (newRow != null)
                                                    {
                                                        listTable[j].Rows.Add(newRow1);
                                                    }
                                                    //newRow["编号1"] = layer.Caption + "-" + feats[m].ID;
                                                    //newRow["编号2"] = layer2.Caption + "-" + feats2[n].ID;
                                                    //dt.Rows.Add(newRow);
                                                }
                                            }
                                        }
                                        line2.ReleaseInnerPointer();
                                        feat2.ReleaseInnerPointer();
                                    }
                                    feats2.ReleaseInnerPointer();
                                }
                            }
                            line1.ReleaseInnerPointer();
                            feat.ReleaseInnerPointer();
                        }
                        feats.ReleaseInnerPointer();
                    }
                }
            }
            return(listTable);
        }