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(); } }
/// <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 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(); } }
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); }
//加载shp文件并显示管线 private void btn_LoadLayer_Click(object sender, EventArgs e) { if (_layerAdded) { return; } _shpLayer = _glbControl.Globe.Layers.Add(_testShpPath); _shpLayer.Editable = true; //设置样式 GSOPipeLineStyle3D style = new GSOPipeLineStyle3D(); style.LineColor = Color.Green; //管线半径 style.Radius = _radius; //获得默认图层的要素 var features = _shpLayer.GetAllFeatures(); //遍历要素 for (int i = 0; i < features.Length; i++) { GSOGeoPolyline3D geometry = features[i].Geometry as GSOGeoPolyline3D; geometry.Style = style; //将高度抬高到管径高度 geometry.MoveZ(style.Radius); //重要,要将高度模式设置成相对地表,如果为依附地面则无渲染效果 geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround; } _glbControl.Refresh(); FlyToLayer(_shpLayer); }
public FrmAnalysisProfileBaseLine(GSOGlobeControl _globeControl1, GSOGeoPolyline3D _geopolyline) { InitializeComponent(); globeControl1 = _globeControl1; m_geopolyline = _geopolyline; }
public FrmAnalysisHengDuanMian(ArrayList arraylistP, ArrayList arraylistF, GSOGeoPolyline3D _line, GSOGlobeControl _ctl) { InitializeComponent(); this.listPoint = arraylistP; this.listFeat = arraylistF; line = _line; globeControl1 = _ctl; }
public FrmAnalysisHengDuanMian(ArrayList arraylistP, ArrayList arraylistF, GSOGeoPolyline3D _line,GSOGlobeControl _ctl) { InitializeComponent(); this.listPoint = arraylistP; this.listFeat = arraylistF; line = _line; globeControl1 = _ctl; }
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(); } }
private GSOGeoPolyline3D CreatePipeRect(GSOGeoPolyline3D line, double width, double height) { GSOGeoPolyline3D cloneline = line.Clone() as GSOGeoPolyline3D; GSOExtendSectionLineStyle3D style = createRectStyle(width, height); if (style == null) { return(null); } cloneline.Style = style; return(cloneline); }
/// <summary> /// FlyEyeAlongWithLine /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line3d = feature.Geometry as GSOGeoPolyline3D; double dHeightAboveLine = 100; //高于线 double dHeading = 0; //视角夹角 double dTilt = 80; //水平夹角 globeControl1.Globe.FlyEyeAlongWithLine(line3d, dHeightAboveLine, 0, true, 0, false); } }
private void RefreshGlobe(GSOSimpleLineStyle3D simpleLineStyle3D) { GSOGeoPolyline3D line = mfeature.Geometry as GSOGeoPolyline3D; line.Style = simpleLineStyle3D; mfeature.Geometry = line; //mfeature.Geometry.Style = simpleLineStyle3D; if (m_GlobeControl != null) { m_GlobeControl.Globe.Refresh(); } }
// 沿线运动对象 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 GSOGeoPolyline3D Coord2LatLon_Line(GSOGeoPolyline3D line) { GSOGeoPolyline3D newline = line.Clone() as GSOGeoPolyline3D; for (int i = 0; i < newline[0].Count; i++) { GSOPoint3d pt = newline[0][i]; GSOPoint2d pt2d = new GSOPoint2d(pt.X, pt.Y); GSOPoint2d pt2dnew = Coord2LatLon(pt2d); GSOPoint3d ptnew = new GSOPoint3d(pt2dnew.X, pt2dnew.Y, pt.Z); newline[0][i] = ptnew; } return(newline); }
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); }
/// <summary> /// FlyAlongWithLine /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line3d = feature.Geometry as GSOGeoPolyline3D; globeControl1.Globe.FlyAlongLineRotateSpeed = 2000; //过弯速度 globeControl1.Globe.FlyAlongLineSpeed = 500; //飞行速度 //globeControl1.Globe.FlyToPointSpeed = 5000; //飞到点速度 double dHeightAboveLine = 100; //高于线 double dHeading = 0; //视角夹角 double dTilt = 80; //水平夹角 globeControl1.Globe.FlyAlongWithLine(line3d, dHeightAboveLine, dHeading, dTilt); } }
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_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 GSOPoint3ds getAllPointInPipeline(GSOGeoPolyline3D pipeline) { GSOPoint3ds points = new GSOPoint3ds(); if (pipeline != null) { for (int i = 0; i < pipeline.PartCount; i++) { GSOPoint3ds pnts = pipeline[i]; for (int j = 0; j < pnts.Count; j++) { GSOPoint3d pt = pnts[j]; points.Add(pt); } } } return(points); }
private void buttonOk_Click(object sender, EventArgs e) { string caption = comboBoxLayerNames.Text; if (caption == "") { return; } GSOLayer layer = m_globeControl.Globe.Layers.GetLayerByCaption(caption); GSOFeatures features = layer.GetAllFeatures(); for (int i = 0; i < features.Length; i++) { GSOFeature feature = features[i]; GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; if (line == null) { continue; } GSOPipeLineStyle3D pipeLineStyle = line.Style as GSOPipeLineStyle3D; int mode = 0; // 管线暂不支持依地模式 if (line.AltitudeMode == EnumAltitudeMode.ClampToGround) { mode = 1; line.AltitudeMode = EnumAltitudeMode.RelativeToGround; } if (pipeLineStyle == null) { pipeLineStyle = new GSOPipeLineStyle3D(); } pipeLineStyle.LineColor = buttonPipelineColor.BackColor; line.Style = pipeLineStyle; if (mode == 1) { line.AltitudeMode = EnumAltitudeMode.ClampToGround; } } m_globeControl.Refresh(); this.Close(); }
public static FrmAnalysisHengDuanMian GetForm(ArrayList arraylistP, ArrayList arraylistF, GSOGeoPolyline3D _line, GSOGlobeControl _ctl) { if (allPipelineAnalysis == null) { allPipelineAnalysis = new FrmAnalysisHengDuanMian(arraylistP, arraylistF, _line,_ctl); } else { allPipelineAnalysis.listPoint = arraylistP; allPipelineAnalysis.listFeat = arraylistF; allPipelineAnalysis.line = _line; allPipelineAnalysis.globeControl1 = _ctl; list = new ArrayList(); //table = new DataTable(); //showTable = new DataTable(); } return allPipelineAnalysis; }
private void one2Multi(GSOGeoPolyline3D line, int num_width, int num_height, double interval, GSOPipeLineStyle3D style, GSOFeatureDataset layer, string name, GSOFeature oldfeat) { 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 = layer.CreateFeature(); feat.Geometry = templine; feat.Geometry.Style = style; feat.Name = name; SetFields(oldfeat, feat); layer.AddFeature(feat); } } }
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 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 (mouseClickInfo == "剖面分析") { GSOFeature feature = globeControl1.Globe.SelectedObject; if (feature == null || feature.Geometry == null || feature.Geometry.Type != EnumGeometryType.GeoPolyline3D) { MessageBox.Show("请选择一条线"); return; } globeControl1.Globe.Action = EnumAction3D.ActionNull; GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; FrmAnalysisProfileBaseLine frm = new FrmAnalysisProfileBaseLine(globeControl1, line); 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 GSOGeoPolyline3D CreatePipeRect(GSOGeoPolyline3D line, double width, double height) { GSOGeoPolyline3D cloneline = line.Clone() as GSOGeoPolyline3D; GSOExtendSectionLineStyle3D style = createRectStyle(width, height); if (style == null) { return null; } cloneline.Style = style; return cloneline; }
public static FrmAnalysisHengDuanMian GetForm(ArrayList arraylistP, ArrayList arraylistF, GSOGeoPolyline3D _line, GSOGlobeControl _ctl) { if (allPipelineAnalysis == null) { allPipelineAnalysis = new FrmAnalysisHengDuanMian(arraylistP, arraylistF, _line, _ctl); } else { allPipelineAnalysis.listPoint = arraylistP; allPipelineAnalysis.listFeat = arraylistF; allPipelineAnalysis.line = _line; allPipelineAnalysis.globeControl1 = _ctl; list = new ArrayList(); //table = new DataTable(); //showTable = new DataTable(); } return(allPipelineAnalysis); }
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 检查管线节点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 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 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(); } }
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(); for (int j = 0; j < features.Length; j++) { GSOFeature f = features[j]; GSOFeature newFeature = new GSOFeature(); GSOPipeLineStyle3D style = new GSOPipeLineStyle3D(); style.LineColor = Color.FromArgb(Convert.ToByte(numericUpDownLineOpaque.Value), btnPipelineColor.BackColor); double radius = f.GetFieldAsDouble(cmbRadius.SelectedIndex) / 1000; // 单位 string eventid = f.GetFieldAsString(cmbID.SelectedItem.ToString()); style.Radius = radius; style.CornerSliceAngle = Convert.ToDouble(textBoxCornerSliceAngle.Text); f.Geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround; GSOGeoPolyline3D line = f.Geometry as GSOGeoPolyline3D; if (line == null) { return; } double deep1 = f.GetFieldAsDouble(cmbFrom.SelectedItem.ToString()); double deep2 = f.GetFieldAsDouble(cmbTo.SelectedItem.ToString()); if (chkDeep.Checked) { deep1 = 0 - deep1; deep2 = 0 - deep2; } if (cmbReference.SelectedIndex == 0) //管底 { deep1 = deep1 + radius; deep2 = deep2 + radius; } else if (cmbReference.SelectedIndex == 1) //管顶 { deep1 = deep1 - radius; deep2 = deep2 - radius; } for (int n = 0; n < line[0].Count; n++) { GSOPoint3d pt3d = line[0][n]; int pointcount = line[0].Count; double radio = Math.Sqrt(Math.Pow(pt3d.Y - line[0][0].Y, 2) + Math.Pow(pt3d.X - line[0][0].X, 2)) / Math.Sqrt(Math.Pow(line[0][pointcount - 1].Y - line[0][0].Y, 2) + Math.Pow(line[0][pointcount - 1].X - line[0][0].X, 2)); pt3d.Z = deep1 + (deep2 - deep1) * radio; line[0][n] = pt3d; } newFeature.Geometry = line; // f.Geometry; newFeature.Geometry.Style = style; newFeature.Name = eventid; //newFeature.CustomID = f.ID; layer.AddFeature(newFeature); } } ctl.Refresh(); layer.Save(); ctl.Globe.Layers.Remove(layer); this.Close(); } catch (Exception ex) { Log.PublishTxt(ex); MessageBox.Show(ex.Message); } }
private void buttonOK_Click(object sender, EventArgs e) { string layerPath = textBoxLayerPath.Text.Trim(); if (layerPath == "") { MessageBox.Show("请选择目标文件!", "提示"); return; } string featureMinLength = textBoxFeatureMinLength.Text.Trim(); double minLength = 0; if (!double.TryParse(featureMinLength, out minLength)) { MessageBox.Show("请输入正确的最小长度值!", "提示"); return; } string featureMaxLength = textBoxFeatureMaxLength.Text.Trim(); double maxLength = 0; if (!double.TryParse(featureMaxLength, out maxLength)) { MessageBox.Show("请输入正确的最大长度值!", "提示"); return; } string featureCount = textBoxFeatureCount.Text.Trim(); int count = 0; if (checkBoxFeatureCount.Checked) { if (!int.TryParse(featureCount, out count)) { MessageBox.Show("请输入正确的要素个数值!", "提示"); return; } } GSOLayer layer = globeControl1.Globe.Layers.Add(layerPath); if (layer != null) { do { for (int i = layer.GetAllFeatures().Length - 1; i >= 0; i--) { GSOFeature feature = layer.GetAt(i); if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; double length = line.GetSpaceLength(false, 6378137.0); if (length >= minLength && length <= maxLength) { feature.Delete(); } } //else //{ // feature.Delete(); //} } maxLength++; }while (checkBoxFeatureCount.Checked && layer.GetAllFeatures().Length > 30000); layer.SaveAs(Path.GetDirectoryName(textBoxLayerPath.Text.Trim()) + "/" + layer.Caption + "-处理后" + Path.GetExtension(textBoxLayerPath.Text.Trim())); MessageBox.Show("删除成功!", "提示"); } }
private void btnApply_Click(object sender, EventArgs e) { GSOLayer layer = ctl.Globe.Layers.GetLayerByCaption(cmbLayers.Text.Trim()); if (layer == null) { MessageBox.Show("请选择图层", "提示"); return; } if (layer.Type != EnumLayerType.FeatureLayer) { MessageBox.Show("当前选中的图层不是模型图层!", "提示"); return; } GSOFeatureLayer flayer = layer as GSOFeatureLayer; GSOFeatures features = new GSOFeatures(); if (radioButtonElevateAllFeature.Checked == true) { features = flayer.GetAllFeatures(); } else if (radioButtonElevatePartFeature.Checked == true) { string fieldName = comboBoxFieldNames.Text.Trim(); if (fieldName == "") { MessageBox.Show("请选择字段名称!", "提示"); return; } if (listViewFieldValues.SelectedItems.Count <= 0) { MessageBox.Show("请选中一个字段值!", "提示"); return; } string fieldValue = listViewFieldValues.SelectedItems[0].Text.Trim(); features = flayer.GetFeatureByFieldValue(fieldName, fieldValue, true); } string elevateHeight = txtHeight.Text.Trim(); double height = 0; if (txtHeight.Text == "" || double.TryParse(elevateHeight, out height) == false) { MessageBox.Show("请输入正确的调整高度", "提示"); return; } for (int i = 0; i < features.Length; i++) { GSOFeature feature = features[i]; if (feature is GSOFeatureFolder) { MoveEachFeature(feature as GSOFeatureFolder, height); } else if (feature.Geometry is GSOGeoModel) { GSOGeoModel model = feature.Geometry as GSOGeoModel; if (model != null) { GSOPoint3d pt = model.Position; pt.Z += height; model.Position = pt; } } else if (feature.Geometry is GSOGeoPolyline3D) { GSOGeoPolyline3D templine = feature.Geometry as GSOGeoPolyline3D; if (templine != null) { templine.MoveZ(height); feature.Geometry = templine; } } } ctl.Refresh(); MessageBox.Show("抬升成功", "提示"); }
private GSOGeoPolyline3D LatLon2Coord_Line(GSOGeoPolyline3D line) { GSOGeoPolyline3D newline = line.Clone() as GSOGeoPolyline3D; for (int i = 0; i < newline[0].Count; i++) { GSOPoint3d pt = newline[0][i]; GSOPoint2d pt2d = new GSOPoint2d(pt.X, pt.Y); GSOPoint2d pt2dnew = LatLon2Coord(pt2d); GSOPoint3d ptnew = new GSOPoint3d(pt2dnew.X, pt2dnew.Y, pt.Z); newline[0][i] = ptnew; } return newline; }
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; }
//应用 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 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); } } }
private GSOPoint3ds getAllPointInPipeline(GSOGeoPolyline3D pipeline) { GSOPoint3ds points = new GSOPoint3ds(); if (pipeline != null) { for (int i = 0; i < pipeline.PartCount; i++) { GSOPoint3ds pnts = pipeline[i]; for (int j = 0; j < pnts.Count; j++) { GSOPoint3d pt = pnts[j]; points.Add(pt); } } } return points; }