Ejemplo n.º 1
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";
             }
         }
     }
 }
Ejemplo n.º 2
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";
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     int selectIndex = comboBox1.SelectedIndex;
     if (selectIndex >= 0)
     {
         layer = mGlobeControl.Globe.Layers.GetLayerByCaption(comboBox1.SelectedItem.ToString());
         if (layer != null)
         {
             features = layer.GetAllFeatures();
             if (features.Length > 0)
             {
                 GSOFeature feature = features[0];
                 if (feature.GetFieldCount() > 0)
                 {
                     for (int i = 0; i < feature.GetFieldCount(); i++)
                     {
                         GSOFieldDefn defn = (GSOFieldDefn)feature.GetFieldDefn(i);
                         listBox1.Items.Add(defn.Name);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
 GSOFeatures GetAllRealFeatures(GSOLayer layer)
 {
     if (layer == null)
     {
         return null;
     }
     GSOFeatures realfeatures = new GSOFeatures();
     for (int i = 0; i < layer.GetAllFeatures().Length; i++)
     {
         GSOFeature feature = layer.GetAllFeatures()[i];
         GetRealFeature(feature, realfeatures);
     }
     return realfeatures;
 }
        private bool valiPipeData()
        {
            if (comboBoxShpLayerList.SelectedItem == null)
            {
                MessageBox.Show("请选择一个shp图层!");
                return(false);
            }
            GSOLayer sourceLayer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxShpLayerList.SelectedItem.ToString().Trim());

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

            if (featDataSet.FieldCount <= 0)
            {
                MessageBox.Show("图层中字段数必须大于0");
                return(false);
            }
            GSOFieldAttr fieldDeep1 = featDataSet.GetField("Deep1");

            if (fieldDeep1 == null)
            {
                MessageBox.Show("Deep1字段不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            if (fieldDeep1.Type != EnumFieldType.Double && fieldDeep1.Type != EnumFieldType.Float && fieldDeep1.Type != EnumFieldType.INT16 && fieldDeep1.Type != EnumFieldType.INT32)
            {
                MessageBox.Show("Deep1必须为数值类型", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            GSOFieldAttr fieldDeep2 = featDataSet.GetField("Deep2");

            if (fieldDeep2 == null)
            {
                MessageBox.Show("Deep2字段不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            if (fieldDeep2.Type != EnumFieldType.Double && fieldDeep2.Type != EnumFieldType.Float && fieldDeep2.Type != EnumFieldType.INT16 && fieldDeep2.Type != EnumFieldType.INT32)
            {
                MessageBox.Show("Deep2必须为数值类型", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            GSOFieldAttr fieldDiameter = featDataSet.GetField("Diameter");

            if (fieldDiameter == null)
            {
                MessageBox.Show("Diameter字段不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            if (fieldDiameter.Type != EnumFieldType.Double && fieldDiameter.Type != EnumFieldType.Float)
            {
                MessageBox.Show("Diameter必须为数值类型", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            List <string> lst = new List <string>();

            for (int j = 0; j < features.Length; j++)
            {
                if (features[j].GetFieldAsFloat("Diameter") <= 0)
                {
                    MessageBox.Show("Diameter中的值必须大于0", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                if (!lst.Contains(features[j].GetFieldAsString("Handle")))
                {
                    lst.Add(features[j].GetFieldAsString("Handle"));
                }
                else
                {
                    MessageBox.Show("Handle字段必须唯一!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
            }
            return(true);
        }
        private GSOFeatureDataset CreateDBFeatureDataset(string name)
        {
            if (comboBoxShpLayerList.SelectedItem == null)
            {
                MessageBox.Show("请选择一个Shp图层!", "提示");
                return(null);
            }
            GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxShpLayerList.SelectedItem.ToString().Trim());

            if (layer == null)
            {
                MessageBox.Show("Shp图层为空!", "提示");
                return(null);
            }
            GSOFeatures features = layer.GetAllFeatures();

            if (features.Length == 0)
            {
                MessageBox.Show("图层要素个数为0!", "提示");
                return(null);
            }

            GSOFeatureDataset featureDataset = layer.Dataset as GSOFeatureDataset;

            if (featureDataset == null)
            {
                MessageBox.Show("Shp图层不是矢量图层!", "提示");
                return(null);
            }
            if (comboBoxDataSourceList.SelectedItem == null)
            {
                MessageBox.Show("请选择一个目标数据源!", "提示");
                return(null);
            }
            GSODataSource ds = Utility.getDataSourceByFullName(globeControl1, comboBoxDataSourceList.SelectedItem.ToString().Trim());

            if (ds == null)
            {
                MessageBox.Show("选择的目标数据源为空!", "提示");
                return(null);
            }
            GSOFeatureDataset newFeatureDataset = ds.CreateFeatureDataset(name);

            if (newFeatureDataset == null)
            {
                MessageBox.Show("输入的图层名称不符合要求!", "提示");
                return(null);
            }
            for (int i = 0; i < featureDataset.FieldCount; i++)
            {
                GeoScene.Data.GSOFieldAttr fielddef = featureDataset.GetField(i);
                if (!en_cns.Contains(fielddef.Name))
                {
                    continue;
                }
                GSOFieldAttr field = new GSOFieldAttr();
                field.Name      = en_cns.ContainsKey(fielddef.Name) == true ? en_cns[fielddef.Name].ToString() : fielddef.Name;
                field.Type      = fielddef.Type;
                field.Width     = fielddef.Width;
                field.Precision = fielddef.Precision;
                bool res = newFeatureDataset.AddField(field);
            }

            newFeatureDataset.Save();
            return(newFeatureDataset);
        }
Ejemplo n.º 7
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)
        {
            if (comboBoxDataSourceList.SelectedItem == null)
            {
                MessageBox.Show("请选择一个目标数据源!", "提示");
                return;
            }
            GSODataSource ds = Utility.getDataSourceByFullName(globeControl1, comboBoxDataSourceList.SelectedItem.ToString().Trim());

            if (ds == null)
            {
                MessageBox.Show("选择的目标数据源为空!", "提示");
                return;
            }
            //判断是数字或者存在特殊字符串
            string SuiD = textBoxNewLayerName.Text.ToString().Trim();
            Regex  reg  = new Regex("^[0-9]+$");//判断是不是数据,要不是就表示没有选择。则从隐藏域里读出来
            Match  ma   = reg.Match(SuiD);

            if (ma.Success)
            {
                MessageBox.Show("管线图层名称不能全部为数字!", "警告");
                return;
            }

            try
            {
                // if (valiPipeData())
                {
                    if (string.IsNullOrEmpty(textBoxNewLayerName.Text))
                    {
                        MessageBox.Show("管线图层名称无效!", "提示");
                        return;
                    }

                    GSODataset dataset = ds.GetDatasetByName(textBoxNewLayerName.Text.Trim());

                    GSOFeatureDataset newFeatureDataset;
                    if (dataset != null)
                    {
                        DialogResult result = MessageBox.Show("管线图层名称在数据库中已存在!是否向该表追加", "提示", MessageBoxButtons.YesNo);
                        if (result == DialogResult.Yes)
                        {
                            newFeatureDataset = dataset as GSOFeatureDataset;
                        }
                        else
                        {
                            return;
                        }
                    }
                    else
                    {
                        newFeatureDataset = CreateDBFeatureDataset(textBoxNewLayerName.Text.Trim());
                    }
                    if (newFeatureDataset == null)
                    {
                        return;
                    }
                    GSOLayer sourceLayer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxShpLayerList.SelectedItem.ToString().Trim());
                    newFeatureDataset.Open();
                    GSOFeatures features = sourceLayer.GetAllFeatures(true);
                    string      message  = "";
                    for (int j = 0; j < features.Length; j++)
                    {
                        GSOFeature f = features[j];

                        GSOGeoPolyline3D lineeee = f.Geometry as GSOGeoPolyline3D;
                        if (lineeee == null)
                        {
                            message += "ID为" + f.ID + "的对象不是一个线对象\n";
                            continue;
                        }
                        double length = lineeee.GetSpaceLength(true, 6378137);
                        if (length == 0)
                        {
                            message += "ID为" + f.ID + "的管线长度为0\n";
                            continue;
                        }

                        GSOFeature newFeature = newFeatureDataset.CreateFeature();

                        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.INT32 || 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)
                        {
                            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 * 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     fenmu      = 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));

                            if (fenmu == 0)
                            {
                                pt3d.Z = deep1;
                            }
                            else
                            {
                                double radio = Math.Sqrt(Math.Pow(pt3d.Y - line[0][0].Y, 2) + Math.Pow(pt3d.X - line[0][0].X, 2)) / fenmu;
                                pt3d.Z = deep1 + (deep2 - deep1) * radio;
                            }

                            if (double.IsInfinity(pt3d.Z))
                            {
                                pt3d.Z = deep2;
                            }
                            line[0][n] = pt3d;
                        }

                        newFeature.Geometry       = line; // f.Geometry;
                        newFeature.Geometry.Style = style;
                        newFeature.Name           = eventid;

                        for (int i = 0; i < f.GetFieldCount(); i++)
                        {
                            GeoScene.Data.GSOFieldDefn fielddef = (GeoScene.Data.GSOFieldDefn)(f.GetFieldDefn(i));
                            if (fielddef == null)
                            {
                                continue;
                            }
                            if (!en_cns.Contains(fielddef.Name))
                            {
                                continue;
                            }
                            object fieldvalue = f.GetValue(fielddef.Name);// convertFieldValue(fielddef.Name, f.GetValue(fielddef.Name));
                            if (fieldvalue == null)
                            {
                                continue;
                            }
                            string fieldName = en_cns.ContainsKey(fielddef.Name) == true ? en_cns[fielddef.Name].ToString() : fielddef.Name;
                            newFeature.SetValue(fieldName, fieldvalue);
                        }

                        newFeatureDataset.AddFeature(newFeature);
                    }
                    newFeatureDataset.Save();
                    newFeatureDataset.Caption = newFeatureDataset.Name;
                    globeControl1.Globe.Layers.Add(newFeatureDataset);
                    globeControl1.Refresh();

                    string strMessage = "shp文件中共" + features.Length + "个对象,实际入库" + newFeatureDataset.GetAllFeatures().Length + "个对象!\n";
                    if (message == "")
                    {
                        MessageBox.Show(strMessage, "提示");
                    }
                    else
                    {
                        FrmMessageShow frm = new FrmMessageShow(strMessage + message);
                        frm.ShowDialog();
                    }
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                Log.PublishTxt(ex);
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 9
0
        //应用
        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();
        }
Ejemplo n.º 10
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;
            }
        }
Ejemplo n.º 11
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);
        }
        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);
            }
        }
Ejemplo n.º 13
0
 private void AddKmlLayer(GSOLayer layer)
 {
     if (layer != null)
     {
         TreeNode node = new TreeNode();
         node.Tag = layer;
         node.Text = layer.Caption;
         node.ImageIndex = 0;
         node.SelectedImageIndex = 0;
         node.Checked = layer.Visible;
         layerManagerNode.Nodes.Insert(0, node);
         VisitFeature3Ds(layer.GetAllFeatures(), node);
     }
 }
Ejemplo n.º 14
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            string fieldName = textBoxFieldName.Text.Trim();

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

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

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

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

            if (layer != null && layer.GetAllFeatures().Length > 0)
            {
                //GSOFieldDefn field = new GSOFieldDefn();
                //field.Name = fieldName;
                //field.Type = fieldType;
                //field.Width = fieldWidth;
                //for (int i = 0; i < layer.GetAllFeatures().Length; i++)
                //{
                //    GSOFeature feature = layer.GetAt(i);
                //    feature.AddField(field);
                //}
                //dataGridView1.Columns.Add(fieldName, fieldName);

                GSOFieldAttr field = new GSOFieldAttr();
                field.Name  = fieldName;
                field.Type  = fieldType;
                field.Width = fieldWidth;
                GSOFeatureDataset dataset = layer.Dataset as GSOFeatureDataset;
                if (dataset != null)
                {
                    dataset.AddField(field);
                    dataGridView1.Columns.Add(fieldName, fieldName);
                }
            }
            this.Close();
        }
        //开始查询
        private void btn_Apply_Click(object sender, EventArgs e)
        {
            string caption = cbox_Layers.Text;

            if (caption == "")
            {
                MessageBox.Show("请先添加图层", "提示");
                return;
            }
            GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(caption);

            if (layer == null)
            {
                return;
            }

            if (!checkBox1.Checked)
            {
                GSOFeatures features = layer.GetAllFeatures();
                for (int i = 0; i < features.Length; i++)
                {
                    GSOFeature newfeature = features[i];

                    GSOGeoPolyline3D line = newfeature.Geometry as GSOGeoPolyline3D;
                    if (line == null)
                    {
                        continue;
                    }
                    GSOPipeLineStyle3D pipeLineStyle = line.Style as GSOPipeLineStyle3D;


                    // 管线暂不支持依地模式

                    if (pipeLineStyle == null)
                    {
                        pipeLineStyle = new GSOPipeLineStyle3D();
                    }

                    pipeLineStyle.LineColor = buttonPipelineColor.BackColor;
                    line.Style = pipeLineStyle;
                }
            }
            else
            {
                string sql = "select * from " + cbox_Layers.Text.Trim();
                if (textBox_WhereClause.Text != "")
                {
                    sql += " where " + textBox_WhereClause.Text;
                    try
                    {
                        if (layer.Dataset == null || layer.Dataset.DataSource == null ||
                            (layer.Dataset.DataSource.Type != EnumDataSourceType.SqlServer && layer.Dataset.DataSource.Type != EnumDataSourceType.Oracle))
                        {
                            return;
                        }
                        DatabaseConnectParams connectParams = Utility.getConnectParamsByDatasourceName(globeControl1, layer.Dataset.DataSource.Name);
                        if (connectParams == null)
                        {
                            return;
                        }
                        DataTable table = OledbHelper.QueryTable(sql, connectParams);
                        if (table == null)
                        {
                            return;
                        }

                        for (int i = 0; i < table.Rows.Count; i++)
                        {
                            int        id         = Convert.ToInt32(table.Rows[i]["LSSYS_ID"]);
                            GSOFeature newfeature = layer.GetFeatureByID(id);

                            GSOGeoPolyline3D line = newfeature.Geometry as GSOGeoPolyline3D;
                            if (line == null)
                            {
                                continue;
                            }
                            GSOPipeLineStyle3D pipeLineStyle = line.Style as GSOPipeLineStyle3D;

                            // 管线暂不支持依地模式
                            if (pipeLineStyle == null)
                            {
                                pipeLineStyle = new GSOPipeLineStyle3D();
                            }
                            pipeLineStyle.LineColor = buttonPipelineColor.BackColor;
                            line.Style = pipeLineStyle;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.PublishTxt(ex);
                        MessageBox.Show(ex.Message, "提示");
                        return;
                    }
                }
            }

            globeControl1.Refresh();
            return;
        }