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 buttonAnalyse_Click(object sender, EventArgs e) { //判断球和分析线不为空 if (m_geopolyline != null && globeControl1.Globe != null) { //获取线的地表长度 输入:半径 m_dSphereLength = m_geopolyline.GetSphereLength(6378137.0); //获取线的空间长度 输入: 是否忽略Z值 ,半径 m_dSpaceLength = m_geopolyline.GetSpaceLength(false, 6378137.0); //获取地标距离 输入:分析线,false,0 m_dGroundLength = globeControl1.Globe.Analysis3D.GetGroundLength(m_geopolyline, false, 0); //采样间距 float jianJu = (float)textBoxJianJu.Value; //采样数量 int pointCount = (int)(m_dSphereLength / jianJu); GSOPoint3d pntMax, pntMin, pntStart, pntEnd; GSOPoint3ds pnt3ds; double dLineLength; //获取分析结果 输入:分析线,采样数量 //输出:点集合,线长度,最大点,最小点,开始点,结束点 globeControl1.Globe.Analysis3D.ProfileAnalyse(m_geopolyline, pointCount, out pnt3ds, out dLineLength, out pntMax, out pntMin, out pntStart, out pntEnd); //开始根据数据整理成到DataGridView中 try { m_pnt3ds = pnt3ds; m_pntMax = pntMax; m_pntMin = pntMin; m_pntStart = pntStart; m_pntEnd = pntEnd; m_dXTotalLength = dLineLength; dataGridViewPoints.Rows.Clear(); int index = 1; for (int i = 0; i < m_pnt3ds.Count; i++) { GSOPoint3d pt = m_pnt3ds[i]; if (pt != null) { int rowIndex = dataGridViewPoints.Rows.Add(); dataGridViewPoints.Rows[rowIndex].Cells[0].Value = index.ToString(); dataGridViewPoints.Rows[rowIndex].Cells[1].Value = pt.X.ToString("0.0000000"); dataGridViewPoints.Rows[rowIndex].Cells[2].Value = pt.Y.ToString("0.0000000"); dataGridViewPoints.Rows[rowIndex].Cells[3].Value = pt.Z.ToString("0.00"); index++; } } //设置文字 SetLableText(); //画出图 DrawCurveGraph(); } catch (Exception ext) { MessageBox.Show("数据异常,参考信息:" + ext.Message, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void MoveEachFeature(GSOFeatureFolder folder, double height) { GSOFeatures features = folder.Features; for (int i = 0; i < features.Length; i++) { GSOFeature feature = features[i]; if (feature is GSOFeatureFolder) { MoveEachFeature(feature as GSOFeatureFolder, height); } else { GSOGeoModel model = feature.Geometry as GSOGeoModel; if (model != null) { GSOPoint3d pt = model.Position; if (model.AltitudeMode == EnumAltitudeMode.ClampToGround) { model.AltitudeMode = EnumAltitudeMode.RelativeToGround; } pt.Z += height; model.Position = pt; } } } }
/// <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 buttonAnalyse_Click(object sender, EventArgs e) { if (m_geopolyline != null && m_globe != null) { checkBoxSameScale.Enabled = true; checkBoxXmin.Enabled = true; checkBoxYMin.Enabled = true; GSOPoint3d pntMax, pntMin, pntStart, pntEnd; GSOPoint3ds pnt3ds; double dLineLength; m_globe.Analysis3D.ProfileAnalyse(m_geopolyline, 100, out pnt3ds, out dLineLength, out pntMax, out pntMin, out pntStart, out pntEnd); m_pnt3ds = pnt3ds; m_pntMax = pntMax; m_pntMin = pntMin; m_pntStart = pntStart; m_pntEnd = pntEnd; m_dXTotalLength = dLineLength; m_dSphereLength = m_geopolyline.GetSphereLength(6378137.0); m_dSpaceLength = m_geopolyline.GetSpaceLength(false, 6378137.0); m_dGroundLength = m_globe.Analysis3D.GetGroundLength(m_geopolyline, false, 0); SetLableText(); DrawCurveGraph(); } }
private void txtNewChange() { decimal x; decimal y; if (txtNewLon.Text.Trim() == "") { txtNewLon.Text = 0 + ""; } bool bl = decimal.TryParse(txtNewLon.Text.Trim(), out x); if (!bl) { MessageBox.Show("数据不符合要求!"); return; } if (txtNewLat.Text.Trim() == "") { txtNewLat.Text = 0 + ""; } bl = decimal.TryParse(txtNewLat.Text.Trim(), out y); if (!bl) { MessageBox.Show("数据不符合要求!"); return; } GSOPoint3d point = ctl.Globe.ScreenToScene((int)Math.Round(x), (int)Math.Round(y)); if (endFeat == null || endFeat.IsDeleted) { endFeat = new GSOFeature(); GSOGeoMarker p = new GSOGeoMarker(); GSOMarkerStyle3D style = new GSOMarkerStyle3D(); style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png"; p.Style = style; p.AltitudeMode = EnumAltitudeMode.ClampToGround; endFeat.Name = "目标点"; endFeat.CustomID = 001; p.X = (double)Math.Round(x); p.Y = (double)Math.Round(y); p.Z = 0; endFeat.Geometry = p; endFeat = ctl.Globe.MemoryLayer.AddFeature(endFeat); } else { GSOGeoPoint3D endpoint = endFeat.Geometry as GSOGeoPoint3D; if (endpoint != null) { endpoint.X = (double)Math.Round(x); endpoint.Y = (double)Math.Round(y); endpoint.Z = 0; } } ctl.Refresh(); }
private void btnExportCAD_Click(object sender, EventArgs e) { globeControl1.Globe.MemoryLayer.RemoveAllFeature(); int id = GeoScene.Data.GSOProjectManager.AddProject("+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=555484.8092 +y_0=-4114948.631 +ellps=krass +units=m +no_defs"); for (int i = 0; i < listPoint.Count; i++) { GSOPoint3d geoPoint = (GSOPoint3d)listPoint[i]; GSOFeature feature = listFeat[i] as GSOFeature; if (feature != null) { if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOPipeLineStyle3D style = feature.Geometry.Style as GSOPipeLineStyle3D; double r = style.Radius; //ExportCAD(double.Parse(sortIndex[i, 0].ToString()), geoPoint.Z, r); Export(geoPoint, r); } } } GSOLayer layer = globeControl1.Globe.MemoryLayer; layer.Dataset.ImportProjectionRefFromProj4("+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=555484.8092 +y_0=-4114948.631 +ellps=krass +units=m +no_defs"); SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "*.dxf|*.dxf"; if (dlg.ShowDialog() == DialogResult.OK) { layer.SaveAs(dlg.FileName); globeControl1.Globe.MemoryLayer.RemoveAllFeature(); MessageBox.Show("导出CAD完成!", "提示"); } }
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 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 btn_Model_Click(object sender, EventArgs e) { GSOGeoModel model = new GSOGeoModel(); //创建模型 GSOPoint3d pt = new GSOPoint3d(); //创建点 pt.X = 120; pt.Y = 30; pt.Z = 0; GSOModelPointStyle3D style = new GSOModelPointStyle3D(); //创建模型的风格 model.Style = style; //设置模型 model.FilePath = _modelPath; model.Position = pt; model.AltitudeMode = EnumAltitudeMode.ClampToGround; //把几何体放到地面上 GSOFeature f = new GSOFeature(); //创建几何要素 f.Geometry = model; f.Name = "模型 01"; f.Description = "模型 01"; //设置feature description的值,这个值将在tooltip上显示 //把几何要素添加到内存图层中 GSOFeature newFeature = _glbControl.Globe.MemoryLayer.AddFeature(f); _glbControl.Globe.FlyToFeature(f); //飞行到模型所在的位置 _glbControl.Refresh(); //刷新场景 }
/// <summary> /// 创建模型 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddModel_Click(object sender, EventArgs e) { GSOGeoModel model = new GSOGeoModel(); //创建模型 GSOPoint3d pt = new GSOPoint3d(); //创建点 pt.X = 116.6; pt.Y = 39.9; pt.Z = 0; GSOModelPointStyle3D style = new GSOModelPointStyle3D(); //创建模型的风格 model.Style = style; //模型可以是3ds、obj、gse、gsez格式的三维模型 //模型所在路径,用户可根据实际情况进行设置 string filepath = Application.StartupPath + "\\Model\\坦克.3ds"; //设置模型 model.FilePath = filepath; model.Position = pt; model.AltitudeMode = EnumAltitudeMode.ClampToGround; //把几何体放到地面上 GSOFeature f = new GSOFeature(); //创建几何要素 f.Geometry = model; f.Name = "模型 01"; f.Description = "模型 01"; //设置feature description的值,这个值将在tooltip上显示 //把几何要素添加到内存图层中 globeControl1.Globe.MemoryLayer.AddFeature(f); //飞行到模型所在的位置 globeControl1.Globe.FlyToFeature(f); }
/// <summary> /// 鼠标移动的时候 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GlobeControl1OnMouseMove(object sender, MouseEventArgs e) { //3D可视域分析 { if (bViewshed3DAnalysisCheck && bViewshed3DAnalysising) { //如果是第一次分析 if (curViewshed3DAnalysisOther == null) { GSOLayer resLayer = null; GSOPoint3d resIntersectPoint; globeControl1.Globe.HitTest(e.X, e.Y, out resLayer, out resIntersectPoint, false, true, 0); pntDistDirPoint = resIntersectPoint; curViewshed3DAnalysis.SetDistDirByPoint(resIntersectPoint); } //如果是其他分析 else { GSOLayer resLayer = null; GSOPoint3d resIntersectPoint; globeControl1.Globe.HitTest(e.X, e.Y, out resLayer, out resIntersectPoint, false, true, 0); pntDistDirPoint = resIntersectPoint; curViewshed3DAnalysisOther.SetDistDirByPoint(resIntersectPoint); } } } }
private void AddModel() { GSOGeoModel model = new GSOGeoModel(); //创建模型 GSOPoint3d pt = new GSOPoint3d(); //创建点 pt.X = 116.6; pt.Y = 39.9; pt.Z = 0; //模型可以是3ds、obj、gse、gsez格式的三维模型 //模型所在路径,用户可根据实际情况进行设置 string filepath = Application.StartupPath + "\\Model\\坦克.3ds"; //设置模型 model.FilePath = filepath; model.Position = pt; model.AltitudeMode = EnumAltitudeMode.ClampToGround; //把几何体放到地面上 GSOFeature feaf = new GSOFeature(); //创建几何要素 feaf.Geometry = model; feaf.Name = "模型 01"; feaf.Description = "模型 01"; //设置feature description的值,这个值将在tooltip上显示 //把几何要素添加到内存图层中 globeControl1.Globe.MemoryLayer.AddFeature(feaf); }
private void 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 flyToFeature(GSOFeature feature) { if (null == _glbControl || null == feature || null == feature.Geometry || null == feature.Geometry.Bounds) { return; } var bounds = feature.Geometry.Bounds; if (bounds.Center == null || bounds.Width == 0.0 || bounds.Height == 0.0) { _glbControl.Globe.FlyToFeature(feature); return; } //获取图层中心点 GSOPoint3d pntPostion = new GSOPoint3d(); pntPostion.X = bounds.Center.X; pntPostion.Y = bounds.Center.Y; //获取图层最大边 double dMaxGeoLen = Math.Max(bounds.Width, bounds.Height); //判断视角高度 double dSize = dMaxGeoLen * Math.PI * 6378137 / 90; pntPostion.Z = dSize > 20000000 ? dSize / 4 : dSize; _glbControl.Globe.FlyToPosition(pntPostion, EnumAltitudeMode.RelativeToGround); }
private void buttonOk_Click(object sender, EventArgs e) { if (light!=null) { light.LightOn = (cbStatus.SelectedIndex == 0); } switch (cbMode.SelectedIndex) { case 0: light.LightMode = EnumLightMode.Default; break; case 1: light.LightMode=EnumLightMode.Object; break; case 2: light.LightMode = EnumLightMode.Eye; break; case 3: light.LightMode = EnumLightMode.World; break; case 4: light.LightMode = EnumLightMode.Sun; break; default: light.LightMode = EnumLightMode.Default; break; } switch (cbType.SelectedIndex) { case 0: light.LightType=EnumLightType.Parallel; break; case 1: light.LightType = EnumLightType.Point; break; case 2: light.LightType = EnumLightType.Spot; break; default: light.LightType = EnumLightType.Parallel; break; } GSOPoint3d pos=new GSOPoint3d(); pos.X = Convert.ToDouble(tbPosX.Text); pos.Y = Convert.ToDouble(tbPosY.Text); pos.Z = Convert.ToDouble(tbPosZ.Text); light.Position = pos; light.Ambient = pbAmbient.BackColor; light.Diffuse= pbDiffuse.BackColor; light.Specular = pbSpecular.BackColor; globeControl.Globe.SceneAmbient= pbGlobalAmbient.BackColor; globeControl.Globe.ModelUseLighting = cbModelUseLighting.Checked; globeControl.Globe.TerrainUseLighting = cbTerrainUseLighting.Checked; }
public static GeoScene.Data.GSOPoint2d Latlon_2_XYZ(GSOPoint3d point3d) { int id = Utility.getProjectID(); GeoScene.Data.GSOPoint2d point2d = new GeoScene.Data.GSOPoint2d(point3d.X, point3d.Y); GeoScene.Data.GSOPoint2d result = GeoScene.Data.GSOProjectManager.Forward(point2d, id); return(result); }
private void globeControl1_MouseUp(object sender, MouseEventArgs e) { if (MouseDown != e.Location) { return; } if (e.Button == MouseButtons.Left) { if (globeControl1.Globe.Action == EnumAction3D.NormalHit) { GSOPoint3d point3d = new GSOPoint3d(); GSOFeature newFeature = new GSOFeature(); GSOGeoMarker p = new GSOGeoMarker(); GSOMarkerStyle3D style = new GSOMarkerStyle3D(); style.IconPath = Application.StartupPath + "/Resource/image/DefaultIcon.png"; p.Style = style; p.Z = point3d.Z <= 0 ? 0 : point3d.Z; if (point3d.Z <= 0.0) { point3d = globeControl1.Globe.ScreenToScene(e.X, e.Y); } p.X = point3d.X; p.Y = point3d.Y; p.Z = point3d.Z; newFeature.Geometry = p; newFeature.Name = "我的地标"; globeControl1.Globe.MemoryLayer.AddFeature(newFeature); globeControl1.Globe.Action = EnumAction3D.ActionNull; } //开始判断是否是缓冲区分析 else if (globeControl1.Globe.Action == EnumAction3D.SelectObject) { if (mouseClickType == "缓冲区创建") { //获取选中要素 GSOFeature feature = globeControl1.Globe.SelectedObject; if (feature == null || feature.Geometry == null) { MessageBox.Show("请选择一个目标"); return; } if (feature.Geometry.Type != EnumGeometryType.GeoMarker && feature.Geometry.Type != EnumGeometryType.GeoPolyline3D && feature.Geometry.Type != EnumGeometryType.GeoPolygon3D) { MessageBox.Show("请选择一个点、线、面对象!", "提示"); return; } globeControl1.Globe.Action = EnumAction3D.ActionNull; makeBuffer(feature); } } } }
private GSOPoint3d GetCurrentViewPoint() { GSOPoint3d pt = new GSOPoint3d(); pt.X = _glbControl.Globe.CameraState.Longitude; pt.Y = _glbControl.Globe.CameraState.Latitude; pt.Z = 0; return(pt); }
public FrmAddPipeFitting(GSOGlobeControl ctl, GSOPoint3d p,GSOLayer _layer) { InitializeComponent(); this.globeControl1 = ctl; this.point = p; layer = _layer; plane3DControl = new GSOPlane3DControl(); panel1.Controls.Add(plane3DControl); plane3DControl.Dock = DockStyle.Fill; }
public FrmAddPipeFitting(GSOGlobeControl ctl, GSOPoint3d p, GSOLayer _layer) { InitializeComponent(); this.globeControl1 = ctl; this.point = p; layer = _layer; plane3DControl = new GSOPlane3DControl(); panel1.Controls.Add(plane3DControl); plane3DControl.Dock = DockStyle.Fill; }
public Form1() { InitializeComponent(); globeControl1 = new GSOGlobeControl(); panel1.Controls.Add(globeControl1); globeControl1.Dock = DockStyle.Fill; //鼠标按下事件,获取坐标 globeControl1.MouseDown += (sender, e) => { Location_MouseDown = e.Location; }; globeControl1.MouseUp += (sender, e) => { //鼠标抬起如果坐标不能对上,就认定为拖动球,不反应 if (Location_MouseDown != e.Location) { return; } if (e.Button == MouseButtons.Left) { //如果按照上面示例按我们方法添加HUD,需要加上这个判断,判断是否点在HUD中 //if (isMouseInHudControl == false) { if (globeControl1.Globe.Action == EnumAction3D.NormalHit) { GSOPoint3d point3d = new GSOPoint3d(); GSOFeature newFeature = new GSOFeature(); GSOGeoMarker p = new GSOGeoMarker(); GSOMarkerStyle3D style = new GSOMarkerStyle3D(); style.IconPath = Application.StartupPath + "/Resource/image/DefaultIcon.png"; p.Style = style; p.Z = point3d.Z <= 0 ? 0 : point3d.Z; if (point3d.Z <= 0.0) { point3d = globeControl1.Globe.ScreenToScene(e.X, e.Y); } p.X = point3d.X; p.Y = point3d.Y; p.Z = point3d.Z; newFeature.Geometry = p; newFeature.Name = "我的地标"; globeControl1.Globe.MemoryLayer.AddFeature(newFeature); globeControl1.Globe.Action = EnumAction3D.ActionNull; } } } }; }
/// <summary> /// 可视域分析,当鼠标按下 /// </summary> /// <param name="sender"></param> /// <param name="mouseEventArgs"></param> private void GlobeControl1OnMouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { //如果进入可视域分析状态 if (bViewshed3DAnalysisCheck) { GSOLayer resLayer = null; GSOPoint3d resIntersectPoint; //测试点击,返回点击图层和点位置信息 globeControl1.Globe.HitTest(e.X, e.Y, out resLayer, out resIntersectPoint, false, true, 0); //如果为第一次分析,并且为设置视点(第一次点击) if (curViewshed3DAnalysis != null && !bViewshed3DAnalysising && curViewshed3DAnalysisOther == null) { //设置可视域分析视点 curViewshed3DAnalysis.ViewerPosition = resIntersectPoint; pntViewerPos = resIntersectPoint; bViewshed3DAnalysising = true; } //如果为第二次分析,设置第二次分析视点(第一次点击) else if (curViewshed3DAnalysisOther != null && !bViewshed3DAnalysising) { curViewshed3DAnalysisOther.ViewerPosition = resIntersectPoint; pntViewerPos = resIntersectPoint; bViewshed3DAnalysising = true; } //如果不是第一次点击 else { //如果其他分析为空,则为第一次分析,设置视线点(第二次点击) if (curViewshed3DAnalysisOther == null) { curViewshed3DAnalysis.SetDistDirByPoint(resIntersectPoint); } //如果其他分析不为空,为第二次分析,设置视线点并且与第一次分析的关联(第二次点击) if (curViewshed3DAnalysisOther != null) { curViewshed3DAnalysisOther.SetDistDirByPoint(resIntersectPoint); //curViewshed3DAnalysisOther.VisibleAreaColor = Color.FromArgb(128, 255, 255, 0); //curViewshed3DAnalysisOther.HiddenAreaColor = Color.FromArgb(128, 0, 0, 255); //用第一个分析关联其他可视域分析 //如果有三个可视域分析,只能A关联B,A关联C。!!不能A关联B,B关联C!! curViewshed3DAnalysis.AttachViewshed3DAnalysis(curViewshed3DAnalysisOther); } //关闭可视域分析状态 bViewshed3DAnalysisCheck = false; bViewshed3DAnalysising = false; } } } }
private void SetControlsByStyle(GSOStyle style) { if (m_Style != null) { extentSectionLineStyle3D = m_Style as GSOExtendSectionLineStyle3D; if (extentSectionLineStyle3D == null) { extentSectionLineStyle3D = new GSOExtendSectionLineStyle3D(); extentSectionLineStyle3D.LineColor = Color.Green; GSOPoint3ds points = new GSOPoint3ds(); points.Add(new GSOPoint3d(-0.5, 0.5, 0)); points.Add(new GSOPoint3d(-0.5, -0.5, 0)); points.Add(new GSOPoint3d(0.5, -0.5, 0)); points.Add(new GSOPoint3d(0.5, 0.5, 0)); extentSectionLineStyle3D.SetSectionPoints(points); RefreshGlobe(extentSectionLineStyle3D); } } else { extentSectionLineStyle3D = new GSOExtendSectionLineStyle3D(); extentSectionLineStyle3D.LineColor = Color.Green; GSOPoint3ds points = new GSOPoint3ds(); points.Add(new GSOPoint3d(-0.5, 0.5, 0)); points.Add(new GSOPoint3d(-0.5, -0.5, 0)); points.Add(new GSOPoint3d(0.5, -0.5, 0)); points.Add(new GSOPoint3d(0.5, 0.5, 0)); extentSectionLineStyle3D.SetSectionPoints(points); RefreshGlobe(extentSectionLineStyle3D); } // 这句要写到前面,不然下面Checked的时候要检查 pictureBoxLineColor.BackColor = extentSectionLineStyle3D.LineColor; numericUpDownLineOpaque.Value = extentSectionLineStyle3D.LineColor.A; textBoxCornerSliceAngle.Text = extentSectionLineStyle3D.CornerSliceAngle.ToString(); GSOPoint3ds mpoints = extentSectionLineStyle3D.GetSectionPoints(); if (mpoints != null && mpoints.Count > 0) { for (int i = 0; i < mpoints.Count; i++) { GSOPoint3d point = mpoints[i]; if (point != null) { textBoxLineRadius.Text = (Math.Abs(point.X) * 2).ToString(); textBoxThickness.Text = (Math.Abs(point.Y) * 2).ToString(); break; } } } m_bInitialized = true; }
void mGlobeControl_MouseDown(object sender, MouseEventArgs e)//单击添加模型 { if (e.Button == MouseButtons.Left) { GSOLayer templayer; GSOFeature feature1 = mGlobeControl.Globe.HitTest(e.X, e.Y, out templayer, out point, false, true, 0); if (point.X == 0 && point.Y == 0 && point.Z == 0) { point = mGlobeControl.Globe.ScreenToScene(e.X, e.Y); } } }
//视频投射 private void btn_VedioProjection_Click(object sender, EventArgs e) { ConnectServer(); //绑定计时器事件 timerPlayVideo.Tick += this.timerPlayVideo_Tick; //打开视频文件 OpenFileDialog file = new OpenFileDialog() { Filter = "*.avi;*.mp4|*.avi;*.mp4", Multiselect = false }; if (file.ShowDialog() != DialogResult.OK) { return; } //新建VideoCapture _videoCapture = new VideoCapture(file.FileName); //新建视频投射GSOVideoCamera _gsoVideoCamera = new GSOVideoCamera(_glbControl.Globe); //获得当前相机位置 GSOPoint3d pos = _glbControl.Globe.CameraLookAt.Position; //视频水平视角 _gsoVideoCamera.HorizontalFov = 120; //视频垂直视角 _gsoVideoCamera.VerticalFov = 90; //根据当前相机位置设置视频投射点位置,高度为200米 _gsoVideoCamera.Position = new GSOPoint3d(_glbControl.Globe.CameraState.Longitude, _glbControl.Globe.CameraState.Latitude, 200); //设置投射点(决定投射方向,本例设置为垂直向下投射) _gsoVideoCamera.SetDirectionByPoint(new GSOPoint3d(_glbControl.Globe.CameraState.Longitude, _glbControl.Globe.CameraState.Latitude, 0)); //设置投射距离 _gsoVideoCamera.Distance = _glbControl.Globe.CameraState.Distance; //设置投射图像格式 _gsoVideoCamera.SetImageData(null, 0, 0, EnumTexturePixelFormat.TYPE_B8G8R8); //将创建的投射点应用到Globe中 _gsoVideoCamera.Apply(); //刷新球 _glbControl.Globe.Refresh(); //通过OPENCV获得视频的元数据信息 movieInfo = new MovieInfo(_videoCapture); //计算计时器间隔时间 timerPlayVideo.Interval = Convert.ToInt32(System.Math.Round(1.0 / movieInfo.fps, 2) * 100); //设置计时器为可用 timerPlayVideo.Enabled = true; }
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); }
/// <summary> /// 垂直净距分析 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_VerDist_Click(object sender, EventArgs e) { btn_CreatePipeLine.PerformClick(); GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); GSOPoint3d pntProIntersect1 = new GSOPoint3d(); GSOPoint3d pntProIntersect2 = new GSOPoint3d(); //计算两根管线最短垂直间距点 double hVert = _glbControl.Globe.Analysis3D.ComputeVerticalDistance(_pipeFeature1.Geometry as GSOGeoPolyline3D, _pipeFeature2.Geometry as GSOGeoPolyline3D, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); //通过返回的两个最短垂直间距点的Z值差,扣除管径,得到两根管线的垂直净距 hVert = Math.Abs(pntIntersect1.Z - pntIntersect2.Z) - _radius - _radius; MessageBox.Show(string.Format("计算出的垂直净距为{0}", Math.Round(hVert, 3))); }
private void btn_addPowerLine_Click(object sender, EventArgs e) { //创建杆塔节点位置 GSOPoint3d point1 = new GSOPoint3d(120.121, 30.210, 0); GSOPoint3d point2 = new GSOPoint3d(120.121, 30.2105, 0); GSOPoint3ds points = new GSOPoint3ds(); //加载顺序就是连接顺序 points.Add(point1); points.Add(point2); //电力线 GSOGeoPowerLine powerLine = new GSOGeoPowerLine(); for (int i = 0; i < points.Count; i++) { //创建杆塔节点 GSOGeoPowerLineNode node = new GSOGeoPowerLineNode(); node.Position = points[i]; //添加杆塔模型 node.NodeTemplatePath = i % 2 == 0 ? _modelPath : _modelPath; //赋予旋转角(需要调整旋转角适应电力线位置) node.RotateZ = 0; //将杆塔节点添加到电力线 powerLine.AddNode(node); } //电力线样式设置 powerLine.LinkLineStyle = new GSOElecLineStyle3D() { LineColor = Color.White, //电力线半径 Radius = 0.05, //分段数 Slice = 5, //电力线曲率 CurveFactor = 0.0002 }; //新建要素 GSOFeature feature = new GSOFeature(); feature.Geometry = powerLine; //添加要素到globe中 _glbControl.Globe.MemoryLayer.AddFeature(feature); _glbControl.Globe.JumpToFeature(feature, 1500); }
void mGlobeControl_MouseUp(object sender, MouseEventArgs e)//单击添加模型 { if (e.Button == MouseButtons.Left) { GSOPoint3d newpoint; GSOLayer templayer; GSOFeature feature1 = mGlobeControl.Globe.HitTest(e.X, e.Y, out templayer, out newpoint, false, true, 0); if (newpoint.X == 0 && newpoint.Y == 0 && newpoint.Z == 0) { newpoint = mGlobeControl.Globe.ScreenToScene(e.X, e.Y); } if (newpoint == point) { GSOPoint3d pt = new GSOPoint3d(); pt.X = newpoint.X; pt.Y = newpoint.Y; pt.Z = newpoint.Z; if (filePath != null && filePath != "") { if (mGlobeControl.Globe.Action == EnumAction3D.SelectObject) { GSOFeature newfeature = null; if (mGlobeControl.Globe.DestLayerFeatureAdd.Dataset != null && mGlobeControl.Globe.DestLayerFeatureAdd.Dataset.IsFeatureDataset == true) { GSOFeatureDataset featureDataset = mGlobeControl.Globe.DestLayerFeatureAdd.Dataset as GSOFeatureDataset; newfeature = featureDataset.CreateFeature(); } else { newfeature = new GSOFeature(); } newfeature.Name = Path.GetFileNameWithoutExtension(filePath) + "_" + iModelCount.ToString(); GSOGeoModel model = new GSOGeoModel(); model.FilePath = filePath; model.Position = pt; newfeature.Geometry = model; mGlobeControl.Globe.DestLayerFeatureAdd.AddFeature(newfeature); iModelCount++; } } } } }
/// <summary> /// 图层定位 /// </summary> /// <param name="globeControl1"></param> /// <param name="latLonBounds"></param> public static void flyToLayerOrTerrain(GSOGlobeControl globeControl1, GSORect2d latLonBounds) { if ((latLonBounds.Left.Equals(0.0) == false) && (latLonBounds.Bottom.Equals(0.0) == false) && (latLonBounds.Top.Equals(0.0) == false) && (latLonBounds.Right.Equals(0.0) == false)) { GSOPoint2d pntCenter = latLonBounds.Center; GSOPoint3d pntPostion = new GSOPoint3d(); pntPostion.X = pntCenter.X; pntPostion.Y = pntCenter.Y; double dMaxGeoLen = Math.Max(latLonBounds.Width, latLonBounds.Height); double dSize = dMaxGeoLen * Math.PI * 6378137 / 90; pntPostion.Z = dSize > 20000000 ? dSize / 4 : dSize; globeControl1.Globe.FlyToPosition(pntPostion, EnumAltitudeMode.RelativeToGround); } }
public void LoadChartEvent() { try { this.Shown += new EventHandler(Frm_HDMAnalysis2_Shown); chart1.Series["管线"].ChartType = SeriesChartType.Point; chart1.Series["管线"]["DrawingStyle"] = "Cylinder"; chart1.Series["管线"].MarkerStyle = MarkerStyle.Circle; //点的类型 chart1.Series["管线"].MarkerBorderColor = Color.Black; //点的边框颜色 chart1.ChartAreas[0].AxisX.Minimum = 0; //x轴的起始点大小 chart1.ChartAreas[0].AxisX.Maximum = line.GetSpaceLength(true, 6378137); chart1.ChartAreas[0].AxisY.Maximum = 0; //y轴的最大值 chart1.ChartAreas[0].AxisX.Title = "距离 (米)"; chart1.ChartAreas[0].AxisY.Title = "埋深 (米)"; //chart1.ChartAreas[0].AxisY2.Title = "大家好 ()"; //chart1.ChartAreas[0].AxisY2.Maximum = 10000; //chart1.ChartAreas[0].AxisY2.CustomLabels.Add(-3d, -2d, "1"); //chart1.ChartAreas[0].AxisY2.CustomLabels.Add(-2d, -1.5d, "2"); //chart1.ChartAreas[0].AxisY2.CustomLabels.Add(-1.5d, -1d, "3"); //chart1.ChartAreas[0].AxisY2.CustomLabels.Add(-1d, -0.5d, "4"); //chart1.ChartAreas[0].AxisY2.CustomLabels.Add(-0.5d, 0d, "5"); //chart1.ChartAreas[0].AxisY2.CustomLabels.Add(0d, 1d, "6"); if (line.PartCount > 0) { GSOPoint3ds nodes = line[0]; GSOPoint3d node = nodes[0]; A_x = node.X; A_y = node.Y; } DrawCurveGraph(A_x, A_y); } catch (Exception ex) { Log.PublishTxt(ex); } }
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 btnAdd_Click(object sender, EventArgs e) { if (feature != null) { GSOPoint3d pt = new GSOPoint3d(); pt.X = point.X; pt.Y = point.Y; pt.Z = point.Z; GSOGeoModel model = new GSOGeoModel(); model.FilePath = modelPath; model.Position = pt; model.AltitudeMode = EnumAltitudeMode.Absolute; feature = new GSOFeature(); feature.Geometry = model; layer.AddFeature(feature); globeControl1.Refresh(); } this.Close(); }
private void buttonAddNode_Click(object sender, EventArgs e) { GSOPoint3ds nodes = GetCurNodes(); if (nodes!=null) { m_GlobeControl.Globe.AddToEditHistroy(mlayer, mfeature, EnumEditType.Modify); GSOPoint3d newPoint = new GSOPoint3d(); try { newPoint.X = Double.Parse(textBoxX.Text); newPoint.Y = Double.Parse(textBoxY.Text); newPoint.Z = Double.Parse(textBoxZ.Value.ToString()); } catch (System.Exception exp) { Log.PublishTxt(exp); //MessageBox.Show(exp.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } /* ListViewItem item = new ListViewItem(); item.SubItems.Add(textBoxX.Text); item.SubItems.Add(textBoxY.Text); item.SubItems.Add(textBoxZ.Text); listViewNodeList.Items.Add(item); */ nodes.Add(newPoint); UpdateNodeViewList(); // 选中最后一个 SelectItem(listViewNodeList.Items.Count - 1); if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } }
//单击添加模型 void mGlobeControl_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { GSOPoint3d newpoint; GSOLayer templayer; GSOFeature feature1 = mGlobeControl.Globe.HitTest(e.X, e.Y, out templayer, out newpoint, false, true, 0); if (newpoint.X == 0 && newpoint.Y == 0 && newpoint.Z == 0) { newpoint = mGlobeControl.Globe.ScreenToScene(e.X, e.Y); } if (newpoint == point) { GSOPoint3d pt = new GSOPoint3d(); pt.X = newpoint.X; pt.Y = newpoint.Y; pt.Z = newpoint.Z; if (filePath != null && filePath != "") { if (mGlobeControl.Globe.Action == EnumAction3D.SelectObject) { GSOFeature newfeature = null; if (mGlobeControl.Globe.DestLayerFeatureAdd.Dataset != null && mGlobeControl.Globe.DestLayerFeatureAdd.Dataset.IsFeatureDataset == true) { GSOFeatureDataset featureDataset = mGlobeControl.Globe.DestLayerFeatureAdd.Dataset as GSOFeatureDataset; newfeature = featureDataset.CreateFeature(); } else { newfeature = new GSOFeature(); } newfeature.Name = Path.GetFileNameWithoutExtension(filePath) + "_" + iModelCount.ToString(); GSOGeoModel model = new GSOGeoModel(); model.FilePath = filePath; model.Position = pt; newfeature.Geometry = model; mGlobeControl.Globe.DestLayerFeatureAdd.AddFeature(newfeature); iModelCount++; } } } } }
private void buttonModify_Click(object sender, EventArgs e) { if (listViewNodeList.SelectedIndices.Count>0) { int nSelIndex = listViewNodeList.SelectedIndices[0]; GSOPoint3ds nodes = GetCurNodes(); if (nodes != null && nodes.Count > nSelIndex) { m_GlobeControl.Globe.AddToEditHistroy(mlayer, mfeature, EnumEditType.Modify); GSOPoint3d newPoint = new GSOPoint3d(); try { newPoint.X = Double.Parse(textBoxX.Text); newPoint.Y = Double.Parse(textBoxY.Text); newPoint.Z = Double.Parse(textBoxZ.Value.ToString()); } catch (System.Exception exp) { Log.PublishTxt(exp); } nodes[nSelIndex] = newPoint; ListViewItem item = listViewNodeList.Items[nSelIndex]; item.SubItems[1].Text = textBoxX.Text; item.SubItems[2].Text = textBoxY.Text; item.SubItems[3].Text = textBoxZ.Value.ToString(); // 选中刚才的那个索引 SelectItem(m_nCurSelected); if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } } }
//关阀分析 private void CloseValvesAnalysisMenuItem_Click(object sender, EventArgs e) { ClearCloseValvesAnalysisMenuItem_Click(sender,e); if (globeControl1.Globe.SelObjectCount < 1) { MessageBox.Show("请选中至少一个管线!!"); return; } GSOLayer resLayer = null; GSOFeature resFeature = null; globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); GSOGeoPolyline3D line1 = resFeature.Geometry as GSOGeoPolyline3D; if (line1 == null) { MessageBox.Show("请选择管线!!"); return; } GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D; if (pipeStyle1 == null) { MessageBox.Show("请选择管线!!"); return; } GSOPoint3d resIntersetPoint = new GSOPoint3d(); if (NetworkCloseValvesAnalysis(resFeature, resIntersetPoint, resLayer)) { //btnGFFX.Checked = false; globeControl1.Globe.Action = EnumAction3D.ActionNull; } }
private void FlyToPlaceMenu_Click(object sender, EventArgs e) { FrmFlyToLatLonPos frm = new FrmFlyToLatLonPos(); if (frm.ShowDialog() == DialogResult.OK) { if (frm.m_strLon.Trim() != "" && frm.m_strLat.Trim() != "") { GSOPoint3d point3d = new GSOPoint3d(); point3d.X = Convert.ToSingle(frm.m_strLon); point3d.Y = Convert.ToSingle(frm.m_strLat); if (frm.m_strAlt.Trim() == "") { point3d.Z = 2000; } else { point3d.Z = Convert.ToSingle(frm.m_strAlt); } globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.RelativeToGround); } } }
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 AddModelMenu_Click(object sender, EventArgs e) { GSOFeature newFeature = new GSOFeature(); GSOGeoModel model = new GSOGeoModel(); GSOPoint3d pt = new GSOPoint3d(); pt.X = globeControl1.Globe.CameraState.Longitude; pt.Y = globeControl1.Globe.CameraState.Latitude; pt.Z = 0; model.Position = pt; newFeature.Geometry = model; newFeature.Name = "我的模型"; ShowAddFeatureDlg(newFeature); }
private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node.Tag != null) { if(e.Node.Tag.GetType() == typeof(GSOFeature)) { GSOFeature feature = e.Node.Tag as GSOFeature; if (feature.Geometry == null || feature.Geometry.CameraState == null) { globeControl1.Globe.FlyToFeature(feature); } else { globeControl1.Globe.FlyToCameraState(feature.Geometry.CameraState); } } else { GSORect2d rcBounds=new GSORect2d(); GSOLayer tempLayer = e.Node.Tag as GSOLayer; if (tempLayer!=null) { rcBounds = tempLayer.LatLonBounds; } else if (e.Node.Tag.GetType() == typeof(GSOTerrain)) { GSOTerrain tempTerrain = e.Node.Tag as GSOTerrain; rcBounds = tempTerrain.LatLonBounds; } if(!rcBounds.IsEmpty()) { GSOPoint2d pntCenter = rcBounds.Center; GSOPoint3d pntPostion=new GSOPoint3d(); pntPostion.X = pntCenter.X; pntPostion.Y = pntCenter.Y; Double dMaxGeoLen = Math.Max(rcBounds.Width, rcBounds.Height); Double dSize = dMaxGeoLen *Math.PI*6378137/360; pntPostion.Z = dSize; globeControl1.Globe.FlyToPosition(pntPostion,EnumAltitudeMode.Absolute); } } } }
//阀门分析 private bool NetworkCloseValvesAnalysis(GSOFeature lineFeature, GSOPoint3d pntBreak, GSOLayer lineLayer) { if (lineLayer == null || lineFeature == null || lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) { return false; } GSODataset curCAYDataset = lineLayer.Dataset; if (curCAYDataset == null || curCAYDataset.DataSource == null) { return false; } string srName = curCAYDataset.Name; GSONetworkDataset curCAYNDataset = curCAYDataset.DataSource.GetDatasetByName(srName + "Network") as GSONetworkDataset; if (curCAYNDataset == null) { MessageBox.Show("该图层没有创建网络拓扑,请先创建网络拓扑信息再进行分析!", "提示"); return false; } ClearCloseValvesAnalysisMenuItem_Click(null, null); int[] arryResNodeID; int[] arryResValveID; curCAYNDataset.CloseValveAnalysis(lineFeature.ID, out arryResNodeID, out arryResValveID, false, true); if (arryResValveID != null) { if (lineFeature.GetFieldAsInt32("管线编码") >= 6000 && lineFeature.GetFieldAsInt32("管线编码") <= 6203) // 6100是热力管线的编码 { GSOLayer ValveLayer = globeControl1.Globe.Layers.GetLayerByCaption("热力阀门"); if (ValveLayer != null) { m_CloseValvesAnalyResFeatures = ValveLayer.GetFeaturesByIDs(arryResValveID); } } else if (lineFeature.GetFieldAsInt32("管线编码") >= 5000 && lineFeature.GetFieldAsInt32("管线编码") <= 5200) // 5000是燃气管线的编码 { GSOLayer ValveLayer = globeControl1.Globe.Layers.GetLayerByCaption("燃气阀门"); if (ValveLayer != null) { m_CloseValvesAnalyResFeatures = ValveLayer.GetFeaturesByIDs(arryResValveID); } } else if (lineFeature.GetFieldAsInt32("管线编码") >= 3000 && lineFeature.GetFieldAsInt32("管线编码") <= 3513) // 3000是给水管线的编码 { GSOLayer ValveLayer = globeControl1.Globe.Layers.GetLayerByCaption("给水阀门"); if (ValveLayer != null) { m_CloseValvesAnalyResFeatures = ValveLayer.GetFeaturesByIDs(arryResValveID); } } } if (m_CloseValvesAnalyResFeatures == null || m_CloseValvesAnalyResFeatures.Length < 1) { MessageBox.Show("没有找到要关闭的阀门!"); } else { int nCount = m_CloseValvesAnalyResFeatures.Length; if (nCount > 0) { FrmShowValvesNeedClose frm = FrmShowValvesNeedClose.getForm(globeControl1, m_CloseValvesAnalyResFeatures, m_CloseValvesList); frm.setLstValvesName(); if (!frm.Visible) { frm.Show(this); } } } return true; }
private void buttonAnalyse_Click(object sender, EventArgs e) { if(m_geopolyline!=null && m_globe!=null) { checkBoxSameScale.Enabled = true; checkBoxXmin.Enabled = true; checkBoxYMin.Enabled = true; GSOPoint3d pntMax, pntMin, pntStart, pntEnd; GSOPoint3ds pnt3ds; double dLineLength; m_globe.Analysis3D.ProfileAnalyse(m_geopolyline, 100, out pnt3ds, out dLineLength, out pntMax, out pntMin, out pntStart, out pntEnd); m_pnt3ds = pnt3ds; m_pntMax = pntMax; m_pntMin = pntMin; m_pntStart = pntStart; m_pntEnd = pntEnd; m_dXTotalLength = dLineLength; m_dSphereLength = m_geopolyline.GetSphereLength(6378137.0); m_dSpaceLength = m_geopolyline.GetSpaceLength(false, 6378137.0); m_dGroundLength = m_globe.Analysis3D.GetGroundLength(m_geopolyline, false, 0); SetLableText(); DrawCurveGraph(); } }
private void button3_Click(object sender, EventArgs e) { if (comboBoxDataSourceList.SelectedItem == null) { MessageBox.Show("请选择一个目标数据源!", "提示"); return; } GSODataSource ds = Utility.getDataSourceByFullName(globeControl1, comboBoxDataSourceList.SelectedItem.ToString().Trim()); if (ds == null) { MessageBox.Show("选择的目标数据源为空!", "提示"); return; } if (comboBoxShpLayerList.SelectedIndex<0) { return; } try { if (valiValvedata()) { GSOFeatureDataset featdataset = CreateDBFeatureDataset(textBoxNewLayerName.Text); if (featdataset == null) { return; } featdataset.Open(); GSOLayer shpLayer = globeControl1.Globe.Layers[comboBoxShpLayerList.SelectedIndex]; if (shpLayer == null) { return; } GSOFeatures features = shpLayer.GetAllFeatures(true); string message = ""; for (int j = 0; j < features.Length; j++) { GSOFeature f = features[j]; GSOGeoPoint3D shpPoint = f.Geometry as GSOGeoPoint3D; double z = f.GetFieldAsDouble(combZ.SelectedItem.ToString()); double deep = f.GetFieldAsDouble(combZ.SelectedItem.ToString()); GSOFeature feature = featdataset.CreateFeature(); GSOGeoModel model = new GSOGeoModel(); GSOPoint3d pt = new GSOPoint3d(); pt.X = shpPoint.X; pt.Y = shpPoint.Y; pt.Z = z; model.Position = pt; model.AltitudeMode = EnumAltitudeMode.RelativeToGround; string modelPath = f.GetFieldAsString(combPath.SelectedItem.ToString()); model.FilePath = Application.StartupPath + "\\" + modelPath; model.Name = f.GetValue(combModelName.SelectedItem.ToString()).ToString(); feature.Name = f.GetValue(combModelName.SelectedItem.ToString()).ToString(); feature.Geometry = model; for (int i = 0; i < f.GetFieldCount(); i++) { GeoScene.Data.GSOFieldDefn fielddef = (GeoScene.Data.GSOFieldDefn)(f.GetFieldDefn(i)); if (fielddef == null) { continue; } if (!fm_cns.ContainsKey(fielddef.Name)) { continue; } object obu = f.GetValue(fielddef.Name); if (obu != null) { string fieldName = fm_cns.ContainsKey(fielddef.Name) == true ? fm_cns[fielddef.Name].ToString() : fielddef.Name; feature.SetValue(fieldName, obu); } } featdataset.AddFeature(feature); } featdataset.Save(); string strMessage = "shp文件中共" + features.Length + "个对象,实际入库" + featdataset.GetAllFeatures().Length + "个对象!\r\n"; if (message == "") { MessageBox.Show(strMessage, "提示"); } else { FrmMessageShow frm = new FrmMessageShow(strMessage + message); frm.ShowDialog(); } this.Close(); } } catch (Exception ex) { Log.PublishTxt(ex); MessageBox.Show(ex.Message); } }
private void AddNewEntity(GSOGeoEntity geoEntity, string strName) { GSOFeature newFeature = new GSOFeature(); GSOPoint3d pt = new GSOPoint3d(); pt.X = globeControl1.Globe.CameraState.Longitude; pt.Y = globeControl1.Globe.CameraState.Latitude; pt.Z = 0; geoEntity.Position = pt; newFeature.Geometry = geoEntity; newFeature.Name = strName; ShowAddFeatureDlg(newFeature); }
private void button3_Click(object sender, EventArgs e) { if (comboBoxDataSourceList.SelectedItem == null) { MessageBox.Show("请选择一个目标数据源!", "提示"); return; } GSODataSource ds = Utility.getDataSourceByFullName(globeControl1, comboBoxDataSourceList.SelectedItem.ToString().Trim()); if (ds == null) { MessageBox.Show("选择的目标数据源为空!", "提示"); return; } if (textBoxModelFolder.Text == "") { return; } if (comboBoxShpLayerList.SelectedIndex < 0) { return; } try { Regex regNum = new Regex("^[0-9]"); DirectoryInfo theFolder = new DirectoryInfo(textBoxModelFolder.Text); foreach (FileInfo nextFile in theFolder.GetFiles()) { if (nextFile.Name.ToLower().IndexOf("3ds") > -1 || nextFile.Name.ToLower().IndexOf("gcm") > -1) { files.Add(nextFile.Name); string temp = nextFile.Name.Substring(nextFile.Name.IndexOf("-") + 1, nextFile.Name.LastIndexOf(".") - nextFile.Name.IndexOf("-") - 1); string modeltype = nextFile.Name.Substring(0, nextFile.Name.IndexOf("-")); modeltypes.Add(modeltype); double Num; bool isNum = double.TryParse(temp, out Num); if (isNum) { deeps.Add(Convert.ToDouble(temp)); } } } GSODataset dataset = ds.GetDatasetByName(textBoxNewLayerName.Text.Trim()); GSOFeatureDataset featdataset; if (dataset != null) { DialogResult result = MessageBox.Show("工井图层名称在数据库中已存在!是否向该表追加", "提示", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } else if (result == DialogResult.Yes) { featdataset = dataset as GSOFeatureDataset; } else { return; } } else { featdataset = CreateDBFeatureDataset(textBoxNewLayerName.Text.Trim()); } if (featdataset == null) { return; } featdataset.Open(); GSOLayer shpLayer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxShpLayerList.SelectedItem.ToString().Trim()); if (shpLayer == null) return; GSOFeatures features = shpLayer.GetAllFeatures(true); string message = ""; for (int j = 0; j < features.Length; j++) { GSOFeature f = features[j]; GSOGeoPoint3D shpPoint = f.Geometry as GSOGeoPoint3D; double x; double y; double rotateAngle = 0; string currentModelType = f.GetValue(combCode.SelectedItem.ToString()).ToString(); double z = Convert.ToDouble(txtUpGround.Text); double deep=f.GetFieldAsDouble(combDeep.SelectedItem.ToString()); int index = -1; double diff = double.MaxValue; for (int i = 0; i < deeps.Count; i++) { double tempdeep = Convert.ToDouble(deeps[i]); string modeltype = modeltypes[i].ToString(); if (modeltype != currentModelType) { continue; } if (tempdeep > deep) { double chazhi = tempdeep - deep; if (diff > chazhi) { diff = chazhi; index = i; } } } if (index < 0) { message += "ID为" + f.ID + "的对象没有找到符合井深的工井模型\r\n"; continue; } GSOFeature feature = featdataset.CreateFeature(); GSOGeoModel model = new GSOGeoModel(); GSOPoint3d pt = new GSOPoint3d(); pt.X = shpPoint.X; pt.Y = shpPoint.Y; pt.Z = z; model.Position = pt; model.Align = EnumEntityAlign.TopCenter; //接口已修复作用 model.AltitudeMode = EnumAltitudeMode.RelativeToGround; model.RotateZ = 0 - rotateAngle * 180 / Math.PI + 90; model.FilePath = textBoxModelFolder.Text + "\\" + files[index]; model.Name = f.GetValue(combModelName.SelectedItem.ToString()).ToString(); feature.Name = f.GetValue(combModelName.SelectedItem.ToString()).ToString(); feature.Geometry = model; for (int i = 0; i < f.GetFieldCount(); i++) { GeoScene.Data.GSOFieldDefn fielddef = (GeoScene.Data.GSOFieldDefn)(f.GetFieldDefn(i)); if (fielddef == null) { continue; } if (!gj_cns.ContainsKey(fielddef.Name)) continue; object obu = f.GetValue(fielddef.Name); if (obu != null) { string fieldName = gj_cns.ContainsKey(fielddef.Name) == true ? gj_cns[fielddef.Name].ToString() : fielddef.Name; feature.SetValue(fieldName, obu); } } featdataset.AddFeature(feature); } featdataset.Save(); featdataset.Close(); string strMessage = "shp文件中共" + features.Length + "个对象,实际入库" + featdataset.GetAllFeatures().Length + "个对象!\r\n"; if (message == "") { MessageBox.Show(strMessage, "提示"); } else { FrmMessageShow frm = new FrmMessageShow(strMessage + message); frm.ShowDialog(); } this.Close(); } catch (Exception ex) { Log.PublishTxt(ex); MessageBox.Show(ex.Message); } }
//单击添加模型 void mGlobeControl_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { GSOLayer templayer; GSOFeature feature1 = mGlobeControl.Globe.HitTest(e.X, e.Y, out templayer, out point, false, true, 0); if (point.X == 0 && point.Y == 0 && point.Z == 0) { point = mGlobeControl.Globe.ScreenToScene(e.X, e.Y); } } }
void sceneControl1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { GSOPoint3d point; GSOLayer templayer; GSOFeature feature1 = globeControl1.Globe.HitTest(e.X, e.Y, out templayer, out point, false, true, 0); if (point.X == 0 && point.Y == 0 && point.Z == 0) { point = globeControl1.Globe.ScreenToScene(e.X, e.Y); } GSOPoint3d pt = new GSOPoint3d(); pt.X = point.X; pt.Y = point.Y; pt.Z = point.Z; if (addfitflag) { WorldGIS.Forms.FrmAddPipeFitting frm = new WorldGIS.Forms.FrmAddPipeFitting(globeControl1, pt, globeControl1.Globe.DestLayerFeatureAdd); frm.Show(this); addfitflag = false; } } }
private void AddMultiModeMenuItem_Click(object sender, EventArgs e) { FrmAddMultiModel dlg = new FrmAddMultiModel(); if (dlg.ShowDialog() == DialogResult.OK) { TreeNode featureAddLayerTreeNode = GetDestLayerFeatureAddTreeNode(); if (featureAddLayerTreeNode != null) { GSOLayer featureAddLayer = (GSOLayer)featureAddLayerTreeNode.Tag; int nSelFileNum = dlg.m_arryFileSel.Count; for (int i = 0; i < nSelFileNum; i++) { string strFilePath = dlg.m_arryFileSel[i].ToString(); string strFileExt = Path.GetExtension(strFilePath).ToLower(); string strFileName = Path.GetFileName(strFilePath); int nIndex = strFileName.LastIndexOf('.'); string strTitle = strFileName.Substring(0, nIndex); GSOFeature f = new GSOFeature(); GSOGeoModel model = new GSOGeoModel(); model.FilePath = strFilePath; if (strFileExt == ".gcm") // 如果是gcm需要提前加载坐标信息 { model.LoadGCMCoordInfo(); if (!model.IsCoordInfoValid()) { GSOPoint3d pt = new GSOPoint3d(); pt.X = globeControl1.Globe.CameraState.Longitude; pt.Y = globeControl1.Globe.CameraState.Latitude; pt.Z = model.Position.Z; // 注意z值还是要保留下来的 model.Position = pt; } model.AltitudeMode = EnumAltitudeMode.RelativeToGround; } else { GSOPoint3d pt = new GSOPoint3d(); pt.X = globeControl1.Globe.CameraState.Longitude; pt.Y = globeControl1.Globe.CameraState.Latitude; pt.Z = 0; model.Position = pt; model.AltitudeMode = EnumAltitudeMode.ClampToGround; } f.Geometry = model; f.Name = strTitle; featureAddLayer.AddFeature(f); } RefreshTreeNodeLayerFeatureList(featureAddLayerTreeNode); globeControl1.Globe.Refresh(); } } }
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 void button3_Click(object sender, EventArgs e) { if (txtFolder.Text == "") return; if (cmbLayer.SelectedIndex<0) return; try { Regex regNum = new Regex("^[0-9]"); DirectoryInfo theFolder = new DirectoryInfo(txtFolder.Text); foreach (FileInfo nextFile in theFolder.GetFiles()) { if (nextFile.Name.ToLower().IndexOf("3ds") > -1 || nextFile.Name.ToLower().IndexOf("gcm") > -1) { files.Add(nextFile.Name); string temp = nextFile.Name.Substring(nextFile.Name.IndexOf("-") + 1, nextFile.Name.LastIndexOf(".") - nextFile.Name.IndexOf("-") - 1); string modeltype = nextFile.Name.Substring(0, nextFile.Name.IndexOf("-")); modeltypes.Add(modeltype); double Num; bool isNum = double.TryParse(temp, out Num); if (isNum) { deeps.Add(Convert.ToDouble(temp)); } } } GSOFeatureDataset featdataset = CreateDBFeatureDataset(txtLayerName.Text); featdataset.Open(); GSOLayer shpLayer = globeControl1.Globe.Layers[cmbLayer.SelectedIndex]; if (shpLayer == null) return; GSOFeatures features = shpLayer.GetAllFeatures(true); for (int j = 0; j < features.Length; j++) { GSOFeature f = features[j]; GSOGeoPoint3D shpPoint = f.Geometry as GSOGeoPoint3D; double x; double y; double rotateAngle = 0; rotateAngle = (double)f.GetValue(combAngle.SelectedItem.ToString()); string currentModelType = f.GetValue(combCode.SelectedItem.ToString()).ToString(); double z = Convert.ToDouble(txtUpGround.Text); double deep=f.GetFieldAsDouble(combDeep.SelectedItem.ToString()); int index = -1; double diff = double.MaxValue; for (int i = 0; i < deeps.Count; i++) { double tempdeep = Convert.ToDouble(deeps[i]); string modeltype = modeltypes[i].ToString(); if (modeltype != currentModelType) { continue; } if (tempdeep > deep) { double chazhi = tempdeep - deep; if (diff > chazhi) { diff = chazhi; index = i; } } } if (index < 0) { continue; } GSOFeature feature = featdataset.CreateFeature(); GSOGeoModel model = new GSOGeoModel(); GSOPoint3d pt = new GSOPoint3d(); pt.X = shpPoint.X; pt.Y = shpPoint.Y; pt.Z = z; model.Position = pt; model.Align = EnumEntityAlign.TopCenter; //接口已修复作用 model.AltitudeMode = EnumAltitudeMode.RelativeToGround; model.RotateZ = 0 - rotateAngle * 180 / Math.PI + 90; model.FilePath = txtFolder.Text + "\\" + files[index]; model.Name = f.GetValue(combModelName.SelectedItem.ToString()).ToString(); feature.Name = f.GetValue(combModelName.SelectedItem.ToString()).ToString(); feature.Geometry = model; for (int i = 0; i < feature.GetFieldCount(); i++) { GeoScene.Data.GSOFieldDefn fielddef = (GeoScene.Data.GSOFieldDefn)(f.GetFieldDefn(i)); //if (!en_cns.ContainsKey(fielddef.Name)) // continue; // object fieldvalue = convertFieldValue(fielddef.Name, f.GetValue(fielddef.Name)); if (fielddef == null) continue; feature.SetValue(fielddef.Name, f.GetValue(fielddef.Name)); } featdataset.AddFeature(feature); } featdataset.Save(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }