private void dataGridViewX1_MouseClick(object sender, MouseEventArgs e)
        {
            if (m_feature != null && m_feature.HighLight == true)
            {
                m_feature.HighLight = false;
            }
            m_feature = null;
            if (e.Button == MouseButtons.Right)
            {
                DataGridView.HitTestInfo hittestinfo = dataGridView1.HitTest(e.X, e.Y);
                if (hittestinfo.RowIndex > -1)
                {
                    if (dataGridView1.Columns.Contains("编号"))
                    {
                        string featureName = dataGridView1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim();
                        contextMenuStrip1.Show(dataGridView1, e.X, e.Y);

                        for (int j = 0; j < features.Length; j++)
                        {
                            if (features[j].Name == featureName)
                            {
                                m_feature = features[j];
                                break;
                            }
                        }
                    }
                }
            }
        }
Example #2
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);
            }
        }
Example #3
0
        private void button5_Click(object sender, EventArgs e)
        {
            GSOFeature myFeature = null;

            myFeature = globeControl1.Globe.SelectedObject;
            MessageBox.Show("获取到:" + (myFeature == null?"null":myFeature.Name));
        }
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            GSOFeatureLayer pFeatureLayer = geoLayer as GSOFeatureLayer;

            if (pFeatureLayer != null)
            {
                GSOFeature featureFlyTo = dataGridView1.Rows[e.RowIndex].Tag as GSOFeature;
                if (featureFlyTo == null || globeControl1 == null)
                {
                    return;
                }

                if (featureFlyTo.Geometry != null && featureFlyTo.Geometry.Type == EnumGeometryType.GeoPolyline3D)
                {
                    GSOGeoPolyline3D line     = featureFlyTo.Geometry as GSOGeoPolyline3D;
                    double           length   = line.GetSpaceLength(true, 6378137);
                    GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2);
                    GSOPoint3d       point3d  = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1];

                    globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5);
                }
                else
                {
                    globeControl1.Globe.FlyToFeature(featureFlyTo, 0, 45, 3);
                }
                globeControl1.Globe.Refresh();
            }
        }
Example #5
0
        private bool updateFeatures()
        {
            if (layer == null)
            {
                MessageBox.Show("请选择一个图层!");
                return(false);
            }
            if (comboBoxUpdateFieldName.Text == "")
            {
                MessageBox.Show("请选择一个字段!");
                return(false);
            }
            string fieldValue = textBoxFieldValue.Text;

            if (dataGridView1.Rows.Count <= 0)
            {
                MessageBox.Show("查询结果为空!");
                return(false);
            }
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                GSOFeature feat = dataGridView1.Rows[i].Tag as GSOFeature;
                if (feat != null)
                {
                    feat.SetFieldValue(comboBoxUpdateFieldName.Text, fieldValue);
                }
            }
            return(true);
        }
Example #6
0
 //public GSOGeometry m_feature.Geometry = null;
 public CtrlEntitySpaceInfo(GSOFeature feature, GSOGlobeControl globeControl)//(GSOGeometry geometry, GSOGlobeControl globeControl)
 {
     InitializeComponent();
     m_GlobeControl = globeControl;
     //m_feature.Geometry = geometry;
     m_feature = feature;
 }
Example #7
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtCurveFactor.Text != "" && txtRadius.Text != "" && textBoxPath.Text !="")
            {
                GSOGeoPolyline3D line = (GSOGeoPolyline3D)feature.Geometry;

                GSOGeoPowerLine geopowerline = new GSOGeoPowerLine();

                GSOPoint3d pnt = new GSOPoint3d();
                for (int i = 0; i < line[0].Count; i++)
                {
                    GSOGeoPowerLineNode node = new GSOGeoPowerLineNode();
                    pnt = line[0][i];

                    node.NodeTemplatePath = textBoxPath.Text;
                    node.SetPosition(pnt.X, pnt.Y, pnt.Z);
                    geopowerline.AddNode(node);

                }
                GSOFeature newFeature = new GSOFeature();

                geopowerline.LinkLineStyle = new GSOElecLineStyle3D();
                geopowerline.LinkLineStyle.LineColor = Color.FromArgb(255,pictureBoxFillColor.BackColor);
                geopowerline.LinkLineStyle.Radius = double.Parse(txtRadius.Text);
                geopowerline.LinkLineStyle.Slice = int.Parse(txtSlice.Text);
                geopowerline.LinkLineStyle.CurveFactor = double.Parse(txtCurveFactor.Text);
                newFeature.Geometry = geopowerline;
                ctl.Globe.MemoryLayer.AddFeature(newFeature);
                this.Close();
            }
        }
Example #8
0
        /// <summary>
        /// 模型替换
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_ReplaceModel_Click(object sender, EventArgs e)
        {
            if (_trackPressPolygon.Count < 1)
            {
                MessageBox.Show("请先绘制压平模型。");
                return;
            }
            foreach (var trackPolygon in _trackPressPolygon)
            {
                //创建模型
                GSOGeoModel model = new GSOGeoModel();
                //给定模型路径
                model.FilePath = _modelPath;
                //模型加载
                model.Load();
                //模型位置
                model.Position = trackPolygon.GeoCenterPoint;
                //将模型放置于模型表面
                model.AltitudeMode = EnumAltitudeMode.ClampToModel; //把几何体放到表面上
                GSOFeature f = new GSOFeature();                    //创建几何要素
                f.Geometry = model;
                f.Name     = "模型 01";

                //把几何要素添加到内存图层中
                GSOFeature newFeature = _glbControl.Globe.MemoryLayer.AddFeature(f);
                _glbControl.Refresh();    //刷新场景
            }
        }
Example #9
0
        private void AddModel()
        {
            GSOGeoModel model = new GSOGeoModel(); //创建模型
            GSOPoint3d  pt    = new GSOPoint3d();  //创建点

            pt.X = 116.6;
            pt.Y = 39.9;
            pt.Z = 0;


            //模型可以是3ds、obj、gse、gsez格式的三维模型
            //模型所在路径,用户可根据实际情况进行设置
            string filepath = Application.StartupPath + "\\Model\\坦克.3ds";

            //设置模型
            model.FilePath = filepath;
            model.Position = pt;

            model.AltitudeMode = EnumAltitudeMode.ClampToGround; //把几何体放到地面上

            GSOFeature feaf = new GSOFeature();                  //创建几何要素

            feaf.Geometry    = model;
            feaf.Name        = "模型 01";
            feaf.Description = "模型 01";  //设置feature description的值,这个值将在tooltip上显示

            //把几何要素添加到内存图层中
            globeControl1.Globe.MemoryLayer.AddFeature(feaf);
        }
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            GSOFeatureLayer pFeatureLayer = geoLayer as GSOFeatureLayer;

            if (pFeatureLayer != null)
            {
                string featureName = dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString();
                if (featureName == "")
                {
                    return;
                }
                GSOFeatures features = pFeatureLayer.GetFeatureByName(featureName, false);
                GSOFeature  feature  = new GSOFeature();
                for (int j = 0; j < features.Length; j++)
                {
                    if (features[j].Name == featureName)
                    {
                        feature = features[j];
                        if (globeControl1 != null)
                        {
                            globeControl1.Globe.FlyToFeature(feature);
                            globeControl1.Globe.Refresh();
                        }
                    }
                }
            }
        }
        private void dataGridView1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                DataGridView.HitTestInfo hittestinfo = dataGridView1.HitTest(e.X, e.Y);
                if (hittestinfo.RowIndex > -1)
                {
                    string featureName = dataGridView1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString();
                    contextMenuStrip1.Show(dataGridView1, e.X, e.Y);
                    featureName = featureName.Trim();


                    if (geoLayer == null)
                    {
                        return;
                    }
                    GSOFeatures features = geoLayer.GetFeatureByName(featureName, false);

                    for (int j = 0; j < features.Length; j++)
                    {
                        if (features[j].Name == featureName)
                        {
                            m_feature = features[j];
                            if (m_feature != null && m_feature.HighLight == true)
                            {
                                m_feature.HighLight = false;
                                globeControl1.Globe.Refresh();
                            }
                            break;
                        }
                    }
                }
            }
        }
Example #12
0
 public CtrlPolygonStylePage(GSOFeature feature, GSOGlobeControl globeControl)
 {
     InitializeComponent();
     m_GlobeControl = globeControl;
     m_Geometry     = feature.Geometry;
     mfeature       = feature;
 }
 public FrmAtrributeMapping1(GSOGlobeControl globeControl, GSOLayer layer, GSOFeature feature)
 {
     InitializeComponent();
     m_globeControl = globeControl;
     m_feature      = feature;
     m_layer        = layer;
 }
Example #14
0
 public FrmAtrributeMapping1(GSOGlobeControl globeControl,GSOLayer layer,GSOFeature feature)
 {
     InitializeComponent();
     m_globeControl = globeControl;
     m_feature = feature;
     m_layer = layer;
 }
Example #15
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtCurveFactor.Text != "" && txtRadius.Text != "" && textBoxPath.Text != "")
            {
                GSOGeoPolyline3D line = (GSOGeoPolyline3D)feature.Geometry;

                GSOGeoPowerLine geopowerline = new GSOGeoPowerLine();

                GSOPoint3d pnt = new GSOPoint3d();
                for (int i = 0; i < line[0].Count; i++)
                {
                    GSOGeoPowerLineNode node = new GSOGeoPowerLineNode();
                    pnt = line[0][i];

                    node.NodeTemplatePath = textBoxPath.Text;
                    node.SetPosition(pnt.X, pnt.Y, pnt.Z);
                    geopowerline.AddNode(node);
                }
                GSOFeature newFeature = new GSOFeature();

                geopowerline.LinkLineStyle             = new GSOElecLineStyle3D();
                geopowerline.LinkLineStyle.LineColor   = Color.FromArgb(255, pictureBoxFillColor.BackColor);
                geopowerline.LinkLineStyle.Radius      = double.Parse(txtRadius.Text);
                geopowerline.LinkLineStyle.Slice       = int.Parse(txtSlice.Text);
                geopowerline.LinkLineStyle.CurveFactor = double.Parse(txtCurveFactor.Text);
                newFeature.Geometry = geopowerline;
                ctl.Globe.MemoryLayer.AddFeature(newFeature);
                this.Close();
            }
        }
Example #16
0
        /// <summary>
        /// 创建点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddPoint_Click(object sender, EventArgs e)
        {
            GSOGeoMarker point = new GSOGeoMarker();                                          //创建点对象

            point.X            = 120.417888231016;                                            //设置点X的值,单位为度
            point.Y            = 31.3283140323302;                                            //设置点Y的值,单位为度
            point.Z            = 20;                                                          //设置点Z的值,单位为米
            point.AltitudeMode = EnumAltitudeMode.RelativeToGround;                           //设置点的高程模式,设置为相对地面。则点的为(X,Y)处地面高程上方100米(point.Z = 100)
            point.Text         = "中科图新";                                                      //设置点对象显示的文字
            GSOMarkerStyle3D mstyle = new GSOMarkerStyle3D();                                 //新建点样式

            mstyle.IconPath = Application.StartupPath + "\\Resource\\image\\DefaultIcon.png"; //设置图标路径
            point.Style     = mstyle;                                                         //把显示风格
            GSOFeature feature = new GSOFeature();                                            //创建几何要素

            feature.Geometry = point;                                                         //把点赋予集合要素
            feature.Name     = point.Text;                                                    //赋予名字
            globeControl1.Globe.MemoryLayer.AddFeature(feature);                              //将要素添加到图层中

            //下面不属于工程内容,只是飞到点的位置
            GSOCameraState cs = new GSOCameraState();

            cs.Longitude = point.X;
            cs.Latitude  = point.Y;
            cs.Altitude  = 1000;
            globeControl1.Globe.FlyToCameraState(cs);
        }
        private void dataGridViewX1_MouseClick(object sender, MouseEventArgs e)
        {
            if (m_feature != null && m_feature.HighLight == true)
            {
                m_feature.HighLight = false;
            }
            m_feature = null;
            if (e.Button == MouseButtons.Right)
            {
                DataGridView.HitTestInfo hittestinfo = dataGridView1.HitTest(e.X, e.Y);
                if (hittestinfo.RowIndex > -1)
                {
                    if (dataGridView1.Columns.Contains("编号"))
                    {
                        string featureName = dataGridView1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim();
                        contextMenuStrip1.Show(dataGridView1, e.X, e.Y);

                        for (int j = 0; j < features.Length; j++)
                        {
                            if (features[j].Name == featureName)
                            {
                                m_feature = features[j];
                                break;
                            }
                        }
                    }
                }
            }
        }
Example #18
0
        /// <summary>
        /// 递归升高/降低给定高度值
        /// </summary>
        /// <param name="folder">要素集</param>
        /// <param name="height">高度/米</param>
        private void MoveEachFeature(GSOFeatureFolder folder, double height)
        {
            GSOFeatures features = folder.Features;

            for (int i = 0; i < features.Length; i++)
            {
                GSOFeature feature = features[i];
                if (feature is GSOFeatureFolder)
                {
                    MoveEachFeature(feature as GSOFeatureFolder, height);
                }
                else
                {
                    GSOGeometry geometry = feature.Geometry;
                    if (geometry != null)
                    {
                        //为了显示升降效果,需要将ClampToGround模式修改为RelativeToGround模式
                        if (geometry.AltitudeMode == EnumAltitudeMode.ClampToGround)
                        {
                            geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround;
                        }
                        //将z轴移动height米
                        geometry.MoveZ(height);
                    }
                }
            }
        }
Example #19
0
        /// <summary>
        /// 创建模型
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddModel_Click(object sender, EventArgs e)
        {
            GSOGeoModel model = new GSOGeoModel(); //创建模型
            GSOPoint3d  pt    = new GSOPoint3d();  //创建点

            pt.X = 116.6;
            pt.Y = 39.9;
            pt.Z = 0;

            GSOModelPointStyle3D style = new GSOModelPointStyle3D();  //创建模型的风格

            model.Style = style;

            //模型可以是3ds、obj、gse、gsez格式的三维模型
            //模型所在路径,用户可根据实际情况进行设置
            string filepath = Application.StartupPath + "\\Model\\坦克.3ds";

            //设置模型
            model.FilePath = filepath;
            model.Position = pt;

            model.AltitudeMode = EnumAltitudeMode.ClampToGround; //把几何体放到地面上

            GSOFeature f = new GSOFeature();                     //创建几何要素

            f.Geometry    = model;
            f.Name        = "模型 01";
            f.Description = "模型 01";  //设置feature description的值,这个值将在tooltip上显示

            //把几何要素添加到内存图层中
            globeControl1.Globe.MemoryLayer.AddFeature(f);

            //飞行到模型所在的位置
            globeControl1.Globe.FlyToFeature(f);
        }
        private void MoveEachFeature(GSOFeatureFolder folder, double height)
        {
            GSOFeatures features = folder.Features;

            for (int i = 0; i < features.Length; i++)
            {
                GSOFeature feature = features[i];
                if (feature is GSOFeatureFolder)
                {
                    MoveEachFeature(feature as GSOFeatureFolder, height);
                }
                else
                {
                    GSOGeoModel model = feature.Geometry as GSOGeoModel;
                    if (model != null)
                    {
                        GSOPoint3d pt = model.Position;
                        if (model.AltitudeMode == EnumAltitudeMode.ClampToGround)
                        {
                            model.AltitudeMode = EnumAltitudeMode.RelativeToGround;
                        }
                        pt.Z          += height;
                        model.Position = pt;
                    }
                }
            }
        }
Example #21
0
        private void txtNewChange()
        {
            decimal x;
            decimal y;

            if (txtNewLon.Text.Trim() == "")
            {
                txtNewLon.Text = 0 + "";
            }
            bool bl = decimal.TryParse(txtNewLon.Text.Trim(), out x);

            if (!bl)
            {
                MessageBox.Show("数据不符合要求!");
                return;
            }

            if (txtNewLat.Text.Trim() == "")
            {
                txtNewLat.Text = 0 + "";
            }
            bl = decimal.TryParse(txtNewLat.Text.Trim(), out y);
            if (!bl)
            {
                MessageBox.Show("数据不符合要求!");
                return;
            }

            GSOPoint3d point = ctl.Globe.ScreenToScene((int)Math.Round(x), (int)Math.Round(y));

            if (endFeat == null || endFeat.IsDeleted)
            {
                endFeat = new GSOFeature();
                GSOGeoMarker     p     = new GSOGeoMarker();
                GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png";
                p.Style        = style;
                p.AltitudeMode = EnumAltitudeMode.ClampToGround;

                endFeat.Name     = "目标点";
                endFeat.CustomID = 001;

                p.X = (double)Math.Round(x);
                p.Y = (double)Math.Round(y);
                p.Z = 0;
                endFeat.Geometry = p;
                endFeat          = ctl.Globe.MemoryLayer.AddFeature(endFeat);
            }
            else
            {
                GSOGeoPoint3D endpoint = endFeat.Geometry as GSOGeoPoint3D;
                if (endpoint != null)
                {
                    endpoint.X = (double)Math.Round(x);
                    endpoint.Y = (double)Math.Round(y);
                    endpoint.Z = 0;
                }
            }
            ctl.Refresh();
        }
        private void btn_Model_Click(object sender, EventArgs e)
        {
            GSOGeoModel model = new GSOGeoModel(); //创建模型
            GSOPoint3d  pt    = new GSOPoint3d();  //创建点

            pt.X = 120;
            pt.Y = 30;
            pt.Z = 0;

            GSOModelPointStyle3D style = new GSOModelPointStyle3D();  //创建模型的风格

            model.Style = style;

            //设置模型
            model.FilePath = _modelPath;
            model.Position = pt;

            model.AltitudeMode = EnumAltitudeMode.ClampToGround; //把几何体放到地面上

            GSOFeature f = new GSOFeature();                     //创建几何要素

            f.Geometry    = model;
            f.Name        = "模型 01";
            f.Description = "模型 01";  //设置feature description的值,这个值将在tooltip上显示

            //把几何要素添加到内存图层中
            GSOFeature newFeature = _glbControl.Globe.MemoryLayer.AddFeature(f);

            _glbControl.Globe.FlyToFeature(f); //飞行到模型所在的位置
            _glbControl.Refresh();             //刷新场景
        }
Example #23
0
 public CtrlPolygonStylePage(GSOFeature feature, GSOGlobeControl globeControl)
 {
     InitializeComponent();
      m_GlobeControl = globeControl;
      m_Geometry = feature.Geometry;
     mfeature = feature;
 }
 //删除
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         double min = double.Parse(textBox1.Text);
         double max = double.Parse(textBox2.Text);
         for (int i = 0; i < treeView1.Nodes.Count; i++)
         {
             if (treeView1.Nodes[i].Checked)
             {
                 GSOLayer    layer = treeView1.Nodes[i].Tag as GSOLayer;
                 GSOFeatures fs    = layer.GetAllFeatures();
                 for (int j = fs.Length - 1; j >= 0; j--)
                 {
                     GSOFeature f = fs[j];
                     double     z = f.Geometry.GeoCenterPoint.Z;
                     if (z >= min && z <= max)
                     {
                         layer.RemoveAt(j);
                     }
                 }
             }
         }
     }
     catch (Exception exp)
     {
         exp.GetType();
     }
 }
Example #25
0
        private void flyToFeature(GSOFeature feature)
        {
            if (null == _glbControl ||
                null == feature ||
                null == feature.Geometry ||
                null == feature.Geometry.Bounds)
            {
                return;
            }

            var bounds = feature.Geometry.Bounds;

            if (bounds.Center == null ||
                bounds.Width == 0.0 ||
                bounds.Height == 0.0)
            {
                _glbControl.Globe.FlyToFeature(feature);
                return;
            }
            //获取图层中心点
            GSOPoint3d pntPostion = new GSOPoint3d();

            pntPostion.X = bounds.Center.X;
            pntPostion.Y = bounds.Center.Y;
            //获取图层最大边
            double dMaxGeoLen = Math.Max(bounds.Width, bounds.Height);
            //判断视角高度
            double dSize = dMaxGeoLen * Math.PI * 6378137 / 90;

            pntPostion.Z = dSize > 20000000 ? dSize / 4 : dSize;
            _glbControl.Globe.FlyToPosition(pntPostion, EnumAltitudeMode.RelativeToGround);
        }
        private void lstValvesName_DoubleClick(object sender, EventArgs e)
        {
            int i = this.lstValvesName.SelectedIndex;

            if (i < 0)
            {
                return;
            }
            GSOFeature m_CloseValvesAnalyresFeature = m_CloseValvesAnalyResFeatures[i];

            globeControl1.Globe.FlyToFeature(m_CloseValvesAnalyresFeature, 1, 45, 5);
            GSOLabel newLabel = new GSOLabel();

            newLabel.Text               = "关闭此阀门";
            newLabel.Style              = new GSOLabelStyle();
            newLabel.Style.Opaque       = 0.8;
            newLabel.Style.OutlineColor = Color.Red;
            //newLabel.Style.TractionLineEndPos = new GSOPoint2d(150, 120);
            newLabel.Style.OutlineWidth       = 1;
            newLabel.Style.TracktionLineWidth = 1;
            newLabel.Style.BackBeginColor     = Color.Orange;
            newLabel.Style.BackEndColor       = Color.PaleGreen;

            m_CloseValvesAnalyresFeature.Label = newLabel;

            m_CloseValvesList.Add(m_CloseValvesAnalyresFeature);

            globeControl1.Refresh();
        }
Example #27
0
        private void buttonMerge_Click(object sender, EventArgs e)
        {
            GSOLayer layerlgd = mGlobeControl.Globe.Layers.Add(textBoxLgdPath.Text.Trim());
            GSOLayer layerkml = mGlobeControl.Globe.Layers.Add(textBoxKmlPath.Text.Trim());
            GSOLayer newlayer = mGlobeControl.Globe.Layers.Add(textBoxSavePath.Text.Trim());

            if (layerlgd.GetAllFeatures().Length > 0)
            {
                GSOFeatures features = layerlgd.GetAllFeatures();
                for (int i = 0; i < features.Length; i++)
                {
                    GSOFeature feature = features[i];
                    newlayer = AddFeatureAndFeatureFolder(feature, newlayer);
                }
            }
            if (layerkml.GetAllFeatures().Length > 0)
            {
                GSOFeatures features = layerkml.GetAllFeatures();
                for (int i = 0; i < features.Length; i++)
                {
                    GSOFeature feature = features[i];
                    newlayer = AddFeatureAndFeatureFolder(feature, newlayer);
                }
            }
            if (newlayer.GetAllFeatures().Length > 0)
            {
                newlayer.SaveAs(textBoxSavePath.Text.Trim());
                MessageBox.Show("合并成功", "提示");
            }
            else
            {
                MessageBox.Show("将要合并的图层不符合要求", "提示");
            }
            this.Close();
        }
Example #28
0
 //(GSOGeometry geometry, GSOGlobeControl globeControl)
 //public GSOGeometry m_feature.Geometry = null;
 public CtrlEntitySpaceInfo(GSOFeature feature, GSOGlobeControl globeControl)
 {
     InitializeComponent();
     m_GlobeControl = globeControl;
     //m_feature.Geometry = geometry;
     m_feature = feature;
 }
Example #29
0
        /// <summary>
        /// 获取图层中的所有feature对象,包括featureFolder下面的feature对象
        /// </summary>
        /// <param name="layer"></param>
        /// <returns></returns>
        public static GSOFeatures getRealFeaturesByLayer(GSOLayer layer)
        {
            GSOFeatures realFeatures = new GSOFeatures();

            if (layer != null)
            {
                for (int i = 0; i < layer.GetAllFeatures().Length; i++)
                {
                    GSOFeature feature = layer.GetAt(i);
                    if (feature != null)
                    {
                        if (feature.Type == EnumFeatureType.FeatureFolder)
                        {
                            GSOFeatureFolder featureFolder = feature as GSOFeatureFolder;
                            getRealFeatureByFeatures(featureFolder.Features, ref realFeatures);
                        }
                        else
                        {
                            realFeatures.Add(feature);
                        }
                    }
                }
            }
            return(realFeatures);
        }
Example #30
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);
                            }
                        }
                    }
                }
            }
        }
Example #31
0
        private void dataGridView1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                DataGridView.HitTestInfo hittestinfo = dataGridView1.HitTest(e.X, e.Y);
                if (hittestinfo.RowIndex > -1)
                {
                    contextMenuStrip1.Show(dataGridView1, e.X, e.Y);

                    if (layer == null)
                    {
                        return;
                    }

                    GSOFeatureLayer pFeatureLayer = layer as GSOFeatureLayer;
                    if (pFeatureLayer != null)
                    {
                        features = layer.GetFeatureByName(dataGridView1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(), true);
                        if (features != null)
                        {
                            for (int i = 0; i < features.Length; i++)
                            {
                                m_feature           = features[i];
                                m_feature.HighLight = false;
                            }
                            globeControl1.Globe.Refresh();
                        }
                    }
                }
            }
        }
Example #32
0
        private void Export(GSOPoint3d _pnt, double r)
        {
            GSOPoint3ds pnts = new GSOPoint3ds();
            GSOPoint3d  pnt  = new GSOPoint3d();

            pnt.X = _pnt.X;
            pnt.Y = _pnt.Y;
            pnt.Z = _pnt.Z;
            pnts.Add(pnt);
            pnt.X = _pnt.X;
            pnt.Y = _pnt.Y - 0.0000000005;
            pnt.Z = _pnt.Z;
            pnts.Add(pnt);
            GSOGeoPolyline3D line = new GSOGeoPolyline3D();

            line.AddPart(pnts);
            GSOGeoPolygon3D  polygon = line.CreateBuffer(r * 2, true, 5, true, false);
            GSOPoint3ds      points  = polygon[0];
            GSOGeoPolyline3D newLine = new GSOGeoPolyline3D();

            newLine.AddPart(points);
            newLine.AltitudeMode = EnumAltitudeMode.RelativeToGround;
            GSOFeature newFeature = new GSOFeature();

            newFeature.Geometry = newLine;
            globeControl1.Globe.MemoryLayer.AddFeature(newFeature);
            // globeControl1.Globe.FlyToFeature(f);
        }
Example #33
0
        private void MoveEachFeature(GSOFeatureFolder folder, double daltX, double daltY)
        {
            GSOFeatures features = folder.Features;

            for (int i = 0; i < features.Length; i++)
            {
                GSOFeature feature = features[i];
                if (feature is GSOFeatureFolder)
                {
                    MoveEachFeature(feature as GSOFeatureFolder, daltX, daltY);
                }
                else
                {
                    GSOGeometry g = feature.Geometry;
                    if (g != null)
                    {
                        g.MoveXY(daltX, daltY);
                    }

                    //GSOGeoModel model = feature.Geometry as GSOGeoModel;
                    //if (model!=null)
                    //{
                    //    GSOPoint3d pt = model.Position;
                    //    pt.X += daltX;
                    //    pt.Y += daltY;

                    //    model.Position = pt;
                    //}
                }
            }
        }
Example #34
0
        private void btnExportCAD_Click(object sender, EventArgs e)
        {
            globeControl1.Globe.MemoryLayer.RemoveAllFeature();
            int id = GeoScene.Data.GSOProjectManager.AddProject("+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=555484.8092 +y_0=-4114948.631 +ellps=krass +units=m +no_defs");

            for (int i = 0; i < listPoint.Count; i++)
            {
                GSOPoint3d geoPoint = (GSOPoint3d)listPoint[i];
                GSOFeature feature  = listFeat[i] as GSOFeature;
                if (feature != null)
                {
                    if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
                    {
                        GSOPipeLineStyle3D style = feature.Geometry.Style as GSOPipeLineStyle3D;
                        double             r     = style.Radius;
                        //ExportCAD(double.Parse(sortIndex[i, 0].ToString()), geoPoint.Z, r);
                        Export(geoPoint, r);
                    }
                }
            }
            GSOLayer layer = globeControl1.Globe.MemoryLayer;

            layer.Dataset.ImportProjectionRefFromProj4("+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=555484.8092 +y_0=-4114948.631 +ellps=krass +units=m +no_defs");
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter = "*.dxf|*.dxf";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                layer.SaveAs(dlg.FileName);
                globeControl1.Globe.MemoryLayer.RemoveAllFeature();
                MessageBox.Show("导出CAD完成!", "提示");
            }
        }
Example #35
0
        private void Apply()
        {
            label.Style = new GSOLabelStyle();

            label.Style.TextStyle.Italic = chkItalic.Checked;
            label.Style.Opaque           = trackBarOpaque.Value / 10.0;

            label.Style.TextStyle.FontHeight = (double)numFontsize.Value;

            label.Style.TractionLineEndPos = new GSOPoint2d((double)numOffsetX.Value, (double)numOffsetY.Value);

            label.Style.OutlineColor = labelBorderColor.BackColor;
            if (chkHasTrackLine.Checked)
            {
                label.Style.TractionLineColor = Color.FromArgb(255, labelBorderColor.BackColor);
            }
            else
            {
                label.Style.TractionLineColor = Color.FromArgb(0, labelBorderColor.BackColor);
            }

            label.Style.BackFillEffect     = EnumLabelBackEffect.EFFECT_VGRADIENT;
            label.Style.TracktionLineWidth = (double)numTrackWidth.Value;
            label.Style.OutlineWidth       = (double)numBorderWidth.Value;

            Color beginColor = Color.FromArgb(255, Color.Transparent);
            Color endColor   = Color.FromArgb(255, Color.Transparent);

            label.Style.BackBeginColor = labelFrom.BackColor;
            label.Style.BackEndColor   = labelTo.BackColor;

            label.Style.MaxVisibleDistance = (double)numMaxdistance.Value;
            label.Style.MinVisibleDistance = (double)numMinDistance.Value;


            switch (comboBox1.SelectedIndex)
            {
            case 0:
                label.Style.TracktionLineType = EnumTracktionLineType.Solid;
                break;

            default:
                label.Style.TracktionLineType = EnumTracktionLineType.Dot;
                break;
            }

            label.Text = txtInfo.Text;
            if (txtImagePath.Text != "")
            {
                label.BKImage = txtImagePath.Text;
            }


            GSOFeature feature = globeControl.Globe.SelectedObject as GSOFeature;  //new GSOFeature();

            feature.Label = label;
            //   globeControl.Globe.MemoryLayer.AddFeature(feature);
            globeControl.Refresh();
        }
        public CtrlLineFieldsValuePage(GSOFeature feature,GSOLayer layer, GSOGlobeControl globeControl)
        {
            InitializeComponent();
            mGlobeControl = globeControl;
            m_feature = feature;

            mlayer = layer;
        }
Example #37
0
        public CtrlPolylineSpaceInfo(GSOGeometry geometry,GSOFeature feature,GSOLayer layer,GSOGlobeControl globeControl)
        {
            InitializeComponent();
            m_GlobeControl = globeControl;
            m_Geometry = geometry;

            mlayer = layer;
            mfeature = feature;
        }
Example #38
0
        public static FrmFeatureInfo GetForm(GSOFeature feature, GSOLayer layer, GSOGlobeControl globeControl)
        {
            if (featureInfo == null)
            {
                featureInfo = new FrmFeatureInfo(feature, layer, globeControl);

            }
            return featureInfo;
        }
Example #39
0
        public FrmSetOutlineStyle(GSOLineStyle3D style, GSOGeoPolygon3D polygon, GSOFeature feature, GSOGlobeControl globeControl)
        {
            InitializeComponent();
            m_GlobeControl = globeControl;
            mfeature = feature;
            mpolygon = polygon;

            // 如果m_OldStyle不存在,先备份一个
            if (style != null)
            {
                m_OldStyle = (GSOLineStyle3D)style.Clone();
            }
            simpleLineStyle3D = (GSOSimpleLineStyle3D)style;
        }
Example #40
0
        public FrmSetLineStyle(GSOStyle style,GSOFeature feature,GSOLayer layer, GSOGlobeControl globeControl)
        {
            InitializeComponent();
            m_GlobeControl = globeControl;
            mlayer = layer;
            mfeature = feature;

            // 如果m_OldStyle不存在,先备份一个
            if (style != null)
            {
                m_OldStyle = style.Clone();
            }
            m_Style = style;
        }
        public CtrlPipelineStyleSetting(GSOStyle style, GSOFeature feature, GSOLayer layer, GSOGlobeControl globeControl)
        {
            InitializeComponent();
            m_GlobeControl = globeControl;
            mlayer = layer;
            mfeature = feature;
            altituMode = feature.Geometry.AltitudeMode;

            // 如果m_OldStyle不存在,先备份一个
            if (style != null)
            {
                m_OldStyle = style.Clone();
            }
            m_Style = style;
        }
Example #42
0
 public FrmFeatureInfo(GSOFeature feature, GSOLayer layer, GSOGlobeControl globeControl)
 {
     InitializeComponent();
     if (layer != null)
     {
         mlayer = layer;
     }
     m_Feature = feature;
     // 先备份一个
     if (feature != null)
     {
         m_OldFeture = feature.Clone();
     }
     m_GlobeControl = globeControl;
 }
Example #43
0
        public CtrlLineStylePage(GSOGeometry geometry,GSOFeature feature,GSOLayer layer, GSOGlobeControl globeControl)
        {
            InitializeComponent();

            m_GlobeControl = globeControl;
            m_Geometry = geometry;
            mlayer = layer;
            mfeature = feature;

            if (m_Geometry != null && m_Geometry.Style != null)
            {
                m_Style = (GSOLineStyle3D)m_Geometry.Style;

                m_OldStyle = (GSOLineStyle3D)m_Geometry.Style.Clone();
            }
        }
Example #44
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();
 }
 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;
 }
Example #46
0
        private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex < 0)
                return;

            GSOFeatureLayer pFeatureLayer = layer as GSOFeatureLayer;
            if (pFeatureLayer != null)
            {
                features = layer.GetFeatureByName(dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString(),true);
                if (features != null)
                {
                    for (int i = 0; i < features.Length; i++)
                    {
                        m_feature = features[i];
                        globeControl1.Globe.FlyToFeature(features[i]);
                    }
                    globeControl1.Globe.Refresh();
                }
            }
        }
 private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         DataGridView.HitTestInfo hittestinfo = dataGridView1.HitTest(e.X, e.Y);
         if (hittestinfo.RowIndex > -1)
         {
             if (dataGridView1.Columns.Contains("编号"))
             {
                 string featureName = dataGridView1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim();
                 for (int j = 0; j < features.Length; j++)
                 {
                     if (features[j].Name == featureName)
                     {
                         m_feature = features[j];
                         globe.FlyToFeature(m_feature, 0, 45, 3);
                     }
                 }
             }
         }
     }
 }
 public CtrlGeometryCameraState(GSOFeature feature, GSOGlobeControl globeControl)
 {
     InitializeComponent();
     m_GlobeControl = globeControl;
     m_feature = feature;
 }
        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);
            }
        }
        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);
            }
        }
Example #51
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();
        }
Example #52
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);
                }
            }
        }
Example #53
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);
            }
        }
 private void Export(GSOPoint3d _pnt, double r)
 {
     GSOPoint3ds pnts = new GSOPoint3ds();
     GSOPoint3d pnt = new GSOPoint3d();
     pnt.X = _pnt.X;
     pnt.Y = _pnt.Y;
     pnt.Z = _pnt.Z;
     pnts.Add(pnt);
     pnt.X = _pnt.X;
     pnt.Y = _pnt.Y - 0.0000000005;
     pnt.Z = _pnt.Z;
     pnts.Add(pnt);
     GSOGeoPolyline3D line = new GSOGeoPolyline3D();
     line.AddPart(pnts);
     GSOGeoPolygon3D polygon = line.CreateBuffer(r * 2, true, 5, true, false);
     GSOPoint3ds points = polygon[0];
     GSOGeoPolyline3D newLine = new GSOGeoPolyline3D();
     newLine.AddPart(points);
     newLine.AltitudeMode = EnumAltitudeMode.RelativeToGround;
     GSOFeature newFeature = new GSOFeature();
     newFeature.Geometry = newLine;
     globeControl1.Globe.MemoryLayer.AddFeature(newFeature);
        // globeControl1.Globe.FlyToFeature(f);
 }
Example #55
0
        private GSOFeature CreatePipeRect(GSOFeature shp_feat,GSOGeoPolyline3D line,double width,double height)
        {
            GSOFeature newRectfeat = new GSOFeature();
            GSOGeoPolyline3D cloneline = line.Clone() as GSOGeoPolyline3D;

            GSOExtendSectionLineStyle3D style = createRectStyle(width, height);
            if (style == null)
                return null;

            cloneline.Style = style;
            newRectfeat.Geometry = cloneline;
            return newRectfeat;
        }
Example #56
0
 public CtrlModelPathPage(GSOFeature feature, GSOGlobeControl globeControl)
 {
     InitializeComponent();
     m_GlobeControl = globeControl;
     m_Feature = feature;
 }
Example #57
0
        void ctl_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                GSOPoint3d point = ctl.Globe.ScreenToScene(e.X, e.Y);
                if (radioOld.Checked)
                {
                    txtOldLon.Text = point.X.ToString();
                    txtOldLat.Text = point.Y.ToString();

                    if (startFeat == null || startFeat.IsDeleted)
                    {
                        startFeat = new GSOFeature();
                        GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                        GSOGeoMarker p = new GSOGeoMarker();
                        style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png";
                        p.Style = style;
                        p.AltitudeMode = EnumAltitudeMode.ClampToGround;
                        p.X = point.X;
                        p.Y = point.Y;
                        p.Z = point.Z;
                        startFeat.Name = "起点";
                        startFeat.CustomID = 000;
                        startFeat.Geometry = p;

                        startFeat = ctl.Globe.MemoryLayer.AddFeature(startFeat);
                    }
                    else
                    {
                        GSOGeoPoint3D startpoint = startFeat.Geometry as GSOGeoPoint3D;
                        if (startpoint != null)
                        {
                            startpoint.X = point.X;
                            startpoint.Y = point.Y;
                            startpoint.Z = 0;
                        }
                    }
                }
                else
                {
                    txtNewLon.Text = point.X.ToString();
                    txtNewLat.Text = point.Y.ToString();

                    if (endFeat == null || endFeat.IsDeleted)
                    {
                        endFeat = new GSOFeature();
                        GSOGeoMarker p = new GSOGeoMarker();
                        GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                        style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png";
                        p.Style = style;
                        p.AltitudeMode = EnumAltitudeMode.ClampToGround;

                        endFeat.Name = "目标点";
                        endFeat.CustomID = 001;

                        p.X = point.X;
                        p.Y = point.Y;
                        p.Z = point.Z;
                        endFeat.Geometry = p;
                        endFeat = ctl.Globe.MemoryLayer.AddFeature(endFeat);
                    }
                    else
                    {
                        GSOGeoPoint3D endpoint = endFeat.Geometry as GSOGeoPoint3D;
                        if (endpoint != null)
                        {
                            endpoint.X = point.X;
                            endpoint.Y = point.Y;
                            endpoint.Z = 0;
                        }
                    }
                }
                ctl.Refresh();
            }
        }
Example #58
0
 void GetRealFeature(GSOFeature feature, GSOFeatures realfeatures)
 {
     if (feature == null || realfeatures == null)
     {
         return;
     }
     if (feature.Type == EnumFeatureType.Feature)
     {
         realfeatures.Add(feature);
     }
     else if (feature.Type == EnumFeatureType.FeatureFolder)
     {
         GSOFeatureFolder featureFolder = (GSOFeatureFolder)feature;
         for (int i = 0; i < featureFolder.Features.Length; i++)
         {
             GetRealFeature(featureFolder.Features[i],realfeatures);
         }
     }
 }
Example #59
0
 public CtrlFeatureAttribute(GSOFeature feature,GSOGlobeControl globeControl)
 {
     InitializeComponent();
     m_GlobeControl = globeControl;
     m_Feature = feature;
 }
Example #60
0
        private void txtOldChange()
        {
            decimal x;
            decimal y;
            if (txtOldLon.Text.Trim() == "")
            {
                txtOldLon.Text = 0 + "";
            }
            bool bl = decimal.TryParse(txtOldLon.Text.Trim(), out x);
            if (!bl)
            {
                MessageBox.Show("数据不符合要求!");
                return;
            }

            if (txtOldLat.Text.Trim() == "")
            {
                txtOldLat.Text = 0 + "";
            }
            bl = decimal.TryParse(txtOldLat.Text.Trim(), out y);
            if (!bl)
            {
                MessageBox.Show("数据不符合要求!");
                return;
            }

            if (startFeat == null || startFeat.IsDeleted)
            {
                startFeat = new GSOFeature();
                GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                GSOGeoMarker p = new GSOGeoMarker();
                style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png";
                p.Style = style;
                p.AltitudeMode = EnumAltitudeMode.ClampToGround;
                p.X = (double)Math.Round(x);
                p.Y = (double)Math.Round(y);
                p.Z = 0;
                startFeat.Name = "起点";
                startFeat.CustomID = 000;
                startFeat.Geometry = p;

                startFeat = ctl.Globe.MemoryLayer.AddFeature(startFeat);
            }
            else
            {
                GSOGeoPoint3D startpoint = startFeat.Geometry as GSOGeoPoint3D;
                if (startpoint != null)
                {
                    startpoint.X = (double)Math.Round(x);
                    startpoint.Y = (double)Math.Round(y);
                    startpoint.Z = 0;
                }
            }
            ctl.Refresh();
        }