using System; using System.Collections; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using DevComponents.DotNetBar; using GeoScene.Data; using GeoScene.Engine; using GeoScene.Globe; namespace Cyberpipe { public partial class FrmShResult : Office2007Form { public double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; public string layername; public GSOGlobeControl globleControl1; int selectState; //定位和闪烁初始化定义 int count; private string flashflag = "single"; GSOFeature hlfeature = null; GSOLayer layerTemp; List<string> m_PipelineLayerNames = new List<string>();//线图层名称 GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); List<string> m_vqLayer = new List<string>(); List<string> m_hqLayer = new List<string>(); MainFrm mainfrm; ArrayList shresultLists = new ArrayList(); /// <summary> /// /// </summary> /// <param name="_vbz"></param> /// <param name="_hbz"></param> /// <param name="_layername"></param> /// <param name="_globleControl1"></param> /// <param name="_PipelineLayerNames"></param> public FrmShResult(double _vbz, double _hbz, string _layername, GSOGlobeControl _globleControl1, List<string> _PipelineLayerNames) { dVerticalJingJuBiaoZhun = _vbz; dHorizontalJingJuBiaoZhun = _hbz; layername = _layername; globleControl1 = _globleControl1; m_PipelineLayerNames = _PipelineLayerNames; InitializeComponent(); } public FrmShResult() { // TODO: Complete member initialization } public void analysis() { mainfrm = (MainFrm)Owner; layerTemp = globleControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); if (layer == null) return; GSOFeatureLayer flayer = layer as GSOFeatureLayer; GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; GSOFeatures feats = flayer.GetAllFeatures(); if (feats == null) { return; } for (int i = 0; i < feats.Length; i++) { selectState = 1; VerticalDistanceAnalysis("垂直净距分析", feats[i], m_PipelineLayerNames); HorizontalDistanceAnalysis("水平净距分析", feats[i], m_PipelineLayerNames); } //////////////////////得到问题图层列表//////////////////////// for (int i = 0; i < dgridShVResult.RowCount; i++) { m_vqLayer.Add(dgridShVResult.Rows[i].Cells["审核编号"].Value.ToString()); } for (int i = 0; i < dgridShHResult.RowCount; i++) { m_hqLayer.Add(dgridShHResult.Rows[i].Cells["审核编号1"].Value.ToString()); } ShResult sr = null; shresultLists.Clear(); for (int i = 0; i < feats.Length; i++) { GSOFeature feat = feats[i]; string featname = feat.Name; for (int j = 0; j < m_vqLayer.Count; j++) { if (m_vqLayer.Contains(featname)) { sr = new ShResult(feat.Name, "垂直净距不符合要求"); shresultLists.Add(sr); break; } } } for (int i = 0; i < feats.Length; i++) { GSOFeature feat = feats[i]; string featname = feat.Name; for (int j = 0; j < m_hqLayer.Count; j++) { if (m_hqLayer.Contains(featname)) { sr = new ShResult(feat.Name, "水平净距不符合要求"); shresultLists.Add(sr); break; } } } mainfrm.shresultLists = shresultLists; //数据库中录入审核记录 String sql = ""; string now = DateTime.Now.ToString("yyyy-MM-dd"); if (dgridShVResult.Rows.Count > 0) { for (int i = 0; i < dgridShVResult.Rows.Count; i++) { sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" + dgridShVResult.Rows[i].Cells[0].Value + "','" + dgridShVResult.Rows[i].Cells[1].Value + "','" + dgridShVResult.Rows[i].Cells[2].Value + "','" + dgridShVResult.Rows[i].Cells[3].Value + "','" + dgridShVResult.Rows[i].Cells[4].Value + "','V','" + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; OledbHelper.sqlExecuteNonQuery(sql); } } if (dgridShHResult.Rows.Count > 0) { for (int j = 0; j < dgridShHResult.Rows.Count; j++) { sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" + dgridShHResult.Rows[j].Cells[0].Value + "','" + dgridShHResult.Rows[j].Cells[1].Value + "','" + dgridShHResult.Rows[j].Cells[2].Value + "','" + dgridShHResult.Rows[j].Cells[3].Value + "','" + dgridShHResult.Rows[j].Cells[4].Value + "','H','" + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; OledbHelper.sqlExecuteNonQuery(sql); } } } private void FrmShResult_Load(object sender, EventArgs e) { } /// <summary> /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 /// </summary> /// <param name="type"></param> /// <param name="caption"></param> /// <param name="feat"></param> /// <param name="dis"></param> private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List<string> _pipelineLayerNames) { double verticalDistance = 1; if (selectedFeature == null) { selectState = 0; MessageBox.Show("请选择一条管线!"); return; } GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; if (line1 == null) { selectState = 0; MessageBox.Show("请选择一条管线!"); return; } //GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); string caption = selectedFeature.Dataset.Caption; GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); GSOPoint3d pntProIntersect1 = new GSOPoint3d(); GSOPoint3d pntProIntersect2 = new GSOPoint3d(); for (int i = 0; i < _pipelineLayerNames.Count; i++) { verticalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); if (caption == _pipelineLayerNames[i]) { continue; } GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); if (layer2 != null) { GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); for (int j = 0; j < feats2.Length; j++) { GSOFeature feat2 = feats2[j]; GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; if (line2 == null) continue; double dDist = -1; dDist = globleControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); if (dDist > -1) { if (dDist < verticalDistance) { int idx = -1; GSOPoint3d markerPosition = new GSOPoint3d(); if (type == "垂直净距分析") { feat2.HighLight = true; /* if (dDist.ToString("0.00") != "0.00") { * */ markerPosition = LabelVerticalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); idx = dgridShVResult.Rows.Add(); dgridShVResult.Rows[idx].Cells[0].Value = caption; dgridShVResult.Rows[idx].Cells[1].Value = selectedFeature.Name; dgridShVResult.Rows[idx].Cells[2].Value = layer2.Caption; dgridShVResult.Rows[idx].Cells[3].Value = feat2.Name; dgridShVResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); dgridShVResult.Rows[idx].Cells[5].Value = verticalDistance.ToString("0.00"); // } } } } line2.ReleaseInnerPointer(); feat2.ReleaseInnerPointer(); } feats2.ReleaseInnerPointer(); } } line1.ReleaseInnerPointer(); selectedFeature.ReleaseInnerPointer(); } /// <summary> /// 查找指定图层中在 指定范围内的feature对象集合 /// </summary> /// <param name="polygon"></param> /// <param name="layername"></param> /// <returns></returns> private GSOFeatures Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername) { GSOFeatures feats = new GSOFeatures(); GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); if (layer == null) { return feats; } GSOFeatureLayer flayer = layer as GSOFeatureLayer; if (flayer != null) { GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; } if (polygon == null) { feats = flayer.GetAllFeatures(); } else { feats = flayer.FindFeaturesInPolygon(polygon, false); } return feats; } /// <summary> /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 /// </summary> /// <param name="markerLayer"></param> /// <param name="pntIntersect1"></param> /// <param name="pntIntersect2"></param> /// <param name="distance"></param> /// <returns></returns> private GSOPoint3d LabelVerticalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) { if (pntIntersect1 == null || pntIntersect2 == null) { return new GSOPoint3d(); } 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; GSOFeature line = new GSOFeature(); line.Geometry = disline; GSOGeoMarker dismarker = new GSOGeoMarker(); dismarker.X = pntIntersect1.X; dismarker.Y = pntIntersect1.Y; dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; dismarker.Text = "垂直"+distance.ToString("0.00") + "米"; dismarker.AltitudeMode = EnumAltitudeMode.Absolute; GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); GSOTextStyle styleText = new GSOTextStyle(); styleText.IsSizeFixed = true; styleText.ForeColor = Color.White; styleText.FontSize = 20; styleMarker.TextStyle = styleText; dismarker.Style = styleMarker; GSOFeature marker = new GSOFeature(); marker.Geometry = dismarker; line.Visible = marker.Visible = markerVisible; markerLayer.AddFeature(line); markerLayer.AddFeature(marker); return dismarker.Position; } private GSOPoint3d LabelHorizontalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) { if (pntIntersect1 == null || pntIntersect2 == null) { return new GSOPoint3d(); } 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; GSOFeature line = new GSOFeature(); line.Geometry = disline; GSOGeoMarker dismarker = new GSOGeoMarker(); dismarker.X = pntIntersect1.X; dismarker.Y = pntIntersect1.Y; dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; dismarker.Text = "水平" + distance.ToString("0.00") + "米"; dismarker.AltitudeMode = EnumAltitudeMode.Absolute; GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); GSOTextStyle styleText = new GSOTextStyle(); styleText.IsSizeFixed = true; styleText.ForeColor = Color.White; styleText.FontSize = 20; styleMarker.TextStyle = styleText; dismarker.Style = styleMarker; GSOFeature marker = new GSOFeature(); marker.Geometry = dismarker; line.Visible = marker.Visible = markerVisible; markerLayer.AddFeature(line); markerLayer.AddFeature(marker); return dismarker.Position; } /// <summary> /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 /// </summary> /// <param name="type"></param> /// <param name="caption"></param> /// <param name="feat"></param> /// <param name="dis"></param> private void HorizontalDistanceAnalysis(string type, GSOFeature selectedFeature, List<string> _pipelineLayerNames) { double horizontalDistance = 1; #region if (selectedFeature == null) { selectState = 0; MessageBox.Show("请选择一条管线!"); return; } GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; if (line1 == null) { selectState = 0; MessageBox.Show("请选择一条管线!"); return; } string caption = selectedFeature.Dataset.Caption; GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); GSOPoint3d pntProIntersect1 = new GSOPoint3d(); GSOPoint3d pntProIntersect2 = new GSOPoint3d(); for (int i = 0; i < _pipelineLayerNames.Count; i++) { horizontalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); GSOGeoPolygon3D polygon = line1.CreateBuffer(horizontalDistance, true, 5, true, false); if (caption == _pipelineLayerNames[i]) { continue; } GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); if (layer2 != null) { GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); for (int j = 0; j < feats2.Length; j++) { GSOFeature feat2 = feats2[j]; GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; if (line2 == null) { continue; } double dDist = -1; dDist = globleControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); if (dDist > -1) { if (dDist < horizontalDistance) { GSOPoint3d markerPosition = new GSOPoint3d(); if (type == "水平净距分析") { /* if (dDist.ToString("0.00") != "0.00") { * */ feat2.HighLight = true; int idx = dgridShHResult.Rows.Add(); markerPosition = LabelHorizontalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); dgridShHResult.Rows[idx].Tag = feat2; dgridShHResult.Rows[idx].Cells[0].Value = caption; dgridShHResult.Rows[idx].Cells[1].Value = selectedFeature.Name; dgridShHResult.Rows[idx].Cells[2].Value = layer2.Caption; dgridShHResult.Rows[idx].Cells[3].Value = feats2[j].Name; dgridShHResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); dgridShHResult.Rows[idx].Cells[5].Value = horizontalDistance.ToString(); } //} } } } } } #endregion } /// <summary> /// 双击后围绕问题对象旋转 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgridShVResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { string scLayer = dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString(); string scFeatureName = dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString(); GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); GSOFeature scgsoFeature = scgsoFeatures[0]; AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); highlight(); /* string shlayer = (dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString()); string shlayerid = (dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString()); GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); if (centerlayer != null) { for (int j = 0; j < feats.Length; j++) { if (feats[j].Name == shlayerid) { //m_feature = features[j]; GSOFeature rowFeature = feats[j]; if (rowFeature == null) continue; if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = rowFeature.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]; globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); ///高亮 //LightMenu_Click(sender, e); hlfeature = rowFeature; highlight(); } else { globleControl1.Globe.JumpToFeature(rowFeature, 300); } } } } */ } } /// <summary> /// 双击后围绕问题对象旋转 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgridShHResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { string scLayer = dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString(); string scFeatureName = dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString(); GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); GSOFeature scgsoFeature = scgsoFeatures[0]; AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); highlight(); /* string shlayer = (dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString()); string shlayerid = (dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString()); GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); if (centerlayer != null) { for (int j = 0; j < feats.Length; j++) { if (feats[j].Name == shlayerid) { //m_feature = features[j]; GSOFeature rowFeature = feats[j]; if (rowFeature == null) continue; if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = rowFeature.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]; globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 30); globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); //高亮显示 hlfeature = rowFeature; highlight(); } else { globleControl1.Globe.JumpToFeature(rowFeature, 300); } } } } */ } } /// <summary> /// 清除渲染结果 /// </summary> public void ClearAnalyseResult() { dgridShHResult.Rows.Clear(); dgridShVResult.Rows.Clear(); layerTemp.RemoveAllFeature(); globleControl1.Refresh(); } /// <summary> /// 高亮显示 /// </summary> public void highlight(){ flashflag = "single"; timer1.Start(); } /// <summary> /// 使用timer实现管线的闪烁效果 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer1_Tick(object sender, EventArgs e) { GSOFeature rowFeature = hlfeature;//as GSOFeature; if (rowFeature == null) return; if (count < 40) { count++; if (flashflag == "single") { if (rowFeature != null) { if (count % 2 != 0) { rowFeature.HighLight = true; globleControl1.Refresh(); } else { rowFeature.HighLight = false; globleControl1.Refresh(); } } } } else { timer1.Stop(); rowFeature.HighLight = false; count = 0; } } private void FrmShResult_FormClosed(object sender, FormClosedEventArgs e) { mainfrm.boolfrmShResult = false; } /// <summary> /// 一键审核导出 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonExp1_Click(object sender, EventArgs e) { if (dgridShHResult.Rows.Count > 0 || dgridShVResult.Rows.Count > 0) { string strSaveFile = string.Empty; SaveFileDialog savefiledialog = new SaveFileDialog(); savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; savefiledialog.AddExtension = true; savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second; if (savefiledialog.ShowDialog() == DialogResult.OK) { strSaveFile = savefiledialog.FileName; } else { return; } ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); MessageBox.Show("导出成功!"); } else { MessageBox.Show("表格内容为空!", "提示"); } } /// <summary> /// 地球场景中添加lable标注 /// </summary> /// <param name="glb"></param> /// <param name="gsoFeature"></param> /// <param name="FeatureName"></param> private void AddMakerToLayer(GSOGlobeControl glb, GSOFeature gsoFeature, string FeatureName) { glb.Globe.MemoryLayer.RemoveAllFeature(); GSOFeature radiusMarkerFeature; if (gsoFeature != null) { GSOGeoPolyline3D selLine = gsoFeature.Geometry as GSOGeoPolyline3D; if (selLine[0].Count > 1) { GSOLayer makerLayer = glb.Globe.MemoryLayer; GSOGeoPoint3D pt = new GSOGeoPoint3D(); GSOPoint3d point3d = selLine.GeoCenterPoint; pt.X = point3d.X; pt.Y = point3d.Y; pt.Z = point3d.Z; glb.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 200); string radiusLabelName = FeatureName; radiusMarkerFeature = new GSOFeature(); GSOPoint2d point2d = new GSOPoint2d(0, 50); if (makerLayer != null) { if (getLabelName(makerLayer) != -1) { radiusMarkerFeature = createLabel(makerLayer, radiusMarkerFeature, pt, radiusLabelName, (getLabelName(makerLayer) + 1).ToString(), point2d); radiusMarkerFeature.Visible = true; makerLayer.AddFeature(radiusMarkerFeature); } } glb.Refresh(); } } } /// <summary> /// 获取指定图层中最后一个feature对象的名称对应的整数 /// </summary> /// <param name="layer"></param> /// <returns></returns> public int getLabelName(GSOLayer layer) { int nid = -1; if (layer.GetAllFeatures().Length > 0) { string id = layer.GetAllFeatures()[layer.GetAllFeatures().Length - 1].Name; int.TryParse(id, out nid); } else { nid = 0; } return nid; } /// <summary> /// /// </summary> /// <param name="layer"></param> /// <param name="feature"></param> /// <param name="point"></param> /// <param name="labelName"></param> /// <param name="featureName"></param> /// <param name="point2d"></param> /// <returns></returns> private GSOFeature createLabel(GSOLayer layer, GSOFeature feature, GSOGeoPoint3D point, string labelName, string featureName, GSOPoint2d point2d) { for (int i = layer.GetAllFeatures().Length - 1; i >= 0; i--) { GSOFeature gfeat = layer.GetAt(i); if (gfeat != null && gfeat.Geometry != null && gfeat.Geometry.Type == EnumGeometryType.GeoPoint3D) { GSOGeoPoint3D pointItem = gfeat.Geometry as GSOGeoPoint3D; if (pointItem.X == point.X && pointItem.Y == point.Y && pointItem.Z == point.Z) { layer.RemoveAt(i); break; } } } point.AltitudeMode = EnumAltitudeMode.Absolute; feature.Geometry = point; feature.Name = featureName; GSOLabel newLabel = new GSOLabel(); newLabel.Text = labelName; newLabel.Style = new GSOLabelStyle(); newLabel.Style.Opaque = 0.8; newLabel.Style.OutlineColor = Color.Gray; newLabel.Style.TractionLineEndPos = point2d; newLabel.Style.OutlineWidth = 1; newLabel.Style.TracktionLineWidth = 3; newLabel.Style.TractionLineColor = Color.Green; Color color1 = Color.FromArgb(60, 187, 206, 230); Color color2 = Color.FromArgb(150, 187, 200, 250); newLabel.Style.BackBeginColor = color1; newLabel.Style.BackEndColor = color2; feature.Label = newLabel; return feature; } } }