using System; using System.Collections.Generic; using System.Data; using GeoScene.Data; using GeoScene.Engine; using GeoScene.Globe; namespace Cyberpipe { static class DoublePanelAnalysis { public static int bufferWidth = 8; public static string strLabel; public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); GSOPoint3d pntProIntersect1 = new GSOPoint3d(); GSOPoint3d pntProIntersect2 = new GSOPoint3d(); vertical = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); horizon = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); } public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { ClearHighlight(globeControl1); ClearHighlight(globeControl2); } static void ClearHighlight(GSOGlobeControl ctl) { for (int i = 0; i < ctl.Globe.Layers.Count; i++) { GSOLayer layer = ctl.Globe.Layers[i]; if (layer is GSOFeatureLayer) { GSOFeatures feats = layer.GetAllFeatures(); for (int j = 0; j < feats.Length; j++) { GSOFeature feat = feats[j]; feat.HighLight = false; } } } } static void intalDataTable(DataTable dt) { dt.Columns.Add("实测图层"); dt.Columns.Add("实测管段"); dt.Columns.Add("施工图层"); dt.Columns.Add("施工管段"); dt.Columns.Add("水平距离/m"); dt.Columns.Add("水平净距国标/m"); dt.Columns.Add("垂直距离/m"); dt.Columns.Add("垂直净距国标/m"); dt.Columns.Add("检测结果"); } /// <summary> /// 单Feature对比方法 /// </summary> /// <param name="srcFeature"></param> /// <param name="dscFeature"></param> public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { DataTable dt = new DataTable(); intalDataTable(dt); if (scLayer.Caption.Contains("给水") || scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { strLabel = "目标图层包含不符合《给水排水构筑物工程施工及验收规范》(GB50141-2008)要求的管段,具体内容如下:"; CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } return dt; } /// <summary> /// 生成给排水监测结果表格 /// </summary> /// <param name="scLayer"></param> /// <param name="sgLayer"></param> /// <param name="road"></param> /// <param name="dt"></param> public static void CreateJiPaiShuiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { //给排水监测 for (int i = 0; i < scLayer.GetAllFeatures().Length; i++) { GSOFeature scFeature = scLayer.GetAt(i); if (scFeature.GetFieldAsString("所属道路") != road) continue; GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); InsertDataToJSDataTable(sgFeatures, scFeature, scLayer, sgLayer, scLine, globeControl1, globeControl2, dt); } } static void InsertDataToJSDataTable(GSOFeatures sgFeatures, GSOFeature scFeature, GSOLayer scLayer, GSOLayer sgLayer, GSOGeoPolyline3D scLine,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2,DataTable dt) { GSOFeature sgFeature = null; //**判断同一个Feature if (sgFeatures.Length < 1 || GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth) == null) //不存在对应的施工管段 { scFeature.HighLight = true; DataRow dr = dt.NewRow(); dr[0] = scLayer.Caption; dr[1] = scFeature.GetFieldAsString("编号"); dr[2] = sgLayer.Caption; dr[3] = "无"; dr[4] = "无"; dr[5] = scLayer.Caption.Contains("给水") ? "0.03" : "0.015"; dr[6] = "无"; if (scFeature.GetFieldAsDouble("起始管底高程") <= 1) dr[7] = scLayer.Caption.Contains("给水") ? "0.03" : "0.1"; else dr[7] = scLayer.Caption.Contains("给水") ? "0.03" : "0.015"; dr[8] = "未设计管段"; dt.Rows.Add(dr); } else { sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, globeControl2); JiShuiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); } } /// <summary> /// 生成燃气监测结果表格 /// </summary> /// <param name="scLayer"></param> /// <param name="sgLayer"></param> /// <param name="road"></param> /// <param name="dt"></param> public static void CreateRanQiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { //燃气监测 for (int i = 0; i < scLayer.GetAllFeatures().Length; i++) { GSOFeature scFeature = scLayer.GetAt(i); if (scFeature.GetFieldAsString("所属道路") != road) continue; GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); InsertDataToRQDataTable(sgFeatures, scFeature, scLayer, sgLayer, scLine, globeControl1, globeControl2, dt); } } static void InsertDataToRQDataTable(GSOFeatures sgFeatures, GSOFeature scFeature, GSOLayer scLayer, GSOLayer sgLayer, GSOGeoPolyline3D scLine, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2, DataTable dt) { GSOFeature sgFeature = null; //**判断同一个Feature if (sgFeatures.Length < 1 || GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth) == null) { scFeature.HighLight = true; DataRow dr = dt.NewRow(); dr[0] = scLayer.Caption; dr[1] = scFeature.GetFieldAsString("编号"); dr[2] = sgLayer.Caption; dr[3] = "无"; dr[4] = "无"; dr[5] = "0.06"; dr[6] = "无"; dr[7] = "0.06"; dr[8] = "未设计管段"; dt.Rows.Add(dr); } else { sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, globeControl2); RanQiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); } } /// <summary> /// 生成供电监测结果表格 /// </summary> /// <param name="scLayer"></param> /// <param name="sgLayer"></param> /// <param name="road"></param> /// <param name="dt"></param> public static void CreateGongDianDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { //供电监测 for (int i = 0; i < scLayer.GetAllFeatures().Length; i++) { GSOFeature scFeature = scLayer.GetAt(i); if (scFeature.GetFieldAsString("所属道路") != road) continue; GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); InsertDataToGDDataTable(sgFeatures, scFeature, scLayer, sgLayer, scLine, globeControl1, globeControl2, dt); } } static void InsertDataToGDDataTable(GSOFeatures sgFeatures, GSOFeature scFeature, GSOLayer scLayer, GSOLayer sgLayer, GSOGeoPolyline3D scLine, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2, DataTable dt) { GSOFeature sgFeature = null; //**判断同一个Feature if (sgFeatures.Length < 1 || GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth) == null) { scFeature.HighLight = true; DataRow dr = dt.NewRow(); dr[0] = scLayer.Caption; dr[1] = scFeature.GetFieldAsString("编号"); dr[2] = sgLayer.Caption; dr[3] = "无"; dr[4] = "无"; dr[5] = "0.02"; dr[6] = "无"; dr[7] = "0.02"; dr[8] = "未设计管段"; dt.Rows.Add(dr); } else { sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, globeControl2); GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); } } #region Fan Zhang 重构feature获取 public static double getLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) { GSOFeatures fullInPolygonFeatures = srcLayer.FindFeaturesInPolygon(bufferPolygon, true); for (int n = 0; n < fullInPolygonFeatures.Length; n++) { if (src.ID == fullInPolygonFeatures[n].ID) { GSOGeoPolyline3D line = src.Geometry as GSOGeoPolyline3D; return line.GetSpaceLength(false, 6378137); } } //算切割 GSOFeature featurePolygon = new GSOFeature(); featurePolygon.Geometry = bufferPolygon; GSOFeatures fs = new GSOFeatures(); int result = 0; double tempLength = 0; GSODataEngineUtility.GSPolygonClipLine(src, featurePolygon, out fs, out result); if (result == 1) { for (int k = 0; k < fs.Length; k++) { GSOFeature featureline = fs[k]; if (featureline != null && featureline.Geometry != null && featureline.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D lineAnalysis = featureline.Geometry as GSOGeoPolyline3D; tempLength = lineAnalysis.GetSpaceLength(false, 6378137); } } } return tempLength; } public static GSOFeature GetSameFeature(GSOFeature scFeature, GSOLayer scLayer, GSOLayer sgLayer, double bufferWidth) { GSOFeature reFeature = null; GSOFeatures sgFeaturesList = new GSOFeatures(); //实测管段找施工管段 GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, false); //由施工管段反向寻找实测管段 for (int i = 0; i < sgFeatures.Length; i++) { GSOFeature currentSgFeature = sgFeatures[i]; GSOGeoPolyline3D sgLine = sgFeatures[i].Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D tempBufferPolygon = sgLine.CreateBuffer(bufferWidth, true, 5, true, false); GSOFeatures scFeatures = scLayer.FindFeaturesInPolygon(tempBufferPolygon, false); for (int j = 0; j < scFeatures.Length; j++) { if (scFeatures[j].Name == scFeature.Name) { sgFeaturesList.Add(currentSgFeature); break; } } } if (sgFeaturesList.Length == 0) return null; if (sgFeaturesList.Length == 1) return sgFeaturesList[0]; reFeature = sgFeaturesList[0]; double maxLength = Double.MaxValue; for (int m = 0; m < sgFeaturesList.Length; m++) { GSOFeature tempFeature = sgFeaturesList[m]; double tempLength = getLineLength(tempFeature, sgLayer, bufferPolygon); double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); if (lengthAbs < maxLength) { reFeature = sgFeaturesList[m]; maxLength = lengthAbs; } } return reFeature; } #endregion /// <summary> /// 给排水规范审核 /// </summary> /// <param name="scLayerName"></param> /// <param name="sgLayerName"></param> /// <param name="scFeature"></param> /// <param name="sgFeature"></param> /// <param name="horizonDistance"></param> /// <param name="verticalDistance"></param> /// <param name="dt"></param> public static void JiShuiAnalysis(string scLayerName, string sgLayerName, GSOFeature scFeature, GSOFeature sgFeature, double horizonDistance, double verticalDistance, DataTable dt) { bool dtBool = false; DataRow dr = dt.NewRow(); dr[0] = scLayerName; dr[1] = scFeature.GetFieldAsString("编号"); dr[2] = sgLayerName; dr[3] = sgFeature.GetFieldAsString("编号"); if (scLayerName.Contains("给水")) { //水平 if (horizonDistance > 0.03) { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.03"; dr[8] = dr[8] + "水平净距"; scFeature.HighLight = true; dtBool = true; } else { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.03"; } //垂直 if (Math.Abs(verticalDistance) > 0.03) { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.03"; dr[8] = dr[8] + "垂直净距"; scFeature.HighLight = true; dtBool = true; } else { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.03"; } dr[8] = dr[8] + "超标"; } else { if (horizonDistance > 0.015) { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.015"; scFeature.HighLight = true; dr[8] = dr[8] + "水平净距"; dtBool = true; } else { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.015"; } if (scFeature.GetFieldAsDouble("起始管底高程") <= 1) { if (Math.Abs(verticalDistance) > 0.01) { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.01"; scFeature.HighLight = true; dr[8] = dr[8] + "垂直净距"; dtBool = true; } else { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.01"; } } else { if (Math.Abs(verticalDistance) > 0.015) { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.015"; scFeature.HighLight = true; dr[8] = dr[8] + "垂直净距"; dtBool = true; } else { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.015"; } } dr[8] = dr[8] + "超标"; } if (!dtBool) return; dt.Rows.Add(dr); } /// <summary> /// 燃气规范审核 /// </summary> /// <param name="scLayerName"></param> /// <param name="sgLayerName"></param> /// <param name="scFeature"></param> /// <param name="sgFeature"></param> /// <param name="horizonDistance"></param> /// <param name="verticalDistance"></param> /// <param name="dt"></param> public static void RanQiAnalysis(string scLayerName, string sgLayerName, GSOFeature scFeature, GSOFeature sgFeature, double horizonDistance, double verticalDistance, DataTable dt) { bool dtBool = false; DataRow dr = dt.NewRow(); dr[0] = scLayerName; dr[1] = scFeature.GetFieldAsString("编号"); dr[2] = sgLayerName; dr[3] = sgFeature.GetFieldAsString("编号"); //水平 if (horizonDistance > 0.06) { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.06"; dr[8] = dr[8] + "水平净距"; scFeature.HighLight = true; dtBool = true; } else { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.06"; } //垂直 if (Math.Abs(verticalDistance) > 0.06) { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.06"; dr[8] = dr[8] + "垂直净距"; scFeature.HighLight = true; dtBool = true; } else { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.06"; } dr[8] = dr[8] + "超标"; if (!dtBool) return; dt.Rows.Add(dr); } /// <summary> /// 供电规范审核 /// </summary> /// <param name="scLayerName"></param> /// <param name="sgLayerName"></param> /// <param name="scFeature"></param> /// <param name="sgFeature"></param> /// <param name="horizonDistance"></param> /// <param name="verticalDistance"></param> /// <param name="dt"></param> public static void GongDianAnalysis(string scLayerName, string sgLayerName, GSOFeature scFeature, GSOFeature sgFeature, double horizonDistance, double verticalDistance, DataTable dt) { bool dtBool = false; DataRow dr = dt.NewRow(); dr[0] = scLayerName; dr[1] = scFeature.GetFieldAsString("编号"); dr[2] = sgLayerName; dr[3] = sgFeature.GetFieldAsString("编号"); //水平 if (horizonDistance > 0.02) { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.02"; dr[8] = dr[8] + "水平净距"; scFeature.HighLight = true; dtBool = true; } else { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.02"; } //垂直 if (Math.Abs(verticalDistance) > 0.02) { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.02"; dr[8] = dr[8] + "垂直净距"; scFeature.HighLight = true; dtBool = true; } else { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.02"; } dr[8] = dr[8] + "超标"; if (!dtBool) return; dt.Rows.Add(dr); } #region wxl 重构 碰撞审查,覆土审查,水平净距审查,垂直净距审查 //TODO LIST:UNDONE /// <summary> /// 获取跟选择管线垂直距离小于特定值的管线列表和选择管线的距离 /// </summary> /// <param name="globeControl">地球</param> /// <param name="selectedFeature">选择管线</param> /// <param name="pipelineLayerNames">各图层名称</param> /// <param name="verticalDistance">垂直距离</param> /// <returns>管线列表,可为空</returns> public static Dictionary<GSOFeature, double> VerticalDistanceAnalysis(GSOGlobeControl globeControl, GSOFeature selectedFeature, List<string> pipelineLayerNames, double verticalDistance ) { if (selectedFeature == null) return null; GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; if (line1 == null) return null; GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D; if (pipeStyle1 == null) return null; GSOGeoPolygon3D polygon = line1.CreateBuffer(0.1, true, 5, true, false);//要比较的区域 Dictionary<GSOFeature, double> result = new Dictionary<GSOFeature, double>(); string caption = selectedFeature.Dataset.Caption; foreach (string pipelineName in pipelineLayerNames) { if (caption == pipelineName) continue;//排除本图层 GSOLayer layer2 = globeControl.Globe.Layers.GetLayerByCaption(pipelineName); if (layer2 == null) continue; GSOFeatures feats2 = FeatureStatisticsService.GetLayerFeatures(polygon, layer2); if (feats2 == null) continue; for (int j = 0; j < feats2.Length; j++) { GSOFeature feat2 = feats2[j]; GSOGeoPolyline3D line2 = feat2.Geometry as GSOGeoPolyline3D; if (line2 == null) continue; GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D; if (pipeStyle2 == null) continue; GSOPoint3d pntIntersect1, pntIntersect2, pntProIntersect1, pntProIntersect2; double dDist = globeControl.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); if (dDist >= verticalDistance) continue;//不符合条件 result.Add(feat2,dDist); } } return result; } /// <summary> /// 获取与选定管线水平距离小于特定值的<管线,管线距离>Dictionary /// </summary> /// <param name="globeControl"></param> /// <param name="selectedFeature"></param> /// <param name="pipelineLayerNames"></param> /// <param name="dis"></param> /// <returns>选择的为空或不是管线则返回空,否则返回符合条件的Dictionary</returns> public static Dictionary<GSOFeature, double> HorizontalDistanceAnalysis(GSOGlobeControl globeControl,GSOFeature selectedFeature, List<string> pipelineLayerNames, double dis) { if (selectedFeature == null) return null; GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; if (line1 == null) return null; GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D; if (pipeStyle1 == null) return null; Dictionary<GSOFeature, double> result = new Dictionary<GSOFeature, double>(); string caption = selectedFeature.Dataset.Caption; GSOGeoPolygon3D polygon = line1.CreateBuffer(dis, true, 5, true, false); GSOFeature newFeat = new GSOFeature(); newFeat.Geometry = polygon; foreach (string pipelineName in pipelineLayerNames) { if (caption == pipelineName) continue; GSOLayer layer2 = globeControl.Globe.Layers.GetLayerByCaption(pipelineName); if (layer2 == null) continue; GSOFeatures feats2 = FeatureStatisticsService.GetLayerFeatures(polygon, layer2); for (int j = 0; j < feats2.Length; j++) { GSOFeature feat2 = feats2[j]; GSOGeoPolyline3D line2 = feat2.Geometry as GSOGeoPolyline3D; if (line2 == null) continue; GSOPoint3d pntIntersect1, pntIntersect2, pntProIntersect1, pntProIntersect2; double dDist = globeControl.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D; if (pipeStyle2 == null) continue; result.Add(feat2,dDist); } } return result; } /// <summary> ///碰撞检测,获取与选择管线碰撞的管线 /// </summary> /// <param name="globeControl">地球</param> /// <param name="selectedFeature">选中的feature</param> /// <param name="pipelineLayerNames">图层列表</param> /// <returns></returns> public static GSOFeatures CollisionAnalysis(GSOGlobeControl globeControl, GSOFeature selectedFeature, List<string> pipelineLayerNames) { if (selectedFeature == null) return null; GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; if (line1 == null) return null; GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D; if (pipeStyle1 == null) return null; GSOGeoPolygon3D polygon = line1.CreateBuffer(0.1, true, 5, true, false);//要比较的区域 GSOFeatures result = new GSOFeatures(); string caption = selectedFeature.Dataset.Caption; foreach (string pipelineName in pipelineLayerNames) { if (caption == pipelineName) continue;//排除本图层 GSOLayer layer2 = globeControl.Globe.Layers.GetLayerByCaption(pipelineName); if (layer2 == null) continue; GSOFeatures feats2 = FeatureStatisticsService.GetLayerFeatures(polygon, layer2); if (feats2 == null) continue; for (int j = 0; j < feats2.Length; j++) { double horLen, verLen, dNoIntersetStartRatio=0; GSOFeature feat2 = feats2[j]; GSOGeoPolyline3D line2 = feat2.Geometry as GSOGeoPolyline3D; if (line2 == null) continue; GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D; if (pipeStyle2 == null) continue; GSOPoint3d pntIntersect1, pntIntersect2; double dDist = globeControl.Globe.Analysis3D.ComputeTwoGeoPolylineDistance(line1, line2, out pntIntersect1, out pntIntersect2,out horLen,out verLen,true,true,dNoIntersetStartRatio); if (dDist <= 0 ) result.Add(feat2); } } return result; } #endregion } }