/// <summary> /// 水平净距分析 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_HorizonDist_Click(object sender, EventArgs e) { btn_CreatePipeLine.PerformClick(); //创建传入参数 GSOPoint3d pntIntersect11 = new GSOPoint3d(); GSOPoint3d pntIntersect12 = new GSOPoint3d(); GSOPoint3d pntProIntersect11 = new GSOPoint3d(); GSOPoint3d pntProIntersect12 = new GSOPoint3d(); //水平净距分析,传入两条线,返回四个点 double vVert1 = _glbControl.Globe.Analysis3D.ComputeVerticalDistance(_pipeFeature1.Geometry as GSOGeoPolyline3D, _pipeFeature2.Geometry as GSOGeoPolyline3D, out pntIntersect11, out pntIntersect12, out pntProIntersect11, out pntProIntersect12, false); //计算两点间的空间距离 GSOGeoPolyline3D polyline1 = new GSOGeoPolyline3D(); GSOPoint3ds points1 = new GSOPoint3ds(); points1.Add(pntIntersect11); points1.Add(pntIntersect12); polyline1.AddPart(points1); //将两点间的空间距离扣除管径即为水平净距, 6378137为地球半径 vVert1 = polyline1.GetSpaceLength(true, 6378137) - _radius - _radius; MessageBox.Show(string.Format("计算出的水平净距为{0}", Math.Round(vVert1, 3))); }
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); }
// 沿线运动对象 private void btn_MoveObj_Click(object sender, EventArgs e) { //创建路线(也可以通过获取) GSOGeoPolyline3D polyLine = new GSOGeoPolyline3D(); GSOPoint3ds pnts = new GSOPoint3ds(); //创建节点对象 //把各节点添加到节点对象上 pnts.Add(new GSOPoint3d(120.4, 31.3, 0)); pnts.Add(new GSOPoint3d(120.41, 31.31, 0)); pnts.Add(new GSOPoint3d(120.42, 31.32, 0)); pnts.Add(new GSOPoint3d(120.43, 31.30, 0)); pnts.Add(new GSOPoint3d(120.44, 31.34, 0)); polyLine.AddPart(pnts); GSORoute route = new GSORoute(); //创建路径 for (int i = 0; i < polyLine[0].Count; i++) { route.Add(polyLine[0][i]); } // 设置路径属性 route.CircleRoute = true; //路径是否闭合 route.Speed = 10; //沿线运动速度 route.SpeedAcceleration = 1; //加速度 route.RotateSpeed = 10; //拐弯速度 //加载模型 GSOGeoModel model = new GSOGeoModel(); model.FilePath = _modelPath; //3D模型路径 //创建沿线运动模型要素 GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); dynamicRoute.ActorGeometry = model; //添加模型到沿线运动模型上 dynamicRoute.Route = route; //赋路线 dynamicRoute.Play(); //播放运动 dynamicRoute.TimerInterval = 20; //播放时间间隔 GSOFeature feature = new GSOFeature(); feature.Geometry = dynamicRoute; GSOFeature polylineFeature = new GSOFeature(); polylineFeature.Geometry = polyLine; _glbControl.Globe.MemoryLayer.AddFeature(feature); _glbControl.Globe.MemoryLayer.AddFeature(polylineFeature); _glbControl.Globe.FlyToFeature(polylineFeature); }
// 线 private void btn_Polyline_Click(object sender, System.EventArgs e) { GSOGeoPolyline3D line = new GSOGeoPolyline3D(); //创建线对象 GSOPoint3ds pnts = new GSOPoint3ds(); //创建节点对象 pnts.Add(new GSOPoint3d(120.4, 31.3, 1000)); //把各节点添加到节点对象上 pnts.Add(new GSOPoint3d(120.41, 31.31, 3000)); pnts.Add(new GSOPoint3d(120.42, 31.32, 2000)); pnts.Add(new GSOPoint3d(120.43, 31.30, 2500)); pnts.Add(new GSOPoint3d(120.44, 31.34, 4000)); line.AddPart(pnts); //把节点添加到线上 GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); line.Style = style; AddNewGeoToLayer(line, "线"); }
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 GSOFeature makeLine() { GSOGeoPolyline3D line = new GSOGeoPolyline3D(); //创建线对象 GSOPoint3ds pnts = new GSOPoint3ds(); //创建节点对象 pnts.Add(new GSOPoint3d(116.6, 39.9, 1000)); //把各节点添加到节点对象上 pnts.Add(new GSOPoint3d(116.61, 39.91, 3000)); pnts.Add(new GSOPoint3d(116.62, 39.92, 2000)); pnts.Add(new GSOPoint3d(116.63, 39.90, 2500)); pnts.Add(new GSOPoint3d(116.64, 39.94, 4000)); line.AddPart(pnts); //把节点添加到线上 GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 style.LineColor = Color.FromArgb(150, 0, 255, 0); style.LineWidth = 3; //设置线的宽度为3 style.VertexVisible = true; //显示线的节点 line.Style = style; //把风格添加到线上 //创建几何对象并设置属性 GSOFeature f = new GSOFeature(); f.Geometry = line; //把线对象添加到几何对象上 f.Name = "线 01"; //设置几何对象的名称 f.SetFieldValue("description", "这是线的属性"); //设置几何对象的字段值 //把几何要素添加到内存图层中 globeControl1.Globe.MemoryLayer.AddFeature(f); //下面不属于工程内容,只是飞到点的位置 GSOCameraState cs = new GSOCameraState(); cs.Longitude = 116.62; cs.Latitude = 39.92; cs.Altitude = 9000; globeControl1.Globe.FlyToCameraState(cs); return(f); }
private void AddLine() { GSOGeoPolyline3D line = new GSOGeoPolyline3D(); //创建线对象 GSOPoint3ds pnts = new GSOPoint3ds(); //创建节点对象 pnts.Add(new GSOPoint3d(116.6, 39.9, 1000)); //把各节点添加到节点对象上 pnts.Add(new GSOPoint3d(116.61, 39.91, 3000)); pnts.Add(new GSOPoint3d(116.62, 39.92, 2000)); pnts.Add(new GSOPoint3d(116.63, 39.90, 2500)); pnts.Add(new GSOPoint3d(116.64, 39.94, 4000)); line.AddPart(pnts); //把节点添加到线上 GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 style.LineColor = Color.FromArgb(150, 0, 255, 0); style.LineWidth = 3; //设置线的宽度为3 style.VertexVisible = true; //显示线的节点 line.Style = style; //把风格添加到线上 //创建几何对象并设置属性 GSOFeature lineFeature = new GSOFeature(); lineFeature.Geometry = line; //把线对象添加到几何对象上 lineFeature.Name = "线 01"; //设置几何对象的名称 lineFeature.SetFieldValue("description", "这是线的属性"); //设置几何对象的字段值 lineFeature.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"; double lineLength = line.GetSpaceLength(true, 6378137); Dictionary <string, string> property = new Dictionary <string, string>(); property.Add("长度", (lineLength / 1000).ToString("0.00") + "KM"); lineFeature.Description = lineFeature.Description.Replace("$tablecontent", maketable(property)); //把几何要素添加到内存图层中 globeControl1.Globe.MemoryLayer.AddFeature(lineFeature); }
//应用 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 button2_Click(object sender, EventArgs e) { double dMinLon = 0, dMaxLon = 0, dMinLat = 0, dMaxLat = 0; string strLayerPath = saveFileDialog1.FileName; string path = Application.StartupPath + "\\Resource\\image\\DefaultIcon.png"; if (string.IsNullOrEmpty(saveFileDialog1.FileName)) { MessageBox.Show("请选择存储目录"); return; } globeControl1.Globe.MemoryLayer.SaveAs(strLayerPath); layerTemp = globeControl1.Globe.Layers.Add(strLayerPath); layerTemp.RemoveAllFeature(); GSOGeoPolyline3D polyLine = new GSOGeoPolyline3D(); GSOPoint3ds pois = new GSOPoint3ds(); for (int i = 0; i < listView1.Items.Count; i++) { ListViewItem item = listView1.Items[i]; double lon, lat; if (!double.TryParse(item.SubItems[3].Text.ToString() == "" ? "0" : item.SubItems[3].Text.ToString(), out lon)) { MessageBox.Show("经度参数不合法"); return; } if (!double.TryParse(item.SubItems[4].Text.ToString() == "" ? "0" : item.SubItems[4].Text.ToString(), out lat)) { MessageBox.Show("纬度参数不合法"); return; } if (i == 0) { dMaxLon = lon; dMinLon = lon; dMinLat = lat; dMaxLat = lat; } GSOPoint3d node = new GSOPoint3d(lon, lat, 0); pois.Add(node); string strDescriptionPrefix = "<![CDATA[<!-- <BALLOON><CONTENT_CX>800</CONTENT_CX><CONTENT_CY>600</CONTENT_CY>" + "<CONTENT_TYPE>link</CONTENT_TYPE><SHOW_MODE>balloonex</SHOW_MODE>-->"; string strDescription = strDescriptionPrefix + "file:\\\\" + Application.StartupPath + "\\Resource\\Page\\pic_route.html"; strDescription += "?URL=" + item.SubItems[5].Text.ToString(); //strDescription += "]]>"; AddMarker(item.SubItems[1].Text.ToString(), lon, lat, path, strDescription, layerTemp); if (lon < dMinLon) { dMinLon = lon; } else if (lon > dMaxLon) { dMaxLon = lon; } if (lat < dMinLat) { dMinLat = lat; } else if (lat > dMaxLat) { dMaxLat = lat; } } if (layerTemp == null) { MessageBox.Show("没有生成轨迹的数据"); return; } polyLine.AddPart(pois); GSOFeature feature = new GSOFeature(); feature.Geometry = polyLine; layerTemp.AddFeature(feature);//添加线 layerTemp.SaveAs(strLayerPath); globeControl1.Globe.FlyToFeature(feature); }
//创建管线要素 public void CreatePipeLine() { //创建线要素 GSOGeoPolyline3D line1 = new GSOGeoPolyline3D(); GSOPoint3ds points1 = new GSOPoint3ds(); GSOPoint3d point1 = new GSOPoint3d(120.27191, 31.9864637, 5); GSOPoint3d point2 = new GSOPoint3d(120.271, 31.9864637, 5); points1.Add(point1); points1.Add(point2); line1.AddPart(points1); //设置线高度模式为相对地表 line1.AltitudeMode = EnumAltitudeMode.RelativeToGround; //设置样式 GSOPipeLineStyle3D style = new GSOPipeLineStyle3D(); //管线颜色 style.LineColor = Color.Brown; //管线半径, 单位:米 style.Radius = 1; line1.Style = style; //相对地表抬高半径的距离 line1.MoveZ(style.Radius); //创建要素 _pipeFeature1 = new GSOFeature(); _pipeFeature1.Geometry = line1; //将要素添加到globe中并显示 _glbControl.Globe.MemoryLayer.AddFeature(_pipeFeature1); _pipeFeature2 = new GSOFeature(); GSOGeoPolyline3D line2 = new GSOGeoPolyline3D(); line2.AltitudeMode = EnumAltitudeMode.RelativeToGround; GSOPoint3ds points2 = new GSOPoint3ds(); GSOPoint3d point3 = new GSOPoint3d(120.27191, 31.986, 0); GSOPoint3d point4 = new GSOPoint3d(120.271, 31.986, 0); points2.Add(point3); points2.Add(point4); line2.AddPart(points2); line2.Style = style; line2.MoveZ(style.Radius); _pipeFeature2.Geometry = line2; _glbControl.Globe.MemoryLayer.AddFeature(_pipeFeature1); _glbControl.Globe.MemoryLayer.AddFeature(_pipeFeature2); _glbControl.Globe.FlyToFeature(_pipeFeature1); //添加辅助线 GSOSimpleLineStyle3D lineStyle = new GSOSimpleLineStyle3D() { LineColor = Color.Yellow, LineType = EnumLineType.Dot }; //水平线 GSOPoint3d pointtemp = new GSOPoint3d(point4.X, point4.Y, point2.Z + _radius); GSOGeoPolyline3D lineHor = new GSOGeoPolyline3D(); GSOPoint3ds pointsHor = new GSOPoint3ds(); pointsHor.Add(pointtemp); pointsHor.Add(new GSOPoint3d(point2.X, point2.Y, point2.Z + _radius)); lineHor.AddPart(pointsHor); lineHor.Style = lineStyle; lineHor.AltitudeMode = EnumAltitudeMode.RelativeToGround; double horLength = Math.Round(lineHor.GetSpaceLength(true, 6378137), 3); GSOFeature featureHorLine = new GSOFeature() { Geometry = lineHor }; featureHorLine.Label = CreateLabel(horLength.ToString()); this._glbControl.Globe.MemoryLayer.AddFeature(featureHorLine); //垂直线 GSOGeoPolyline3D lineVer = new GSOGeoPolyline3D(); GSOPoint3ds pointsVer = new GSOPoint3ds(); pointsVer.Add(pointtemp); pointsVer.Add(new GSOPoint3d(point4.X, point4.Y, point4.Z + _radius)); lineVer.AddPart(pointsVer); lineVer.Style = lineStyle; lineVer.AltitudeMode = EnumAltitudeMode.RelativeToGround; double verLength = Math.Round(Math.Abs(point2.Z - point4.Z)); GSOFeature featureVerLine = new GSOFeature() { Geometry = lineVer }; featureVerLine.Label = CreateLabel(verLength.ToString()); this._glbControl.Globe.MemoryLayer.AddFeature(featureVerLine); }
private void 管线间距分析ToolStripMenuItem_Click(object sender, EventArgs e) { if (globeControl1.Globe.SelObjectCount < 2) { MessageBox.Show("请选中至少两个管线!!"); return; } if (disFeature.ID != 0) { globeControl1.Globe.MemoryLayer.RemoveFeatureByID(disFeature.ID); } if (featureDis.ID != 0) { globeControl1.Globe.MemoryLayer.RemoveFeatureByID(featureDis.ID); } GSOLayer reslayer; globeControl1.Globe.GetSelectObject(0, out m_DisAnalysisFirstFeature, out reslayer); globeControl1.Globe.GetSelectObject(1, out m_DisAnalysisSecondFeature, out reslayer); if (m_DisAnalysisSecondFeature != null && m_DisAnalysisSecondFeature != null) { GSOGeoPolyline3D line1 = m_DisAnalysisFirstFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolyline3D line2 = m_DisAnalysisSecondFeature.Geometry as GSOGeoPolyline3D; if (line1 == null || line2 == null) { MessageBox.Show("请选择管线!!"); return; } GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D; GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D; if (pipeStyle1 == null || pipeStyle2 == null) { MessageBox.Show("请选择管线!!"); return; } GSOPoint3d pntIntersect1; GSOPoint3d pntIntersect2; double dHonLen; double dVerLen; double dNoIntersectStartRatio = 0; // 计算两条线的距离和交点,若果失败返回-1 // 若在同一直线上,并且有交点,返回0 // 若不在同一平面,返回最近两点的距离,并且计算最近两点 double dDist = globeControl1.Globe.Analysis3D.ComputeTwoGeoPolylineDistance(line1, line2, out pntIntersect1, out pntIntersect2, out dHonLen, out dVerLen, false, false, dNoIntersectStartRatio); if (dDist > -1) { if (dDist == 0) { MessageBox.Show("管线在同一水平面,距离为0"); return; } else { dDist = dDist - pipeStyle1.Radius - pipeStyle2.Radius; GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); GSOPoint3ds point3ds = new GSOPoint3ds(); point3ds.Add(pntIntersect1); point3ds.Add(pntIntersect2); disline.AddPart(point3ds); GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 style.LineColor = Color.GreenYellow; style.LineWidth = 3; //设置线的宽度为3 style.VertexVisible = true; //显示线的节点 disline.Style = style; //把风格添加到线上 disline.AltitudeMode = EnumAltitudeMode.Absolute; disFeature.Geometry = disline; GSOGeoMarker markerDis = new GSOGeoMarker(); markerDis.X = pntIntersect1.X; markerDis.Y = pntIntersect1.Y; markerDis.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; markerDis.Text = dDist.ToString().Substring(0, dDist.ToString().IndexOf(".") + 3) + "米"; markerDis.AltitudeMode = EnumAltitudeMode.Absolute; GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); GSOTextStyle styleText = new GSOTextStyle(); styleText.IsSizeFixed = true; styleText.ForeColor = Color.White; styleText.FontSize = 20; styleMarker.TextStyle = styleText; markerDis.Style = styleMarker; featureDis.Geometry = markerDis; layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); layerTemp.AddFeature(featureDis); layerTemp.AddFeature(disFeature); globeControl1.Refresh(); } } else { MessageBox.Show("没有交点!!"); return; } } }
//去除管线对象中多余的节点 private void 检查管线节点ToolStripMenuItem_Click(object sender, EventArgs e) { GSOLayer layer = globeControl1.Globe.DestLayerFeatureAdd; if (layer != null && layer.ID == globeControl1.Globe.MemoryLayer.ID) { MessageBox.Show("请先设置目标图层!", "提示"); return; } FrmCheckPipelinePoint frm = new FrmCheckPipelinePoint(); if (frm.ShowDialog() == DialogResult.OK && layer.GetAllFeatures().Length > 0) { double distance = frm.pointDistance; 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; //获取管线中所有节点 GSOPoint3ds allPoint = new GSOPoint3ds(); for (int j = 0; j < line.PartCount; j++) { GSOPoint3ds points = line[j]; if (points != null) { for (int m = 0; m < points.Count; m++) { GSOPoint3d point = points[m]; allPoint.Add(point); } } } if (allPoint.Count > 2) { for (int j = 0; j < allPoint.Count - 1; j++) { GSOPoint3d point = allPoint[j]; GSOPoint3d point1 = allPoint[j + 1]; GSOPoint3ds points = new GSOPoint3ds(); points.Add(point); points.Add(point1); GSOGeoPolyline3D newLine = new GSOGeoPolyline3D(); newLine.AddPart(points); double length = newLine.GetSpaceLength(false, 6378137.0); if (length < distance) { if (j == allPoint.Count - 2) { allPoint.Remove(j); } else { allPoint.Remove(j + 1); } if (allPoint.Count < 3) { break; } j--; } } } line.Clear(); line.AddPart(allPoint); feature.Geometry = line; globeControl1.Refresh(); } } } MessageBox.Show("检查完毕!", "提示"); }
private GSOFeatures getFeatureByPolygon(GSOLayer layer,GSOFeatures features, GSOPoint3d point, double allowValue) { if (layer == null || point == null || allowValue <= 0) { return null; } GSOGeoPolyline3D bufferLine = new GSOGeoPolyline3D(); GSOPoint3ds points = new GSOPoint3ds(); points.Add(point); GSOPoint3d newPoint = new GSOPoint3d(); newPoint.X = point.X + 0.00001; newPoint.Y = point.Y; newPoint.Z = point.Z; points.Add(newPoint); bufferLine.AddPart(points); GSOGeoPolygon3D polygon = bufferLine.CreateBuffer(allowValue, true, 12, false, false); layer.RemoveAllFeature(); layer.AddFeatures(features); GSOFeatures featuresInPolygon = layer.FindFeaturesInPolygon(polygon, false); return featuresInPolygon; }
private void ConnexityAnalysis() { GSODataset curCAYDataset = m_ConnexityAnalysisFirstLayer.Dataset; string srName = curCAYDataset.Name; GSONetworkDataset curCAYNDataset = curCAYDataset.DataSource.GetDatasetByName(srName + "Network") as GSONetworkDataset; if (curCAYNDataset == null) { MessageBox.Show("该图层没有创建网络拓扑,请先创建网络拓扑信息再进行分析!", "提示"); return; } int[] arryResID; curCAYNDataset.ConnexityAnalysis(m_ConnexityAnalysisFirstFeature.ID, m_ConnexityAnaylsisSecondFeature.ID, out arryResID, false, true); m_ConnexityAnalyResFeatures = m_ConnexityAnalysisFirstLayer.GetFeaturesByIDs(arryResID); if (m_ConnexityAnalyResFeatures == null || m_ConnexityAnalyResFeatures.Length < 1) { String strLine1 = "管线:" + m_ConnexityAnalysisFirstFeature.ID; String strLine2 = "管线:" + m_ConnexityAnaylsisSecondFeature.ID; MessageBox.Show(strLine1 + " 与 " + strLine2 + " 不连通", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { int nCount = m_ConnexityAnalyResFeatures.Length; GSOGeoPolyline3D effectLine = new GSOGeoPolyline3D(); GSOPoint3ds effectPart = new GSOPoint3ds(); for (int i = 0; i < nCount; i++) { m_ConnexityAnalyResFeatures[i].HighLight = true; GSOGeoPolyline3D geoline = m_ConnexityAnalyResFeatures[i].Geometry as GSOGeoPolyline3D; if (geoline != null) { //管线显示流动效果 for (int j = 0; j < geoline.PartCount; j++) { effectLine.AddPart(geoline[j]); } } } effectLine.SmoothToSpline(); GSOFeature feature = new GSOFeature(); feature.Geometry = effectLine; if (feature.Geometry.Style == null) { feature.Geometry.Style = new GSOSimpleLineStyle3D(); } feature.Geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround; ((GSOStyle3D)feature.Geometry.Style).UsingBlur = true; globeControl1.Globe.MemoryLayer.AddFeature(feature); GSOAniFeature featureAnimation = new GSOAniFeature();//动画的类型--要素动画 featureAnimation.Feature = feature; //动画的关联对象 GSOGeoMarker marker = new GSOGeoMarker(0, 0, 0,""); GSOMarkerStyle3D markerStyle = new GSOMarkerStyle3D(); markerStyle.IconPath = Application.StartupPath + "/Resource/image/star4.bmp"; marker.Style = markerStyle; marker.AltitudeMode = EnumAltitudeMode.RelativeToGround; GSOFeature markerFeature = new GSOFeature(); markerFeature.Geometry = marker; GSOAniEffectLineGrow effect = new GSOAniEffectLineGrow();//动画效果-线增长动画 effect.StartValue = 0; effect.EndValue = 1; effect.FrameCount = 1200; effect.RepeatCount = 1; effect.IsSmooth = false; effect.ActorFeature = markerFeature; GSOAniKeyFrame keyFream = new GSOAniKeyFrame(); //关键帧 keyFream.Frame = 0; keyFream.AddEffect(effect); //给关键帧添加动画效果 GSOAniObjTimeLine timeLine = new GSOAniObjTimeLine();//动画对象 timeLine.Name = "线增长动画对象"; timeLine.AniObject = featureAnimation; //动画对象的动画类型 timeLine.AddKeyFrame(keyFream); //给动画对象添加关键帧 GSOAnimationPage page = new GSOAnimationPage(); //动画 page.FPS = 60; //动画--帧率 page.FrameCount = 20 * 60; //动画时长 * 帧率 //动画--帧总数 page.Name = "线增长动画"; page.AddObjTimeLine(timeLine); //给动画添加动画对象 globeControl1.Globe.AnimationPages.Add(page); globeControl1.Globe.AnimationPages.GetAt(globeControl1.Globe.AnimationPages.Length - 1).Play(); globeControl1.Refresh(); } }