コード例 #1
0
        /// <summary>
        /// 添加地标
        /// </summary>
        private bool AddMarker(string name, double lon, double lat, string path, string description, GSOLayer layer)
        {
            try
            {
                GSOFeature       newFeature = new GSOFeature();
                GSOGeoMarker     p          = new GSOGeoMarker();
                GSOMarkerStyle3D style      = new GSOMarkerStyle3D();

                style.IconPath         = path;
                p.Style                = style;
                p.X                    = lon;
                p.Y                    = lat;
                p.Text                 = name.Substring(0, name.Length - 4);
                p.AltitudeMode         = EnumAltitudeMode.ClampToGround;
                newFeature.Geometry    = p;
                newFeature.Name        = name;
                newFeature.Description = description + " ";
                layer.AddFeature(newFeature);
                return(true);
            }
            catch (Exception e)
            {
                e.GetType();
                return(false);
            }
        }
コード例 #2
0
        private void buttonOk_Click(object sender, EventArgs e)//确定
        {
            if (comboBox1.Text.Trim() == "")
            {
                MessageBox.Show("图层不能为空");
                return;
            }
            if (txtPath.Text.Trim() == "")
            {
                MessageBox.Show("模型路径不能为空");
                return;
            }

            if (textBoxLayerPath.Text.Trim() == "")
            {
                MessageBox.Show("图层保存路径不能为空");
                return;
            }

            GSOLayer newlayer = globeControl1.Globe.Layers.Add(textBoxLayerPath.Text.Trim());

            newlayer.Caption = Path.GetFileNameWithoutExtension(txtPath.Text.Trim());
            GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBox1.Text.Trim());

            if (layer != null)
            {
                GSOFeatures features = layer.GetAllFeatures();
                if (features.Length > 0)
                {
                    for (int i = 0; i < features.Length; i++)
                    {
                        if (features[i] != null && features[i].Geometry != null)
                        {
                            if (features[i].Geometry.Type == EnumGeometryType.GeoPoint3D)
                            {
                                GSOFeature    feature = new GSOFeature();
                                GSOGeoPoint3D point3d = features[i].Geometry as GSOGeoPoint3D;
                                if (point3d != null)
                                {
                                    GSOGeoModel model = new GSOGeoModel();
                                    model.FilePath   = txtPath.Text.Trim();
                                    model.Position   = point3d.Position;
                                    feature.Geometry = model;
                                    newlayer.AddFeature(feature);
                                }
                            }
                        }
                    }
                    globeControl1.Globe.Refresh();
                }
            }

            this.Close();
        }
コード例 #3
0
 /// <summary>
 /// 文字图层
 /// </summary>
 /// <param name="text">显示的文字</param>
 private void TextTitle(string text)
 {
     if (layerScreenText != null)
     {
         //清除其中所有要素
         layerScreenText.RemoveAllFeature();
         GSOGeoScreenText overlayTextTitle = new GSOGeoScreenText(); //创建屏幕文字
         GSOTextStyle     textStyle        = new GSOTextStyle();     //设置属性
         textStyle.ForeColor        = Color.White;
         textStyle.FontSize         = 36;
         overlayTextTitle.TextStyle = textStyle;
         overlayTextTitle.Align     = EnumAlign.TopLeft;        //设置文字对齐方式
         overlayTextTitle.PosAlign  = EnumAlign.BottomRight;    //设置文字位置
         overlayTextTitle.Name      = "ScreenTextTitle";
         overlayTextTitle.SetOffset(180, 60);                   //设置文字偏移量
         overlayTextTitle.Text = text;                          //设置文字
         GSOFeature feature_ScreenTextTitle = new GSOFeature(); //创建要素
         feature_ScreenTextTitle.Geometry = overlayTextTitle;   //赋予要素
         layerScreenText.AddFeature(feature_ScreenTextTitle);
         layerScreenText.Save();
     }
 }
コード例 #4
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (feature != null)
     {
         GSOPoint3d pt = new GSOPoint3d();
         pt.X = point.X;
         pt.Y = point.Y;
         pt.Z = point.Z;
         GSOGeoModel model = new GSOGeoModel();
         model.FilePath     = modelPath;
         model.Position     = pt;
         model.AltitudeMode = EnumAltitudeMode.Absolute;
         feature            = new GSOFeature();
         feature.Geometry   = model;
         layer.AddFeature(feature);
         globeControl1.Refresh();
     }
     this.Close();
 }
コード例 #5
0
 GSOLayer AddFeatureAndFeatureFolder(GSOFeature feature,GSOLayer newlayer)
 {
     if (feature != null && newlayer != null)
     {
         if (feature.Type == EnumFeatureType.Feature)
         {
             newlayer.AddFeature(feature);
         }
         else
         {
             GSOFeatureFolder folder = (GSOFeatureFolder)feature;
             for (int i = 0; i < folder.Features.Length; i++)
             {
                 newlayer = AddFeatureAndFeatureFolder(folder.Features[i], newlayer);
             }
         }
     }
     return newlayer;
 }
コード例 #6
0
 GSOLayer AddFeatureAndFeatureFolder(GSOFeature feature, GSOLayer newlayer)
 {
     if (feature != null && newlayer != null)
     {
         if (feature.Type == EnumFeatureType.Feature)
         {
             newlayer.AddFeature(feature);
         }
         else
         {
             GSOFeatureFolder folder = (GSOFeatureFolder)feature;
             for (int i = 0; i < folder.Features.Length; i++)
             {
                 newlayer = AddFeatureAndFeatureFolder(folder.Features[i], newlayer);
             }
         }
     }
     return(newlayer);
 }
コード例 #7
0
        private void one2Multi(GSOGeoPolyline3D line, int num_width, int num_height, double interval, GSOPipeLineStyle3D style, GSOLayer layer, string name)
        {
            line = LatLon2Coord_Line(line);

            double width_all  = interval * (num_width - 1);
            double height_all = interval * (num_height - 1);

            line.Clone();
            GSOGeoPolyline3D line_1 = line.Clone() as GSOGeoPolyline3D;

            GSOPoint3d p1 = line[0][0];
            GSOPoint3d p2 = line[0][1];

            double daltaX = p2.X - p1.X;
            double daltaY = p2.Y - p1.Y;

            double agree = Math.Atan(daltaY / daltaX);

            line.MoveXY((-0.5 * width_all - interval) * Math.Sin(agree), (0.5 * width_all + interval) * Math.Cos(agree));

            line.MoveZ(height_all / -2);

            for (int i = 0; i < num_width; i++)
            {
                for (int j = 0; j < num_height; j++)
                {
                    GSOGeoPolyline3D templine = line.Clone() as GSOGeoPolyline3D;

                    templine.MoveXY((i + 1) * interval * Math.Sin(agree), -1 * (i + 1) * interval * Math.Cos(agree));

                    templine = Coord2LatLon_Line(templine);

                    templine.MoveZ(interval * j);

                    GSOFeature feat = new GSOFeature();
                    feat.Geometry       = templine;
                    feat.Geometry.Style = style;
                    feat.Name           = name;
                    layer.AddFeature(feat);
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// 向图层数据中添加要素Feature
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_EditFeature_Click(object sender, EventArgs e)
        {
            //新建要素
            GSOGeoPolygon3D polygon = new GSOGeoPolygon3D();
            GSOPoint3ds     points  = new GSOPoint3ds();

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

            GSOFeature feature = new GSOFeature();

            feature.Geometry = polygon;

            _featureLayer.AddFeature(feature);

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

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

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

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

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

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

                        GSOFeature newFeature = new GSOFeature();

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

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

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

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

                        f.Geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround;

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

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

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

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

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

                    pipeModelLayer.Save();
                    layer_Rect.Save();
                    string strMessage = "shp文件中共" + features.Length + "个对象,实际生成" + (pipeModelLayer.GetAllFeatures().Length + layer_Rect.GetAllFeatures().Length) + "个对象!\n";
                    MessageBox.Show(strMessage + message, "提示");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                Log.PublishTxt(ex);
                MessageBox.Show(ex.Message);
            }
        }
コード例 #10
0
        private void btnCreateModel_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtModelLayer.Text))
                {
                    MessageBox.Show("管沟模型文件路径无效!", "提示");
                    return;
                }
                if (File.Exists(txtModelLayer.Text))
                {
                    MessageBox.Show("管沟模型文件已存在!", "提示");
                    return;
                }

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

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

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

                        GSOFeature newFeature = new GSOFeature();

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

                        double radius  = f.GetFieldAsDouble(cmbRadius.SelectedIndex) / 1000; // 单位
                        string eventid = f.GetFieldAsString(cmbID.SelectedItem.ToString());

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


                        f.Geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround;

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



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

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

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

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

                layer.Save();

                ctl.Globe.Layers.Remove(layer);
                this.Close();
            }
            catch (Exception ex)
            {
                Log.PublishTxt(ex);
                MessageBox.Show(ex.Message);
            }
        }
コード例 #11
0
        private void btnCreateModel_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtModelLayer.Text))
                {
                    MessageBox.Show("管线模型文件路径无效!", "提示");
                    return;
                }
                if (File.Exists(txtModelLayer.Text))
                {
                    MessageBox.Show("管线模型文件已存在!", "提示");
                    return;
                }

                GSOLayer 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);
            }
        }
コード例 #12
0
        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();
        }
コード例 #13
0
ファイル: FrmShp2KML.cs プロジェクト: zhongketuxin/qkKL6Dgf12
        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);
            }
        }
コード例 #14
0
        private void button2_Click(object sender, EventArgs e)
        {
            double dMinLon = 0, dMaxLon = 0, dMinLat = 0, dMaxLat = 0;
            string strLayerPath = saveFileDialog1.FileName;
            string path         = Application.StartupPath + "\\Resource\\image\\DefaultIcon.png";

            if (string.IsNullOrEmpty(saveFileDialog1.FileName))
            {
                MessageBox.Show("请选择存储目录");
                return;
            }
            globeControl1.Globe.MemoryLayer.SaveAs(strLayerPath);
            layerTemp = globeControl1.Globe.Layers.Add(strLayerPath);
            layerTemp.RemoveAllFeature();
            GSOGeoPolyline3D polyLine = new GSOGeoPolyline3D();
            GSOPoint3ds      pois     = new GSOPoint3ds();

            for (int i = 0; i < listView1.Items.Count; i++)
            {
                ListViewItem item = listView1.Items[i];
                double       lon, lat;
                if (!double.TryParse(item.SubItems[3].Text.ToString() == "" ? "0" : item.SubItems[3].Text.ToString(), out lon))
                {
                    MessageBox.Show("经度参数不合法");
                    return;
                }
                if (!double.TryParse(item.SubItems[4].Text.ToString() == "" ? "0" : item.SubItems[4].Text.ToString(), out lat))
                {
                    MessageBox.Show("纬度参数不合法");
                    return;
                }
                if (i == 0)
                {
                    dMaxLon = lon;
                    dMinLon = lon;
                    dMinLat = lat;
                    dMaxLat = lat;
                }
                GSOPoint3d node = new GSOPoint3d(lon, lat, 0);
                pois.Add(node);
                string strDescriptionPrefix = "<![CDATA[<!-- <BALLOON><CONTENT_CX>800</CONTENT_CX><CONTENT_CY>600</CONTENT_CY>"
                                              + "<CONTENT_TYPE>link</CONTENT_TYPE><SHOW_MODE>balloonex</SHOW_MODE>-->";

                string strDescription = strDescriptionPrefix + "file:\\\\" + Application.StartupPath + "\\Resource\\Page\\pic_route.html";
                strDescription += "?URL=" + item.SubItems[5].Text.ToString();
                //strDescription += "]]>";
                AddMarker(item.SubItems[1].Text.ToString(), lon, lat, path, strDescription, layerTemp);

                if (lon < dMinLon)
                {
                    dMinLon = lon;
                }
                else if (lon > dMaxLon)
                {
                    dMaxLon = lon;
                }
                if (lat < dMinLat)
                {
                    dMinLat = lat;
                }
                else if (lat > dMaxLat)
                {
                    dMaxLat = lat;
                }
            }
            if (layerTemp == null)
            {
                MessageBox.Show("没有生成轨迹的数据");
                return;
            }
            polyLine.AddPart(pois);
            GSOFeature feature = new GSOFeature();

            feature.Geometry = polyLine;
            layerTemp.AddFeature(feature);//添加线
            layerTemp.SaveAs(strLayerPath);
            globeControl1.Globe.FlyToFeature(feature);
        }
コード例 #15
0
        private void btnCreateModel_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtModelLayer.Text))
                {
                    MessageBox.Show("kml文件路径无效!", "提示");
                    return;
                }
                if (File.Exists(txtModelLayer.Text))
                {
                    MessageBox.Show("kml文件已存在!", "提示");
                    return;
                }

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

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

                        GSOFeature newFeature = new GSOFeature();

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

                        double       radius = 0;
                        GSOFieldDefn field  = (GSOFieldDefn)(f.GetFieldDefn(cmbRadius.SelectedItem.ToString()));
                        if (field.Type == EnumFieldType.Text)
                        {
                            string temp   = f.GetFieldAsString(cmbRadius.SelectedItem.ToString());
                            double outNum = 0;
                            bool   num    = double.TryParse(temp, out outNum);
                            if (num)
                            {
                                radius = outNum / 2000;
                            }
                        }
                        else if (field.Type == EnumFieldType.Double)
                        {
                            radius = f.GetFieldAsDouble(cmbRadius.SelectedItem.ToString()) / 2000;  // 探测数据的单位一般是毫米,需换算为米; 管径一般是 直径, 这个需要半径, 所有除以2000
                        }
                        string eventid = f.GetFieldAsString(cmbID.SelectedItem.ToString());

                        if (radius == 0)
                        {
                            message += "ID为" + f.ID + "的管线的半径为0  \n  ";
                            continue;
                        }
                        style.Radius           = radius;
                        style.Slice            = int.Parse(txtSlice.Text);
                        style.CornerSliceAngle = Convert.ToDouble(textBoxCornerSliceAngle.Text);

                        f.Geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround;

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

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

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

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

                        newFeature.Geometry       = line; // f.Geometry;
                        newFeature.Geometry.Style = style;
                        newFeature.Name           = eventid;
                        layer.AddFeature(newFeature);
                    }
                    ctl.Refresh();
                    layer.Save();
                    ctl.Globe.Layers.Remove(layer);
                    string strMessage = "shp文件中共" + features.Length + "个对象,实际生成" + layer.GetAllFeatures().Length + "个对象!\n";
                    MessageBox.Show(strMessage + message, "提示");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                Log.PublishTxt(ex);
                MessageBox.Show(ex.Message);
            }
        }
コード例 #16
0
        private void one2Multi(GSOGeoPolyline3D line, int num_width, int num_height, double interval, GSOPipeLineStyle3D style, GSOLayer layer,string name)
        {
            line = LatLon2Coord_Line(line);

            double width_all = interval * (num_width-1);
            double height_all = interval * (num_height-1);

            line.Clone();
            GSOGeoPolyline3D line_1 = line.Clone() as GSOGeoPolyline3D;

            GSOPoint3d p1 = line[0][0];
            GSOPoint3d p2 = line[0][1];

            double daltaX = p2.X-p1.X;
            double daltaY = p2.Y-p1.Y;

            double agree = Math.Atan(daltaY/daltaX);

            line.MoveXY((-0.5*width_all-interval)*Math.Sin(agree),(0.5*width_all+interval)*Math.Cos(agree));

            line.MoveZ(height_all / -2);

            for (int i = 0; i < num_width; i++)
            {
                for (int j = 0; j < num_height; j++)
                {
                    GSOGeoPolyline3D templine = line.Clone() as GSOGeoPolyline3D;

                    templine.MoveXY((i + 1) * interval * Math.Sin(agree), -1 * (i + 1) * interval * Math.Cos(agree));

                    templine = Coord2LatLon_Line(templine);

                    templine.MoveZ(interval*j);

                    GSOFeature feat = new GSOFeature();
                    feat.Geometry = templine;
                    feat.Geometry.Style = style;
                    feat.Name = name;
                    layer.AddFeature(feat);
                }
            }
        }
コード例 #17
0
ファイル: MainFrm.cs プロジェクト: StarU/qkKL6Dgf12
        private void 管线间距分析ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (globeControl1.Globe.SelObjectCount < 2)
            {
                MessageBox.Show("请选中至少两个管线!!");
                return;
            }
            if (disFeature.ID != 0)
            {
                globeControl1.Globe.MemoryLayer.RemoveFeatureByID(disFeature.ID);
            }
            if (featureDis.ID != 0)
            {
                globeControl1.Globe.MemoryLayer.RemoveFeatureByID(featureDis.ID);
            }
            GSOLayer reslayer;
            globeControl1.Globe.GetSelectObject(0, out m_DisAnalysisFirstFeature, out reslayer);
            globeControl1.Globe.GetSelectObject(1, out m_DisAnalysisSecondFeature, out reslayer);
            if (m_DisAnalysisSecondFeature != null && m_DisAnalysisSecondFeature != null)
            {
                GSOGeoPolyline3D line1 = m_DisAnalysisFirstFeature.Geometry as GSOGeoPolyline3D;
                GSOGeoPolyline3D line2 = m_DisAnalysisSecondFeature.Geometry as GSOGeoPolyline3D;
                if (line1 == null || line2 == null)
                {
                    MessageBox.Show("请选择管线!!");
                    return;
                }
                GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D;
                GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D;
                if (pipeStyle1 == null || pipeStyle2 == null)
                {
                    MessageBox.Show("请选择管线!!");
                    return;
                }

                GSOPoint3d pntIntersect1;
                GSOPoint3d pntIntersect2;
                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)
                    {
                        MessageBox.Show("管线在同一水平面,距离为0");
                        return;
                    }
                    else
                    {
                        dDist = dDist - pipeStyle1.Radius - pipeStyle2.Radius;
                        GSOGeoPolyline3D disline = new GSOGeoPolyline3D();
                        GSOPoint3ds point3ds = new GSOPoint3ds();
                        point3ds.Add(pntIntersect1);
                        point3ds.Add(pntIntersect2);
                        disline.AddPart(point3ds);

                        GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格
                        //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255
                        style.LineColor = Color.GreenYellow;
                        style.LineWidth = 3;          //设置线的宽度为3
                        style.VertexVisible = true; 	//显示线的节点
                        disline.Style = style;          //把风格添加到线上
                        disline.AltitudeMode = EnumAltitudeMode.Absolute;

                        disFeature.Geometry = disline;

                        GSOGeoMarker markerDis = new GSOGeoMarker();
                        markerDis.X = pntIntersect1.X;
                        markerDis.Y = pntIntersect1.Y;
                        markerDis.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2;
                        markerDis.Text = dDist.ToString().Substring(0, dDist.ToString().IndexOf(".") + 3) + "米";
                        markerDis.AltitudeMode = EnumAltitudeMode.Absolute;
                        GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D();
                        GSOTextStyle styleText = new GSOTextStyle();
                        styleText.IsSizeFixed = true;
                        styleText.ForeColor = Color.White;
                        styleText.FontSize = 20;
                        styleMarker.TextStyle = styleText;
                        markerDis.Style = styleMarker;
                        featureDis.Geometry = markerDis;
                        layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd");
                        layerTemp.AddFeature(featureDis);
                        layerTemp.AddFeature(disFeature);
                        globeControl1.Refresh();
                    }
                }
                else
                {
                    MessageBox.Show("没有交点!!");
                    return;
                }
            }
        }