using System; using System.Collections.Generic; using System.Data; using System.Drawing; 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 clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { FeatureTools.ClearAllFeatureHighLight(globeControl1); FeatureTools.ClearAllFeatureHighLight(globeControl2); } /// <summary> /// 国标检测中根据道路比较实测图层和施工图层是否符合标准 /// </summary> /// <param name="scLayer"></param> /// <param name="sgLayer"></param> /// <param name="road"></param> /// <param name="globeControl1"></param> /// <param name="globeControl2"></param> /// <returns></returns> public static DataTable CompareLayerByRoad(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { DataTable dt = new DataTable(); 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("检测结果"); if (scLayer.Caption.Contains("给水") || scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { strLabel = "目标图层包含不符合《给水排水构筑物工程施工及验收规范》(GB50141-2008)要求的管段,具体内容如下:"; } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; } GBJCDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); return 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> /// 国标检测table计算,某道路下的施工和实测feature的对比信息 /// </summary> /// <param name="scLayer"></param> /// <param name="sgLayer"></param> /// <param name="road"></param> /// <param name="dt"></param> /// <param name="globeControl1"></param> /// <param name="globeControl2"></param> public static void GBJCDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { GSOFeatures scFeatures = scLayer.GetFeatureByFieldValue("所属道路", road, true); double hStandard = 0.02, vStandard = 0.02; //水平净距标准和垂直净距标准,默认供电管线标准 if (scLayer.Caption.Contains("给水")) { hStandard = 0.03; vStandard = 0.03; } else if (scLayer.Caption.Contains("燃气")) { hStandard = 0.06; vStandard = 0.06; } for (int i=0;i<scFeatures.Length;i++) { GSOFeature scFeature = scFeatures[i]; GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; if (scLine == null) continue; GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); GSOFeature sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); if (scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { hStandard = 0.015; vStandard = 0.015; if (scFeature.GetFieldAsDouble("起始管底高程") <= 1) { vStandard = 0.01; } } if (sgFeatures.Length < 1 || sgFeature == 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] = hStandard; dr[6] = "无"; dr[7] = vStandard; dr[8] = "未设计管段"; dt.Rows.Add(dr); } else { GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; ClassDoubleScreenCompare.CalculateDistance(scLine, sgLine, out verticalDistance, out horizonDistance, globeControl1, globeControl2); RowValueInsert(scFeature, sgFeature, horizonDistance, verticalDistance,hStandard,vStandard,dt); } } } /// <summary> /// 填充datatable的行,如果符合标准,则直接返回 /// </summary> /// <param name="scFeature"></param> /// <param name="sgFeature"></param> /// <param name="horizonDistance"></param> /// <param name="verticalDistance"></param> /// <param name="hStandard"></param> /// <param name="vStandard"></param> /// <param name="dt"></param> private static void RowValueInsert(GSOFeature scFeature, GSOFeature sgFeature, double horizonDistance, double verticalDistance,double hStandard,double vStandard,DataTable dt) { //符合标准 if (horizonDistance <= hStandard && verticalDistance <= vStandard) return; string scLayerName = scFeature.Dataset.Caption; DataRow dr = dt.NewRow(); dr[0] = scLayerName; dr[1] = scFeature.GetFieldAsString("编号"); dr[2] = sgFeature.Dataset.Caption; dr[3] = sgFeature.GetFieldAsString("编号"); dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = hStandard.ToString(); dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = vStandard.ToString(); if (horizonDistance > hStandard) { dr[8] = "水平净距超标"; scFeature.HighLight = true; } if (verticalDistance > vStandard) { scFeature.HighLight = true; dr[8] += " 垂直净距超标"; } dt.Rows.Add(dr); } #region wxl 重构 碰撞审查,覆土审查,水平净距审查,垂直净距审查 /// <summary> /// 获取跟选择管线垂直距离小于特定值的管线列表和选择管线的距离 /// </summary> /// <param name="globeControl">地球</param> /// <param name="selectedFeature">选择管线</param> /// <param name="pipelineLayerNames">各图层名称</param> /// <param name="verticalDistance">垂直距离</param> /// <returns>管线列表,可为空</returns> public static List<FeatureAnalysisInfo> 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);//要比较的区域 List<FeatureAnalysisInfo> featureAnalysisInfos = new List<FeatureAnalysisInfo>(); 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;//不符合条件 FeatureAnalysisInfo featureAnalysisInfo = new FeatureAnalysisInfo(); featureAnalysisInfo.point1 = pntIntersect1; featureAnalysisInfo.point2 = pntIntersect2; featureAnalysisInfo.distance = dDist; featureAnalysisInfo.feature = feat2; featureAnalysisInfos.Add(featureAnalysisInfo); } } return featureAnalysisInfos; } /// <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 List<FeatureAnalysisInfo> 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);//要比较的区域 List<FeatureAnalysisInfo> result = new List<FeatureAnalysisInfo>(); 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); // dDist = Math.Abs(pntIntersect1.Z - pntIntersect2.Z) - pipeStyle1.Radius - pipeStyle2.Radius; dDist = dDist - pipeStyle1.Radius - pipeStyle2.Radius; if (dDist <= 0) { FeatureAnalysisInfo featureAnalysisInfo = new FeatureAnalysisInfo(); featureAnalysisInfo.feature = feat2; featureAnalysisInfo.point1 = pntIntersect1; featureAnalysisInfo.point2 = pntIntersect2; result.Add(featureAnalysisInfo); } } } return result; } /// <summary> /// 计算出距离后,增加画线和marker /// </summary> public static GSOPoint3d MakeLabel(GSOLayer layer, GSOPoint3d point1, GSOPoint3d point2, string info, Boolean visiable) { MarkInfo markerInfo = new MarkInfo(); markerInfo.Desc = info; GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); GSOPoint3ds point3Ds = new GSOPoint3ds(); point3Ds.Add(point1); point3Ds.Add(point2); 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 = point1.X; dismarker.Y = point1.Y; dismarker.Z = (point1.Z + point2.Z) / 2; dismarker.Text = info; 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 = visiable; layer.AddFeature(line); layer.AddFeature(marker); return dismarker.Position; } #endregion } }