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); }
public FrmAnalysisDigFillOfTerrain(GSOGlobeControl _globeControl1, GSOGeoPolygon3D _polygon3D) { InitializeComponent(); //从主窗口引入两个值,一个球,一个画的范围 globeControl1 = _globeControl1; m_polygon3D = _polygon3D; }
private void buttonAnalyse_Click(object sender, EventArgs e) { if (globeControl1.Globe != null && m_polygon3D != null) { double dAlt = Convert.ToDouble(textBoxDestAlt.Text); //交给系统处理,传入值为面,高度,返回为挖的高度,填的高度,挖的区域,填的区域,全部的面积,最高点,最低点,最后两项默认false,0 globeControl1.Globe.Analysis3D.DigFillAnalyse(m_polygon3D, dAlt, out m_dDigVolume, out m_dFillVolume, out m_dDigArea, out m_dFillArea, out m_dTotalArea, out m_pntMaxAlt, out m_pntMinAlt, false, 0); GSOFeature altFeature = null; //创建一个空要素 GSOFeatures tempFeatures = globeControl1.Globe.MemoryLayer.GetFeatureByName("DigFillAltPolygon", true); //要素从内存图层里获取 if (tempFeatures.Length > 0) //判断是否获取到 { altFeature = tempFeatures[0]; //获取到就直接赋值 } //把传进来的范围面复制一个 GSOGeoPolygon3D newPolygon = (GSOGeoPolygon3D)m_polygon3D.Clone(); newPolygon.SetAltitude(dAlt); //给这个面设置高度 newPolygon.AltitudeMode = EnumAltitudeMode.Absolute; //高度类型是相对地面 GSOExtrudeStyle extrudeStyle = new GSOExtrudeStyle(); //拉伸风格 extrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeToValue; //拉伸方式 extrudeStyle.ExtrudeValue = m_pntMinAlt.Z; //拉伸的值 extrudeStyle.TailPartVisible = false; //末端是否可见 //多边形风格,立面风格 GSOSimplePolygonStyle3D extrudePolygonStyle = new GSOSimplePolygonStyle3D(); extrudePolygonStyle.FillColor = Color.FromArgb(150, 0, 255, 0); //多边形填充颜色 extrudeStyle.BodyStyle = extrudePolygonStyle; //把风格赋给拉伸风格 //多边形风格,顶层风格 GSOSimplePolygonStyle3D polygonStyle = new GSOSimplePolygonStyle3D(); polygonStyle.FillColor = Color.FromArgb(200, 0, 0, 255); //设置颜色 newPolygon.Style = polygonStyle; //面的顶层风格 newPolygon.ExtrudeStyle = extrudeStyle; //棉的立面风格 //判断如果要素为空,或者被删除 if (m_AltFeature == null || m_AltFeature.IsDeleted) { //新建一个要素,并且把刚才配置的要素赋值给它 m_AltFeature = new GSOFeature(); m_AltFeature.Name = "DigFillAltPolygon"; m_AltFeature.Geometry = newPolygon; globeControl1.Globe.MemoryLayer.AddFeature(m_AltFeature); } else { //如果原来就有,就直接赋值 m_AltFeature.Geometry = newPolygon; } //刷新球 globeControl1.Globe.Refresh(); //设置文字 SetText(); } }
public FrmAnalysisFloodSubmerge(GSOGlobeControl _globeControl1, GSOGeoPolygon3D _polygon3D) { InitializeComponent(); //默认20次每秒 textBoxFrequency.Text = "20"; globeControl1 = _globeControl1; m_polygon3D = _polygon3D; }
public Form1() { InitializeComponent(); globeControl1 = new GSOGlobeControl(); panel1.Controls.Add(globeControl1); globeControl1.Dock = DockStyle.Fill; //画完范围事件 globeControl1.TrackPolygonEndEvent += (sender, e) => { if (trackPolygonType == "淹没模拟") { globeControl1.Globe.Action = EnumAction3D.ActionNull; FrmAnalysisFloodSubmerge frm = new FrmAnalysisFloodSubmerge(globeControl1, e.Polygon); frm.Show(this); } }; //记录鼠标落下的坐标 globeControl1.MouseDown += (sender, e) => { mouseDown = e.Location; }; //判断鼠标抬起时,坐标位置不变 globeControl1.MouseUp += (sender, e) => { if (mouseDown == e.Location) { if (e.Button == MouseButtons.Left) { if (globeControl1.Globe.Action == EnumAction3D.SelectObject) { if (trackPolygonType == "淹没模拟") { GSOFeature feature = globeControl1.Globe.SelectedObject; if (feature == null || feature.Geometry == null || feature.Geometry.Type != EnumGeometryType.GeoPolygon3D) { MessageBox.Show("请选择一个面"); return; } GSOGeoPolygon3D ePolygon = feature.Geometry as GSOGeoPolygon3D; globeControl1.Globe.Action = EnumAction3D.ActionNull; FrmAnalysisFloodSubmerge frm = new FrmAnalysisFloodSubmerge(globeControl1, ePolygon); frm.Show(this); } } } } }; }
private void makeBuffer(GSOFeature feature) { double radius = (double)numericUpDownRadius.Value; //缓冲区宽度 double value = (double)numericUpDownFenDuan.Value; //圆角角度 bool isRoundCorner = CBRoundCorner.Checked; //拐角是否圆滑 bool isRoundEnds = CBRoundEnds.Checked; //两端是否圆滑 GSOGeoPolygon3D buffer = null; //创建缓冲面 if (feature.Geometry.Type == EnumGeometryType.GeoMarker) //如果要素为点 { GSOGeoMarker marker = feature.Geometry as GSOGeoMarker; buffer = marker.CreateBuffer(radius, value, false); //创建点的缓冲面(宽度,角度,false) } else if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; buffer = line.CreateBuffer(radius, isRoundCorner, value, isRoundEnds, false); //创建线的缓冲面(宽度,拐角圆滑,角度,两端圆滑,false) } else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) { GSOGeoPolygon3D polygon = feature.Geometry as GSOGeoPolygon3D; buffer = polygon.CreateBuffer(radius, isRoundCorner, value, isRoundEnds, false); //创建面的缓冲面(宽度,拐角圆滑,角度,两端圆滑,false) } if (buffer != null) { //缓冲面颜色 GSOSimplePolygonStyle3D style = new GSOSimplePolygonStyle3D(); style.FillColor = Color.FromArgb(122, Color.Yellow); //缓冲线颜色 GSOSimpleLineStyle3D outlineStyle = new GSOSimpleLineStyle3D(); outlineStyle.LineColor = Color.Red; style.OutlineStyle = outlineStyle; buffer.Style = style; GSOFeature featureBuffer = new GSOFeature(); featureBuffer.Geometry = buffer; featureBuffer.Name = feature.Name + "_" + radius + "米_Buffer"; globeControl1.Globe.MemoryLayer.AddFeature(featureBuffer); //重新创建原有要素,使得要素在缓冲面上方,可选择 if (feature != null && feature.Dataset.Type == EnumDatasetType.Memory && feature.Dataset.Caption == "" && feature.Dataset.Name == "") { GSOFeature featureSelectCopy = feature.Clone(); globeControl1.Globe.MemoryLayer.AddFeature(featureSelectCopy); feature.Delete(); } globeControl1.Refresh(); } }
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; }
private void GlobeControl1OnTrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) { GSOGeoPolygon3D polygon = e.Polygon; if (TracPolygonType == "挖坑") { //创建坑对象 GSOGeoPit pit = new GSOGeoPit(); pit.PitDepthUsing = true; //是否使用深度 pit.PitDepth = 10; //深度 pit.PitPolygon = polygon; //坑的面 globeControl1.Globe.AddPit("坑1", pit); } }
private void AddPolygon() { GSOGeoPolygon3D geoPolygon = new GSOGeoPolygon3D(); //创建多边形对象 //创建节点对象 GSOPoint3ds polygonPnts = new GSOPoint3ds(); polygonPnts.Add(new GSOPoint3d(116.7, 39.8, 0)); polygonPnts.Add(new GSOPoint3d(116.8, 39.9, 0)); polygonPnts.Add(new GSOPoint3d(116.8, 39.7, 0)); polygonPnts.Add(new GSOPoint3d(116.7, 39.7, 0)); geoPolygon.AddPart(polygonPnts); //把节点添加到多边形对象上 GSOSimplePolygonStyle3D stylePolygon = new GSOSimplePolygonStyle3D(); //创建风格 stylePolygon.OutLineVisible = true; //显示多边形的边缘线 //设置多边形的填充颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 stylePolygon.FillColor = Color.FromArgb(100, 255, 255, 0); geoPolygon.Style = stylePolygon; //把风格添加到多边形上 //创建几何对象并设置属性 GSOFeature f = new GSOFeature(); f.Geometry = geoPolygon; f.Name = "多边形 01"; f.SetFieldValue("description", "a demo polygon"); #region 属性设置 f.Description = "<html>\r\n<head>\r\n<style>\r\n#tab-list {\r\nborder-collapse:collapse;\r\nfont-size:15px;\r\nmargin:20px;\r\ntext-align:left;\r\nwidth:280px;\r\n}\r\n\r\n#tab-list th {\r\nborder-bottom:2px solid #6678B1;\r\ncolor:#003399;\r\nfont-size:14px;\r\nfont-weight:normal;\r\npadding:10px 8px;\r\n}\r\n#tab-list td {\r\nborder-bottom:1px solid #CCCCCC;\r\ncolor:#666699;\r\npadding:6px 8px;\r\n}\r\n</style>\r\n</head>\r\n<body style=\"border:none\">\r\n<center>\r\n<table id=\"tab-list\">\r\n<thead><tr><th>属性名称</th><th>属性值</th></tr></thead>\r\n<tbody>$tablecontent</tbody></table>\r\n</center>\r\n</body>\r\n</html>\r\n"; GSOGeoPolyline3D line = new GSOGeoPolyline3D(); line.AddPart((f.Geometry as GSOGeoPolygon3D)[0]); double length = line.GetSpaceLength(true, 6378137) / 1000; Dictionary <string, string> property = new Dictionary <string, string>(); property.Add("面积", ((f.Geometry as GSOGeoPolygon3D).Area / 1000000).ToString("f4") + "平方千米"); property.Add("周长", length.ToString("f2") + "千米"); f.Description = f.Description.Replace("$tablecontent", maketable(property)); #endregion globeControl1.Globe.MemoryLayer.AddFeature(f); //把几何要素添加到内存图层中 }
// 面 private void btn_Polygon_Click(object sender, System.EventArgs e) { GSOGeoPolygon3D polygon = new GSOGeoPolygon3D(); //创建多边形对象 //创建节点对象 GSOPoint3ds polygonPnts = new GSOPoint3ds(); polygonPnts.Add(new GSOPoint3d(120.47, 31.3, 0)); polygonPnts.Add(new GSOPoint3d(120.48, 31.3, 0)); polygonPnts.Add(new GSOPoint3d(120.48, 31.25, 0)); polygonPnts.Add(new GSOPoint3d(120.47, 31.2, 0)); polygon.AddPart(polygonPnts); //把节点添加到多边形对象上 GSOSimplePolygonStyle3D style = new GSOSimplePolygonStyle3D(); style.FillColor = Color.FromArgb(255, Color.Gray); polygon.Style = style; AddNewGeoToLayer(polygon, "面"); }
private void GlobeOnTrackRectEndEvent(object sender, TrackRectEndEventArgs e) { if (e.Polygon != null) { //将分析矩形复制 GSOGeoPolygon3D polygon = e.Polygon.Clone() as GSOGeoPolygon3D; //清除分析 _glbControl.Globe.ClearAnalysis(); //新建要素 GSOFeature newFeature = new GSOFeature(); //图形元素赋值给要素 newFeature.Geometry = polygon; newFeature.Name = "我的矩形"; //添加要素到图层 _glbControl.Globe.MemoryLayer.AddFeature(newFeature); _glbControl.Refresh(); _glbControl.Globe.Action = EnumAction3D.ActionNull; } }
/// <summary> /// 创建面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddPolygon_Click(object sender, EventArgs e) { GSOGeoPolygon3D geoPolygon = new GSOGeoPolygon3D(); //创建多边形对象 //创建节点对象 GSOPoint3ds polygonPnts = new GSOPoint3ds(); polygonPnts.Add(new GSOPoint3d(116.7, 39.8, 0)); polygonPnts.Add(new GSOPoint3d(116.8, 39.9, 0)); polygonPnts.Add(new GSOPoint3d(116.8, 39.7, 0)); polygonPnts.Add(new GSOPoint3d(116.7, 39.7, 0)); geoPolygon.AddPart(polygonPnts); //把节点添加到多边形对象上 GSOSimplePolygonStyle3D stylePolygon = new GSOSimplePolygonStyle3D(); //创建风格 stylePolygon.OutLineVisible = true; //显示多边形的边缘线 //设置多边形的填充颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 stylePolygon.FillColor = Color.FromArgb(100, 255, 255, 0); geoPolygon.Style = stylePolygon; //把风格添加到多边形上 //创建几何对象并设置属性 GSOFeature f = new GSOFeature(); f.Geometry = geoPolygon; f.Name = "多边形 01"; f.SetFieldValue("description", "a demo polygon"); //绑定数据 btnRemovePolygon.Tag = f; globeControl1.Globe.MemoryLayer.AddFeature(f); //把几何要素添加到内存图层中 //下面不属于工程内容,只是飞到点的位置 GSOCameraState cs = new GSOCameraState(); cs.Longitude = 116.75; cs.Latitude = 39.8; cs.Altitude = 50000; globeControl1.Globe.FlyToCameraState(cs); }
private void Form1_Load(object sender, EventArgs e) { #region 创建面要素和飞到面 GSOGeoPolygon3D geoPolygon = new GSOGeoPolygon3D(); //创建多边形对象 //创建节点对象 GSOPoint3ds polygonPnts = new GSOPoint3ds(); polygonPnts.Add(new GSOPoint3d(116.7, 39.8, 0)); polygonPnts.Add(new GSOPoint3d(116.8, 39.9, 0)); polygonPnts.Add(new GSOPoint3d(116.8, 39.7, 0)); polygonPnts.Add(new GSOPoint3d(116.7, 39.7, 0)); geoPolygon.AddPart(polygonPnts); //把节点添加到多边形对象上 GSOSimplePolygonStyle3D stylePolygon = new GSOSimplePolygonStyle3D(); //创建风格 stylePolygon.OutLineVisible = true; //显示多边形的边缘线 //设置多边形的填充颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 stylePolygon.FillColor = Color.FromArgb(100, 255, 255, 0); geoPolygon.Style = stylePolygon; //把风格添加到多边形上 //下面不属于工程内容,只是飞到点的位置 GSOCameraState cs = new GSOCameraState(); cs.Longitude = 116.75; cs.Latitude = 39.8; cs.Altitude = 50000; globeControl1.Globe.FlyToCameraState(cs); #endregion //创建几何对象并设置属性 GSOFeature f = new GSOFeature(); f.Geometry = geoPolygon; f.Name = "多边形 01"; f.CustomID = 1; f.SetFieldValue("description", "a demo polygon"); f.Description = "这是一个多边形"; //将面添加到球中 feature = globeControl1.Globe.MemoryLayer.AddFeature(f); //添加的时候获取要素 }
private void buttonOK_Click(object sender, EventArgs e) { string filename = textbox1.Text.Trim(); GSOLayer newlayer = mGlobeControl.Globe.Layers.Add(filename); int indexCount = filename.LastIndexOf('.') - filename.LastIndexOf('\\') - 1; string newlayerCaption = ""; if (indexCount > 0) { newlayerCaption = filename.Substring(filename.LastIndexOf('\\') + 1, indexCount); newlayer.Caption = newlayerCaption; } for (int i = 0; i < mListPolygon.Count; i++) { GSOGeoPolygon3D polygon = mListPolygon[i]; string caption = ""; if (comboBoxLayerName.SelectedIndex >= 0) { caption = comboBoxLayerName.SelectedItem.ToString().Trim(); } GSOLayer layer = mGlobeControl.Globe.Layers.GetLayerByCaption(caption); GSOFeatures feats = new GSOFeatures(); if (layer != null) { feats = layer.FindFeaturesInPolygon(polygon, false); } if (feats != null) { newlayer.AddFeatures(feats); } } if (newlayer != null) { newlayer.SaveAs(filename); MessageBox.Show("导出成功!", "提示"); } this.Close(); }
/// <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(); }
private void setMouse() { globeControl1.MouseDown += (sender, e) => { mouseDown = e.Location; }; globeControl1.MouseUp += (sender, e) => { if (mouseDown != e.Location) { return; } if (e.Button == MouseButtons.Left) { if (globeControl1.Globe.Action == EnumAction3D.SelectObject) { if (mouseClikeInfo == "填挖方分析") { GSOFeature feature = globeControl1.Globe.SelectedObject; if (feature == null || feature.Geometry == null || feature.Geometry.Type != EnumGeometryType.GeoPolygon3D) { MessageBox.Show("请选择一个面"); return; } globeControl1.Globe.Action = EnumAction3D.ActionNull; GSOGeoPolygon3D polygon = feature.Geometry as GSOGeoPolygon3D; FrmAnalysisDigFillOfTerrain frm = new FrmAnalysisDigFillOfTerrain(globeControl1, polygon); frm.Show(this); } } } }; }
private GSOPoint3ds GetCurNodes() { GSOPoint3ds nodes = null; if (m_Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D geoPolyline3D = m_Geometry as GSOGeoPolyline3D; if (geoPolyline3D.PartCount > 0) { //一条线由多条子线组成,目前就显示第一条子线的节点内容把 nodes = geoPolyline3D[0]; } } else if (m_Geometry.Type == EnumGeometryType.GeoPolygon3D || m_Geometry.Type == EnumGeometryType.GeoWater) { GSOGeoPolygon3D geoPolygon3D = m_Geometry as GSOGeoPolygon3D; if (geoPolygon3D.PartCount > 0) { nodes = geoPolygon3D[0]; } } return(nodes); }
private void btnCreateModel_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtModelLayer.Text)) { MessageBox.Show("文件路径无效!", "提示"); return; } if (File.Exists(txtModelLayer.Text)) { MessageBox.Show("文件已存在!", "提示"); return; } GSOLayer sourceLayer = ctl.Globe.Layers[cmbLayer.SelectedIndex]; GSOLayer layer = ctl.Globe.Layers.Add(txtModelLayer.Text); lgdFilePath = txtModelLayer.Text; if (layer != null) { GSOFeatures features = sourceLayer.GetAllFeatures(); for (int j = 0; j < features.Length; j++) { GSOFeature f = features[j]; GSOFeature newFeature = new GSOFeature(); string text = ""; if (combLabel.SelectedItem != null) { text = f.GetFieldAsString(combLabel.SelectedItem.ToString()); } if (listFields.CheckedItems.Count > 0) { newFeature.Description = GetBubbleInfo(f, numWidth.Value.ToString(), numHeight.Value.ToString()); } if (f.Geometry is GSOGeoPoint3D) { GSOGeoMarker marker = new GSOGeoMarker(); marker.Position = f.Geometry.GeoCenterPoint; marker.Text = text; GSOMarkerStyle3D style = new GSOMarkerStyle3D(); style.IconPath = Application.StartupPath + "\\Resource\\ddd.png"; marker.Style = style; newFeature.Geometry = marker; } else if (f.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = (GSOGeoPolyline3D)f.Geometry.Clone(); GSOLabel label = new GSOLabel(); label.Text = text; GSOLabelStyle style = new GSOLabelStyle(); style.HasTracktionLine = false; style.OutlineColor = Color.Transparent; style.MaxVisibleDistance = 100000; label.Style = style; line.Label = label; newFeature.Geometry = line; } else if (f.Geometry.Type == EnumGeometryType.GeoPolygon3D) { GSOGeoPolygon3D polygon = (GSOGeoPolygon3D)f.Geometry.Clone(); GSOLabel label = new GSOLabel(); label.Text = text; GSOLabelStyle style = new GSOLabelStyle(); style.HasTracktionLine = false; style.OutlineColor = Color.Transparent; style.MaxVisibleDistance = 100000; label.Style = style; polygon.Label = label; newFeature.Geometry = polygon; } newFeature.Name = text; layer.AddFeature(newFeature); } } ctl.Refresh(); layer.Save(); //ctl.Globe.Layers.Remove(layer); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonAnalyse_Click(object sender, EventArgs e) { if (m_globe != null && m_polygon3D != null) { double dAlt = System.Convert.ToDouble(textBoxDestAlt.Text); m_globe.Analysis3D.DigFillAnalyse(m_polygon3D, dAlt, out m_dDigVolume, out m_dFillVolume, out m_dDigArea, out m_dFillArea, out m_dTotalArea, out m_pntMaxAlt, out m_pntMinAlt, false, 0); //double dTempArea = m_polygon3D.Area; //double dDiff = dTempArea - m_dTotalArea; //double dRadio = dDiff / dTempArea; GSOFeature altFeature = null; GSOFeatures tempFeatures = m_globe.MemoryLayer.GetFeatureByName("DigFillAltPolygon", true); if (tempFeatures.Length > 0) { altFeature = tempFeatures[0]; } GSOGeoPolygon3D newPolygon = (GSOGeoPolygon3D)m_polygon3D.Clone(); newPolygon.SetAltitude(dAlt); newPolygon.AltitudeMode = EnumAltitudeMode.Absolute; GSOExtrudeStyle extrudeStyle = new GSOExtrudeStyle(); extrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeToValue; extrudeStyle.ExtrudeValue = m_pntMinAlt.Z; extrudeStyle.TailPartVisible = false; GSOSimplePolygonStyle3D extrudePolygonStyle = new GSOSimplePolygonStyle3D(); extrudePolygonStyle.FillColor = Color.FromArgb(150, 0, 255, 0); extrudeStyle.BodyStyle = extrudePolygonStyle; GSOSimplePolygonStyle3D polygonStyle = new GSOSimplePolygonStyle3D(); polygonStyle.FillColor = Color.FromArgb(200, 0, 0, 255); newPolygon.Style = polygonStyle; newPolygon.ExtrudeStyle = extrudeStyle; if (m_AltFeature == null || m_AltFeature.IsDeleted) { m_AltFeature = new GSOFeature(); m_AltFeature.Name = "DigFillAltPolygon"; m_AltFeature.Geometry = newPolygon; m_globe.MemoryLayer.AddFeature(m_AltFeature); } else { m_AltFeature.Geometry = newPolygon; } m_globe.Refresh(); SetText(); } }
//应用 private void buttonApply_Click(object sender, EventArgs e) { if (comboBoxLayerCaption.SelectedItem == null) { MessageBox.Show("请选择一个管线图层!", "提示"); return; } if (comboBoxLayerValveCaption.SelectedItem == null) { MessageBox.Show("请选择一个工井图层!", "提示"); return; } if (textBoxValueIndented.Text.Trim() == "") { MessageBox.Show("请输入缩进距离!", "提示"); return; } if (textBoxAllowance.Text.Trim() == "") { MessageBox.Show("请输入容限值!", "提示"); return; } double valueAllowance = 0.0; if (double.TryParse(textBoxAllowance.Text.Trim(), out valueAllowance) == false) { MessageBox.Show("请输入一个正确的容限值!", "提示"); return; } float valueIndented = 0.0f; if (float.TryParse(textBoxValueIndented.Text.Trim(), out valueIndented) == false) { MessageBox.Show("请输入一个正确的缩进值!", "提示"); return; } string layerCaption = comboBoxLayerCaption.SelectedItem.ToString().Trim(); string valveLayerCaption = comboBoxLayerValveCaption.SelectedItem.ToString().Trim(); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerCaption); GSOLayer valveLayer = globeControl1.Globe.Layers.GetLayerByCaption(valveLayerCaption); if (layer != null && valveLayerCaption != null) { featuresIndented.RemoveAll(); cancelHighLight(layer.GetAllFeatures()); for (int i = 0; i < layer.GetAllFeatures().Length; i++) { GSOFeature feature = layer.GetAt(i); if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; double lineLenght = line.GetSpaceLength(false, 6378137.0); if (lineLenght <= valueIndented * 2) { continue; } featuresIndented.Add(feature);//缩进的管线集合 featuresInit.Add(feature.Clone()); //头缩进 GSOPoint3d headPoint = line[0][0]; GSOGeoPolyline3D newline = new GSOGeoPolyline3D(); GSOPoint3ds part = new GSOPoint3ds(); part.Add(headPoint); headPoint.X = headPoint.X - 0.0000000005; part.Add(headPoint); newline.AddPart(part); GSOGeoPolygon3D buffer = newline.CreateBuffer(valueAllowance, true, 5, true, false); GSOFeatures features = valveLayer.FindFeaturesInPolygon(buffer, false); if (features.Length > 0) { feature.HighLight = true; if (line.Style != null && line.Style is GSOPipeLineStyle3D) { GSOPipeLineStyle3D style = line.Style as GSOPipeLineStyle3D; style.HeadJointParam = new GSOPipeJointParam(); style.HeadJointParam.Extent = -valueIndented; } } //尾缩进 GSOPoint3d tailPoint = line[line.PartCount - 1][line[line.PartCount - 1].Count - 1]; newline = new GSOGeoPolyline3D(); part = new GSOPoint3ds(); part.Add(tailPoint); tailPoint.X = tailPoint.X - 0.0000000005; part.Add(tailPoint); newline.AddPart(part); buffer = newline.CreateBuffer(valueAllowance, true, 5, true, false); features = valveLayer.FindFeaturesInPolygon(buffer, false); if (features.Length > 0) { feature.HighLight = true; if (line.Style != null && line.Style is GSOPipeLineStyle3D) { GSOPipeLineStyle3D style = line.Style as GSOPipeLineStyle3D; style.TailJointParam = new GSOPipeJointParam(); style.TailJointParam.Extent = -valueIndented; } } } } } globeControl1.Globe.Refresh(); }
private void _glbControl_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) { //判断绘制的多边形是否在倾斜摄影图层上 GSOPoint3ds polygonPots = e.Polygon[0]; if (!lfpLayer.LatLonBounds.Left.Equals(0.0) && !lfpLayer.LatLonBounds.Bottom.Equals(0.0) && !lfpLayer.LatLonBounds.Top.Equals(0.0) && !lfpLayer.LatLonBounds.Right.Equals(0.0)) { for (int i = 0; i < polygonPots.Count; i++) { if (!lfpLayer.LatLonBounds.Contains(polygonPots[i].X, polygonPots[i].Y)) { MessageBox.Show("请将多边形画于倾斜摄影图层上。"); //清除上一个绘制的分析多边形 _glbControl.Globe.ClearLastTrackPolygon(); return; } } } //压平分析 if (_isPressOn) { //将倾斜摄影图层转换为GSOPageLODFeatureLayer分析图层 GSOPageLODFeatureLayer layer2 = lfpLayer as GSOPageLODFeatureLayer; //压平面 GSOGeoPolygon3D poly1 = e.Polygon; //加入到压平面的List为模型替换做准备 _trackPressPolygon.Add(e.Polygon); //高度模式为绝对高度 poly1.AltitudeMode = EnumAltitudeMode.Absolute; if (layer2 != null) { //添加压平面 layer2.AddFlattenPolygon3D(poly1, ""); //保存压平面 layer2.Save(); } _isPressOn = false; } //填挖方分析 else { //挖方量 double m_dDigVolume = 0; //填方量 double m_dFillVolume = 0; //分析总面积 double m_dTotalArea = 0; //挖方面积(废除) double m_dDigArea = 0; //填方面积(废除) double m_dFillArea = 0; double dAlt = 50; //挖填方高度 double pointDistance = 1; //采样精度,单位:米 //将平面坐标转换为经纬度坐标,使用默认投影ID为0 GSOPoint2d point2D = GSOProjectManager.Inverse(new GSOPoint2d(pointDistance, pointDistance), 0); double dDSampleGap = point2D.X;//重采样的点的距离,单位是:经纬度 //挖方分析线 GSOGeoPolyline3D lineDig = new GSOGeoPolyline3D(); //填方分析线 GSOGeoPolyline3D lineFill = new GSOGeoPolyline3D(); //填挖方分析 bool analysisResult = _glbControl.Globe.Analysis3D.DigFillAnalyseWithModel(e.Polygon, dAlt, out m_dDigVolume, out m_dFillVolume, out m_dDigArea, out m_dFillArea, out m_dTotalArea, dDSampleGap, lineDig, lineFill); //分析成功 if (analysisResult) { StringBuilder str = new StringBuilder(); str.AppendLine("分析高度:" + dAlt.ToString()); str.AppendLine("分析精度:" + pointDistance.ToString() + "米"); str.AppendLine("挖方量:" + m_dDigVolume.ToString() + "立方米"); str.AppendLine("填方量:" + m_dFillVolume.ToString() + "立方米"); str.AppendLine("总面积:" + m_dTotalArea.ToString() + "平方米"); MessageBox.Show(str.ToString()); } else { MessageBox.Show("分析失败。"); } } _glbControl.Refresh(); _glbControl.Globe.Action = EnumAction3D.ActionNull; }
private void comboBoxLayers_TextChanged(object sender, EventArgs e) { string layerName = comboBoxLayers.Text; if (layerName.Trim().Equals("")) { return; } GSOLayer layer = mGlobeControl.Globe.Layers.GetLayerByCaption(layerName); if (layer == null) { return; } //清空上一个图层的style textBoxIconPath.Text = ""; textBoxLineColor.BackColor = this.BackColor; textBoxLineWidth.Text = ""; textBoxOutlineColor.BackColor = this.BackColor; textBoxPolygonColor.BackColor = this.BackColor; textBoxOutlineWidth.Text = ""; textBoxPolygonAlpha.Text = ""; bool markerExists = false; bool lineExists = false; bool polygonExists = false; GSOFeatures features = GetAllRealFeatures(layer); for (int i = 0; i < features.Length; i++) { GSOFeature feature = features[i]; if (feature == null) { continue; } if (feature.Geometry != null) { switch (feature.Geometry.Type) { case EnumGeometryType.GeoMarker: if (!markerExists) { GSOGeoMarker marker = (GSOGeoMarker)feature.Geometry; GSOMarkerStyle3D style = (GSOMarkerStyle3D)marker.Style; if (style != null) { textBoxIconPath.Text = style.IconPath; checkBoxHideLabelOfMarker.Checked = !style.TextVisible; markerExists = true; } } break; case EnumGeometryType.GeoPolyline3D: if (!lineExists) { GSOGeoPolyline3D line = (GSOGeoPolyline3D)feature.Geometry; if (line.Label != null) { checkBoxHideLabelOfPolygon.Checked = !line.Label.Visible; } if (line.Style != null) { GSOSimpleLineStyle3D simpleLineStyle = (GSOSimpleLineStyle3D)line.Style; if (simpleLineStyle != null) { textBoxLineColor.BackColor = simpleLineStyle.LineColor; textBoxLineWidth.Text = (simpleLineStyle.LineWidth == 0 ? "1".ToString() : simpleLineStyle.LineWidth.ToString()); lineExists = true; } else { GSOPipeLineStyle3D pipeLineStyle = (GSOPipeLineStyle3D)line.Style; if (pipeLineStyle != null) { textBoxLineColor.BackColor = pipeLineStyle.LineColor; textBoxLineWidth.Text = (pipeLineStyle.Radius * 2).ToString(); lineExists = true; } } } } break; case EnumGeometryType.GeoPolygon3D: if (!polygonExists) { GSOGeoPolygon3D polygon = (GSOGeoPolygon3D)feature.Geometry; if (polygon.Label != null) { checkBoxHideLabelOfLine.Checked = !polygon.Label.Visible; } GSOSimplePolygonStyle3D stylePolygon = (GSOSimplePolygonStyle3D)polygon.Style; if (stylePolygon != null) { textBoxPolygonColor.BackColor = Color.FromArgb(stylePolygon.FillColor.R, stylePolygon.FillColor.G, stylePolygon.FillColor.B); textBoxPolygonAlpha.Text = stylePolygon.FillColor.A.ToString(); GSOSimpleLineStyle3D styleOutline = (GSOSimpleLineStyle3D)stylePolygon.OutlineStyle; if (styleOutline != null) { textBoxOutlineColor.BackColor = styleOutline.LineColor; textBoxOutlineWidth.Text = (styleOutline.LineWidth == 0 ? "1".ToString() : styleOutline.LineWidth.ToString()); } polygonExists = true; } } break; } } } }
private void button2_Click(object sender, EventArgs e) { if (comboBoxLayers.Text == "") { MessageBox.Show("请选择一个图层!"); return; } GSOLayer layer = mGlobeControl.Globe.Layers.GetLayerByCaption(comboBoxLayers.Text.Trim()); if (layer == null) { MessageBox.Show("您选择的图层不存在!"); return; } string iconPath = textBoxIconPath.Text.Trim(); if (iconPath == "") { iconPath = Application.StartupPath + "\\Resource\\DefaultIcon.png"; } Color lineColor = textBoxLineColor.BackColor; string strLineWidth = textBoxLineWidth.Text.Trim(); double lineWidth = 1; bool blIsLineWidth = double.TryParse(strLineWidth, out lineWidth); Color outlineColor = textBoxOutlineColor.BackColor; string strOutlineWidth = textBoxOutlineWidth.Text.Trim(); double outlineWidth = 1; bool blIsOutlineWidth = double.TryParse(strOutlineWidth, out outlineWidth); Color polygonColor = textBoxPolygonColor.BackColor; string strPolygonAlpha = textBoxPolygonAlpha.Text.Trim(); int polygonAlpha = 255; bool blIsPolygonAlpha = int.TryParse(strPolygonAlpha, out polygonAlpha); polygonColor = Color.FromArgb(polygonAlpha, polygonColor); for (int i = 0; i < layer.GetAllFeatures().Length; i++) { GSOFeature feature = layer.GetAt(i); if (feature.Geometry != null) { switch (feature.Geometry.Type) { case EnumGeometryType.GeoPoint3D: if (panelPoints.Enabled) { GSOGeoPoint3D point = (GSOGeoPoint3D)feature.Geometry; GSOGeoMarker marker = new GSOGeoMarker(); marker.Position = point.Position; marker.Name = point.Name; marker.CameraState = point.CameraState; marker.Label = point.Label; GSOFeature newFeature = new GSOFeature(); newFeature.Name = feature.Name; newFeature.Geometry = marker; layer.RemoveAt(i); layer.AddFeature(newFeature); i--; } break; case EnumGeometryType.GeoMarker: if (panelPoints.Enabled) { GSOGeoMarker marker = (GSOGeoMarker)feature.Geometry; GSOMarkerStyle3D style = null; if (marker.Style == null) { style = new GSOMarkerStyle3D(); } else { style = (GSOMarkerStyle3D)marker.Style; } style.TextVisible = !checkBoxHideLabelOfMarker.Checked; style.IconPath = iconPath.Trim(); marker.Style = style; } break; case EnumGeometryType.GeoPolyline3D: if (panelLines.Enabled) { GSOGeoPolyline3D line = (GSOGeoPolyline3D)feature.Geometry; if (line.Label != null) { line.Label.Visible = !checkBoxHideLabelOfLine.Checked; } if (line.Style == null) { GSOSimpleLineStyle3D styleLine = new GSOSimpleLineStyle3D(); styleLine.LineColor = lineColor; styleLine.LineWidth = lineWidth; line.Style = styleLine; } else { GSOSimpleLineStyle3D styleLine = (GSOSimpleLineStyle3D)line.Style; if (styleLine == null) { GSOPipeLineStyle3D pipeStyle = (GSOPipeLineStyle3D)line.Style; if (pipeStyle != null) { pipeStyle.LineColor = lineColor; pipeStyle.Radius = lineWidth / 2; line.Style = pipeStyle; } } else { styleLine.LineColor = lineColor; styleLine.LineWidth = lineWidth; line.Style = styleLine; } } } break; case EnumGeometryType.GeoPolygon3D: if (panelPolygons.Enabled) { GSOGeoPolygon3D polygon = (GSOGeoPolygon3D)feature.Geometry; if (polygon.Label != null) { polygon.Label.Visible = !checkBoxHideLabelOfPolygon.Checked; } GSOSimplePolygonStyle3D stylePolygon = (polygon.Style == null ? new GSOSimplePolygonStyle3D() : (GSOSimplePolygonStyle3D)polygon.Style); stylePolygon.FillColor = polygonColor; stylePolygon.OutLineVisible = true; GSOSimpleLineStyle3D styleOutline = (GSOSimpleLineStyle3D)stylePolygon.OutlineStyle; if (styleOutline == null) { styleOutline = new GSOSimpleLineStyle3D(); } styleOutline.LineWidth = outlineWidth; styleOutline.LineColor = outlineColor; stylePolygon.OutlineStyle = styleOutline; polygon.Style = stylePolygon; } break; } } } mGlobeControl.Globe.Refresh(); this.Close(); }
private bool apply() { double waveSpeedX = 0; if (!double.TryParse(textBoxWaveSpeedX.Text.Trim(), out waveSpeedX)) { MessageBox.Show("水波横向速度不符合要求"); return(false); } double waveSpeedY = 0; if (!double.TryParse(textBoxWaveSpeedY.Text.Trim(), out waveSpeedY)) { MessageBox.Show("水波纵向速度不符合要求"); return(false); } double waveWidth = 0; if (!double.TryParse(textBoxWaveWidth.Text.Trim(), out waveWidth)) { MessageBox.Show("水波宽度不符合要求"); return(false); } Color waterColor = pictureBoxWaterColor.BackColor; Color reflectorColor = Color.FromArgb(Convert.ToByte(upDownReflectOpaque.Value), pictureBoxReflectColor.BackColor); int intLightType = comboBoxLightType.SelectedIndex; string waveNormalImagePath = textBoxNormalImage.Text; string waveDuDvImagePath = textBoxDuDvImage.Text; GSOFeatures featuresAdded = new GSOFeatures(); GSOFeatures featuresNomal = new GSOFeatures(); for (int i = mFeatures.Length - 1; i >= 0; i--) { GSOFeature feature = mFeatures[i]; if (feature != null && feature.Geometry != null) { if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) { GSOGeoPolygon3D geoPolygon3d = (GSOGeoPolygon3D)feature.Geometry; GSOGeoWater geoWater = geoPolygon3d.ConvertToGeoWater(); // 水一般都是绝对高度模式 //geoWater.Altitude = EnumAltitudeMode.Absolute; geoWater.WaveSpeedX = waveSpeedX; geoWater.WaveSpeedY = waveSpeedY; geoWater.WaveWidth = waveWidth; geoWater.WaterColor = waterColor; geoWater.ReflectColor = reflectorColor; geoWater.WaveNormalImage = waveNormalImagePath; geoWater.WaveDuDvImage = waveDuDvImagePath; geoWater.ReflectSky = checkboxReflectSky.Checked; geoWater.UseWaveLOD = checkBoxWaveLOD.Checked; GSOFeature newFeature = feature.Clone(); geoWater.Play(); newFeature.Geometry = geoWater; featuresAdded.Add(newFeature); } else if (feature.Geometry.Type == EnumGeometryType.GeoWater) { GSOGeoWater geoWater = (GSOGeoWater)feature.Geometry; // 水一般都是绝对高度模式 //geoWater.Altitude = EnumAltitudeMode.Absolute; geoWater.WaveSpeedX = waveSpeedX; geoWater.WaveSpeedY = waveSpeedY; geoWater.WaveWidth = waveWidth; geoWater.WaterColor = waterColor; geoWater.ReflectColor = reflectorColor; geoWater.WaveNormalImage = waveNormalImagePath; geoWater.WaveDuDvImage = waveDuDvImagePath; geoWater.ReflectSky = checkboxReflectSky.Checked; geoWater.UseWaveLOD = checkBoxWaveLOD.Checked; GSOFeature newFeature = feature.Clone(); geoWater.Play(); newFeature.Geometry = geoWater; featuresAdded.Add(newFeature); } else { featuresNomal.Add(feature); } } } mLayer.RemoveAllFeature(); mLayer.AddFeatures(featuresAdded); mLayer.AddFeatures(featuresNomal); mGlobeControl.Refresh(); return(true); }