diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs index f386814..80427c3 100644 --- a/ClassGSOTool.cs +++ b/ClassGSOTool.cs @@ -143,7 +143,6 @@ } } #endregion - } } /// diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs index f386814..80427c3 100644 --- a/ClassGSOTool.cs +++ b/ClassGSOTool.cs @@ -143,7 +143,6 @@ } } #endregion - } } /// diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 5658f3c..e43d638 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs index f386814..80427c3 100644 --- a/ClassGSOTool.cs +++ b/ClassGSOTool.cs @@ -143,7 +143,6 @@ } } #endregion - } } /// diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 5658f3c..e43d638 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index e89f552..7a8afb2 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -9,13 +9,11 @@ { static class DoublePanelAnalysis { - public static GSOGlobeControl globeControl1 = null; - public static GSOGlobeControl globeControl2 = null; public static int bufferWidth = 8; public static string strLabel; public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2) + GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); @@ -27,11 +25,7 @@ out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); } - /// - /// 清除所有高亮Feature - /// - /// - public static void clearFeatureHighLight() + public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { ClearHighlight(globeControl1); ClearHighlight(globeControl2); @@ -54,14 +48,8 @@ } } - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer,string road) + static void intalDataTable(DataTable dt) { - DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); dt.Columns.Add("实测管段"); dt.Columns.Add("施工图层"); @@ -71,24 +59,36 @@ dt.Columns.Add("垂直距离/m"); dt.Columns.Add("垂直净距国标/m"); dt.Columns.Add("检测结果"); + } + + /// + /// 单Feature对比方法 + /// + /// + /// + 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); + CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; - CreateRanQiDataTable(scLayer, sgLayer, road, dt); + CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; - CreateGongDianDataTable(scLayer, sgLayer, road, dt); + CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } return dt; } + /// /// 生成给排水监测结果表格 /// @@ -96,83 +96,58 @@ /// /// /// - public static void CreateJiPaiShuiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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) - { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + if (scFeature.GetFieldAsString("所属道路") != road) continue; - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - //**判断同一个Feature - - if (sgFeatures.Length >= 1) - { + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - sgFeature = GetSameFeature2(scFeature, scLayer, sgLayer, bufferWidth); + 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 (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; + 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); - JiShuiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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.01"; - } - else - { - dr[7] = scLayer.Caption.Contains("给水") ? "0.03" : "0.015"; - } - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } - } - else - { - 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); - } - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + globeControl2); + JiShuiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, + verticalDistance, dt); } } /// @@ -182,65 +157,55 @@ /// /// /// - public static void CreateRanQiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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) - { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - //**判断同一个Feature - if (sgFeatures.Length >= 1) - { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + 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); - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - RanQiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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 - { - 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); - } - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + globeControl2); + RanQiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, + verticalDistance, dt); } } /// @@ -250,7 +215,8 @@ /// /// /// - public static void CreateGongDianDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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++) @@ -260,55 +226,131 @@ GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - GSOFeature sgFeature = null; GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) - { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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 - { - 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); - } + 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 /// /// 给排水规范审核 /// @@ -319,7 +361,8 @@ /// /// /// - public static void JiShuiAnalysis(string scLayerName, string sgLayerName,GSOFeature scFeature,GSOFeature sgFeature, double horizonDistance, double verticalDistance,DataTable dt) + public static void JiShuiAnalysis(string scLayerName, string sgLayerName, GSOFeature scFeature, + GSOFeature sgFeature, double horizonDistance, double verticalDistance, DataTable dt) { bool dtBool = false; @@ -412,226 +455,8 @@ dr[8] = dr[8] + "超标"; } - if (dtBool) - { - dt.Rows.Add(dr); - //count++; - } - } - - #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 GetSameFeature2(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 - - /// - /// 判断同一根管段 - /// - /// - /// - /// - /// - /// - public static GSOFeature GetSameFeature(GSOFeature scFeature, GSOLayer scLayer, GSOLayer sgLayer,double bufferWidth) - { - GSOFeature reFeature = null; - GSOFeatures sgFeaturesList = new GSOFeatures(); - double maxLength = 0; - //实测管段找施工管段 - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, false); - GSOFeatures sgFeatureTrues = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - GSOFeature featurePolygon = new GSOFeature(); - featurePolygon.Geometry = bufferPolygon; - - //由施工管段反向寻找实测管段 - if (sgFeatures.Length == 0) reFeature = null; - else - { - for (int i = 0; i < sgFeatures.Length; i++) - { - GSOGeoPolyline3D sgLine = sgFeatures[i].Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D tempBufferPolygon = sgLine.CreateBuffer(bufferWidth, true, 5, true, false); - - GSOFeatures scFeatures = scLayer.FindFeaturesInPolygon(tempBufferPolygon, false); - if (scFeatures.Length == 0) reFeature = null; - else - { - for (int j = 0; j < scFeatures.Length; j++) - { - if (scFeatures[j].Name == scFeature.Name) - { - sgFeaturesList.Add(sgFeatures[i]); - break; - } - } - } - } - - //长度判断 - if (sgFeaturesList.Length == 0) reFeature = null; - else - { - if (sgFeaturesList.Length == 1) - reFeature = sgFeaturesList[0]; - else - { - for (int m = 0; m < sgFeaturesList.Length; m++) - { - double tempLength = 0; - - GSOFeature feature = sgFeaturesList[m]; - bool isFullInPolygon = false; - for (int n = 0; n < sgFeatureTrues.Length; n++) - { - if (feature.ID == sgFeatureTrues[n].ID) - { - isFullInPolygon = true; - break; - } - } - if (isFullInPolygon) - { - GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; - tempLength = line.GetSpaceLength(false, 6378137); - } - else - { - GSOFeatures fs = new GSOFeatures(); - int result = 0; - GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result); - if (result == 0) - { - //MessageBox.Show("表示用来切割的线、面不合法!"); - } - else if (result == 2) - { - //MessageBox.Show("表示线、面无交点!"); - } - else 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); - } - } - } - } - - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - - if (m == 0) - { - reFeature = sgFeaturesList[0]; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - reFeature = sgFeaturesList[m]; - maxLength = lengthAbs; - } - } - } - } - } - return reFeature; + if (!dtBool) return; + dt.Rows.Add(dr); } /// /// 燃气规范审核 @@ -683,10 +508,8 @@ } dr[8] = dr[8] + "超标"; - if (dtBool) - { - dt.Rows.Add(dr); - } + if (!dtBool) return; + dt.Rows.Add(dr); } /// /// 供电规范审核 @@ -738,13 +561,10 @@ } dr[8] = dr[8] + "超标"; - if (dtBool) - { - dt.Rows.Add(dr); - } + if (!dtBool) return; + dt.Rows.Add(dr); } - #region wxl 重构 碰撞审查,覆土审查,水平净距审查,垂直净距审查 //TODO LIST:UNDONE /// diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs index f386814..80427c3 100644 --- a/ClassGSOTool.cs +++ b/ClassGSOTool.cs @@ -143,7 +143,6 @@ } } #endregion - } } /// diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 5658f3c..e43d638 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index e89f552..7a8afb2 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -9,13 +9,11 @@ { static class DoublePanelAnalysis { - public static GSOGlobeControl globeControl1 = null; - public static GSOGlobeControl globeControl2 = null; public static int bufferWidth = 8; public static string strLabel; public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2) + GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); @@ -27,11 +25,7 @@ out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); } - /// - /// 清除所有高亮Feature - /// - /// - public static void clearFeatureHighLight() + public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { ClearHighlight(globeControl1); ClearHighlight(globeControl2); @@ -54,14 +48,8 @@ } } - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer,string road) + static void intalDataTable(DataTable dt) { - DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); dt.Columns.Add("实测管段"); dt.Columns.Add("施工图层"); @@ -71,24 +59,36 @@ dt.Columns.Add("垂直距离/m"); dt.Columns.Add("垂直净距国标/m"); dt.Columns.Add("检测结果"); + } + + /// + /// 单Feature对比方法 + /// + /// + /// + 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); + CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; - CreateRanQiDataTable(scLayer, sgLayer, road, dt); + CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; - CreateGongDianDataTable(scLayer, sgLayer, road, dt); + CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } return dt; } + /// /// 生成给排水监测结果表格 /// @@ -96,83 +96,58 @@ /// /// /// - public static void CreateJiPaiShuiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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) - { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + if (scFeature.GetFieldAsString("所属道路") != road) continue; - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - //**判断同一个Feature - - if (sgFeatures.Length >= 1) - { + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - sgFeature = GetSameFeature2(scFeature, scLayer, sgLayer, bufferWidth); + 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 (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; + 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); - JiShuiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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.01"; - } - else - { - dr[7] = scLayer.Caption.Contains("给水") ? "0.03" : "0.015"; - } - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } - } - else - { - 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); - } - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + globeControl2); + JiShuiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, + verticalDistance, dt); } } /// @@ -182,65 +157,55 @@ /// /// /// - public static void CreateRanQiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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) - { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - //**判断同一个Feature - if (sgFeatures.Length >= 1) - { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + 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); - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - RanQiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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 - { - 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); - } - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + globeControl2); + RanQiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, + verticalDistance, dt); } } /// @@ -250,7 +215,8 @@ /// /// /// - public static void CreateGongDianDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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++) @@ -260,55 +226,131 @@ GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - GSOFeature sgFeature = null; GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) - { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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 - { - 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); - } + 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 /// /// 给排水规范审核 /// @@ -319,7 +361,8 @@ /// /// /// - public static void JiShuiAnalysis(string scLayerName, string sgLayerName,GSOFeature scFeature,GSOFeature sgFeature, double horizonDistance, double verticalDistance,DataTable dt) + public static void JiShuiAnalysis(string scLayerName, string sgLayerName, GSOFeature scFeature, + GSOFeature sgFeature, double horizonDistance, double verticalDistance, DataTable dt) { bool dtBool = false; @@ -412,226 +455,8 @@ dr[8] = dr[8] + "超标"; } - if (dtBool) - { - dt.Rows.Add(dr); - //count++; - } - } - - #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 GetSameFeature2(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 - - /// - /// 判断同一根管段 - /// - /// - /// - /// - /// - /// - public static GSOFeature GetSameFeature(GSOFeature scFeature, GSOLayer scLayer, GSOLayer sgLayer,double bufferWidth) - { - GSOFeature reFeature = null; - GSOFeatures sgFeaturesList = new GSOFeatures(); - double maxLength = 0; - //实测管段找施工管段 - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, false); - GSOFeatures sgFeatureTrues = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - GSOFeature featurePolygon = new GSOFeature(); - featurePolygon.Geometry = bufferPolygon; - - //由施工管段反向寻找实测管段 - if (sgFeatures.Length == 0) reFeature = null; - else - { - for (int i = 0; i < sgFeatures.Length; i++) - { - GSOGeoPolyline3D sgLine = sgFeatures[i].Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D tempBufferPolygon = sgLine.CreateBuffer(bufferWidth, true, 5, true, false); - - GSOFeatures scFeatures = scLayer.FindFeaturesInPolygon(tempBufferPolygon, false); - if (scFeatures.Length == 0) reFeature = null; - else - { - for (int j = 0; j < scFeatures.Length; j++) - { - if (scFeatures[j].Name == scFeature.Name) - { - sgFeaturesList.Add(sgFeatures[i]); - break; - } - } - } - } - - //长度判断 - if (sgFeaturesList.Length == 0) reFeature = null; - else - { - if (sgFeaturesList.Length == 1) - reFeature = sgFeaturesList[0]; - else - { - for (int m = 0; m < sgFeaturesList.Length; m++) - { - double tempLength = 0; - - GSOFeature feature = sgFeaturesList[m]; - bool isFullInPolygon = false; - for (int n = 0; n < sgFeatureTrues.Length; n++) - { - if (feature.ID == sgFeatureTrues[n].ID) - { - isFullInPolygon = true; - break; - } - } - if (isFullInPolygon) - { - GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; - tempLength = line.GetSpaceLength(false, 6378137); - } - else - { - GSOFeatures fs = new GSOFeatures(); - int result = 0; - GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result); - if (result == 0) - { - //MessageBox.Show("表示用来切割的线、面不合法!"); - } - else if (result == 2) - { - //MessageBox.Show("表示线、面无交点!"); - } - else 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); - } - } - } - } - - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - - if (m == 0) - { - reFeature = sgFeaturesList[0]; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - reFeature = sgFeaturesList[m]; - maxLength = lengthAbs; - } - } - } - } - } - return reFeature; + if (!dtBool) return; + dt.Rows.Add(dr); } /// /// 燃气规范审核 @@ -683,10 +508,8 @@ } dr[8] = dr[8] + "超标"; - if (dtBool) - { - dt.Rows.Add(dr); - } + if (!dtBool) return; + dt.Rows.Add(dr); } /// /// 供电规范审核 @@ -738,13 +561,10 @@ } dr[8] = dr[8] + "超标"; - if (dtBool) - { - dt.Rows.Add(dr); - } + if (!dtBool) return; + dt.Rows.Add(dr); } - #region wxl 重构 碰撞审查,覆土审查,水平净距审查,垂直净距审查 //TODO LIST:UNDONE /// diff --git a/FrmGBJC.cs b/FrmGBJC.cs index afd5411..38ade64 100644 --- a/FrmGBJC.cs +++ b/FrmGBJC.cs @@ -21,8 +21,8 @@ { this.globeControl1 = _globeControl1; this.globeControl2 = _globeControl2; - DoublePanelAnalysis.globeControl1 = globeControl1; - DoublePanelAnalysis.globeControl2 = globeControl2; + //DoublePanelAnalysis.globeControl1 = globeControl1; + //DoublePanelAnalysis.globeControl2 = globeControl2; this.layerTemp = _layerTemp; this.layerTemp2 = _layerTemp2; InitializeComponent(); @@ -72,21 +72,13 @@ } } } - /// - /// 施工图层列表点击事件 - /// - /// - /// + private void listBoxSG_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxSG.SelectedItem == null) return; textBoxSG.Text = listBoxSG.SelectedItem.ToString(); } - /// - /// 实测图层列表点击事件 - /// - /// - /// + private void listBoxSC_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxSC.SelectedItem == null) return; @@ -112,11 +104,6 @@ } } - /// - /// 确定检测 - /// - /// - /// private void buttonOK_Click(object sender, EventArgs e) { invalParam(); @@ -127,9 +114,9 @@ return; DataTable dt = DoublePanelAnalysis.lineFeatureCompare(scLayer, sgLayer, - comboBoxRoad.SelectedItem.ToString()); + comboBoxRoad.SelectedItem.ToString(), globeControl1, globeControl2); - FrmGBJCresult rs = new FrmGBJCresult(globeControl1, globeControl2, dt, layerTemp, layerTemp2); + FrmGBJCresult rs = new FrmGBJCresult(globeControl1, globeControl2, dt); rs.Show(); this.Close(); } diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs index f386814..80427c3 100644 --- a/ClassGSOTool.cs +++ b/ClassGSOTool.cs @@ -143,7 +143,6 @@ } } #endregion - } } /// diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 5658f3c..e43d638 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index e89f552..7a8afb2 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -9,13 +9,11 @@ { static class DoublePanelAnalysis { - public static GSOGlobeControl globeControl1 = null; - public static GSOGlobeControl globeControl2 = null; public static int bufferWidth = 8; public static string strLabel; public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2) + GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); @@ -27,11 +25,7 @@ out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); } - /// - /// 清除所有高亮Feature - /// - /// - public static void clearFeatureHighLight() + public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { ClearHighlight(globeControl1); ClearHighlight(globeControl2); @@ -54,14 +48,8 @@ } } - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer,string road) + static void intalDataTable(DataTable dt) { - DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); dt.Columns.Add("实测管段"); dt.Columns.Add("施工图层"); @@ -71,24 +59,36 @@ dt.Columns.Add("垂直距离/m"); dt.Columns.Add("垂直净距国标/m"); dt.Columns.Add("检测结果"); + } + + /// + /// 单Feature对比方法 + /// + /// + /// + 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); + CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; - CreateRanQiDataTable(scLayer, sgLayer, road, dt); + CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; - CreateGongDianDataTable(scLayer, sgLayer, road, dt); + CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } return dt; } + /// /// 生成给排水监测结果表格 /// @@ -96,83 +96,58 @@ /// /// /// - public static void CreateJiPaiShuiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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) - { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + if (scFeature.GetFieldAsString("所属道路") != road) continue; - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - //**判断同一个Feature - - if (sgFeatures.Length >= 1) - { + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - sgFeature = GetSameFeature2(scFeature, scLayer, sgLayer, bufferWidth); + 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 (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; + 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); - JiShuiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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.01"; - } - else - { - dr[7] = scLayer.Caption.Contains("给水") ? "0.03" : "0.015"; - } - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } - } - else - { - 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); - } - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + globeControl2); + JiShuiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, + verticalDistance, dt); } } /// @@ -182,65 +157,55 @@ /// /// /// - public static void CreateRanQiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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) - { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - //**判断同一个Feature - if (sgFeatures.Length >= 1) - { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + 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); - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - RanQiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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 - { - 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); - } - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + globeControl2); + RanQiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, + verticalDistance, dt); } } /// @@ -250,7 +215,8 @@ /// /// /// - public static void CreateGongDianDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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++) @@ -260,55 +226,131 @@ GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - GSOFeature sgFeature = null; GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) - { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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 - { - 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); - } + 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 /// /// 给排水规范审核 /// @@ -319,7 +361,8 @@ /// /// /// - public static void JiShuiAnalysis(string scLayerName, string sgLayerName,GSOFeature scFeature,GSOFeature sgFeature, double horizonDistance, double verticalDistance,DataTable dt) + public static void JiShuiAnalysis(string scLayerName, string sgLayerName, GSOFeature scFeature, + GSOFeature sgFeature, double horizonDistance, double verticalDistance, DataTable dt) { bool dtBool = false; @@ -412,226 +455,8 @@ dr[8] = dr[8] + "超标"; } - if (dtBool) - { - dt.Rows.Add(dr); - //count++; - } - } - - #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 GetSameFeature2(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 - - /// - /// 判断同一根管段 - /// - /// - /// - /// - /// - /// - public static GSOFeature GetSameFeature(GSOFeature scFeature, GSOLayer scLayer, GSOLayer sgLayer,double bufferWidth) - { - GSOFeature reFeature = null; - GSOFeatures sgFeaturesList = new GSOFeatures(); - double maxLength = 0; - //实测管段找施工管段 - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, false); - GSOFeatures sgFeatureTrues = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - GSOFeature featurePolygon = new GSOFeature(); - featurePolygon.Geometry = bufferPolygon; - - //由施工管段反向寻找实测管段 - if (sgFeatures.Length == 0) reFeature = null; - else - { - for (int i = 0; i < sgFeatures.Length; i++) - { - GSOGeoPolyline3D sgLine = sgFeatures[i].Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D tempBufferPolygon = sgLine.CreateBuffer(bufferWidth, true, 5, true, false); - - GSOFeatures scFeatures = scLayer.FindFeaturesInPolygon(tempBufferPolygon, false); - if (scFeatures.Length == 0) reFeature = null; - else - { - for (int j = 0; j < scFeatures.Length; j++) - { - if (scFeatures[j].Name == scFeature.Name) - { - sgFeaturesList.Add(sgFeatures[i]); - break; - } - } - } - } - - //长度判断 - if (sgFeaturesList.Length == 0) reFeature = null; - else - { - if (sgFeaturesList.Length == 1) - reFeature = sgFeaturesList[0]; - else - { - for (int m = 0; m < sgFeaturesList.Length; m++) - { - double tempLength = 0; - - GSOFeature feature = sgFeaturesList[m]; - bool isFullInPolygon = false; - for (int n = 0; n < sgFeatureTrues.Length; n++) - { - if (feature.ID == sgFeatureTrues[n].ID) - { - isFullInPolygon = true; - break; - } - } - if (isFullInPolygon) - { - GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; - tempLength = line.GetSpaceLength(false, 6378137); - } - else - { - GSOFeatures fs = new GSOFeatures(); - int result = 0; - GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result); - if (result == 0) - { - //MessageBox.Show("表示用来切割的线、面不合法!"); - } - else if (result == 2) - { - //MessageBox.Show("表示线、面无交点!"); - } - else 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); - } - } - } - } - - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - - if (m == 0) - { - reFeature = sgFeaturesList[0]; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - reFeature = sgFeaturesList[m]; - maxLength = lengthAbs; - } - } - } - } - } - return reFeature; + if (!dtBool) return; + dt.Rows.Add(dr); } /// /// 燃气规范审核 @@ -683,10 +508,8 @@ } dr[8] = dr[8] + "超标"; - if (dtBool) - { - dt.Rows.Add(dr); - } + if (!dtBool) return; + dt.Rows.Add(dr); } /// /// 供电规范审核 @@ -738,13 +561,10 @@ } dr[8] = dr[8] + "超标"; - if (dtBool) - { - dt.Rows.Add(dr); - } + if (!dtBool) return; + dt.Rows.Add(dr); } - #region wxl 重构 碰撞审查,覆土审查,水平净距审查,垂直净距审查 //TODO LIST:UNDONE /// diff --git a/FrmGBJC.cs b/FrmGBJC.cs index afd5411..38ade64 100644 --- a/FrmGBJC.cs +++ b/FrmGBJC.cs @@ -21,8 +21,8 @@ { this.globeControl1 = _globeControl1; this.globeControl2 = _globeControl2; - DoublePanelAnalysis.globeControl1 = globeControl1; - DoublePanelAnalysis.globeControl2 = globeControl2; + //DoublePanelAnalysis.globeControl1 = globeControl1; + //DoublePanelAnalysis.globeControl2 = globeControl2; this.layerTemp = _layerTemp; this.layerTemp2 = _layerTemp2; InitializeComponent(); @@ -72,21 +72,13 @@ } } } - /// - /// 施工图层列表点击事件 - /// - /// - /// + private void listBoxSG_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxSG.SelectedItem == null) return; textBoxSG.Text = listBoxSG.SelectedItem.ToString(); } - /// - /// 实测图层列表点击事件 - /// - /// - /// + private void listBoxSC_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxSC.SelectedItem == null) return; @@ -112,11 +104,6 @@ } } - /// - /// 确定检测 - /// - /// - /// private void buttonOK_Click(object sender, EventArgs e) { invalParam(); @@ -127,9 +114,9 @@ return; DataTable dt = DoublePanelAnalysis.lineFeatureCompare(scLayer, sgLayer, - comboBoxRoad.SelectedItem.ToString()); + comboBoxRoad.SelectedItem.ToString(), globeControl1, globeControl2); - FrmGBJCresult rs = new FrmGBJCresult(globeControl1, globeControl2, dt, layerTemp, layerTemp2); + FrmGBJCresult rs = new FrmGBJCresult(globeControl1, globeControl2, dt); rs.Show(); this.Close(); } diff --git a/FrmGBJCresult.cs b/FrmGBJCresult.cs index 7be6604..c1931c0 100644 --- a/FrmGBJCresult.cs +++ b/FrmGBJCresult.cs @@ -13,21 +13,17 @@ DataTable dt; GSOGlobeControl globeControl1; GSOGlobeControl globeControl2; - GSOLayer layerTemp; - GSOLayer layerTemp2; - public FrmGBJCresult(GSOGlobeControl _golbeControl1, GSOGlobeControl _golbeControl2, DataTable _dt,GSOLayer _layerTemp,GSOLayer _layerTemp2) + public FrmGBJCresult(GSOGlobeControl _golbeControl1, GSOGlobeControl _golbeControl2, DataTable _dt) { globeControl1=_golbeControl1; globeControl2 = _golbeControl2; dt = _dt; - layerTemp = _layerTemp; - layerTemp2 = _layerTemp2; InitializeComponent(); labelX1.Text = DoublePanelAnalysis.strLabel; } - private void FrmGBJCresult_Load(object sender, EventArgs e) + void intalDatagridView() { dataGridViewX1.DataSource = dt; dataGridViewX1.Columns[0].Width = 80; @@ -39,16 +35,18 @@ dataGridViewX1.Columns[6].Width = 70; dataGridViewX1.Columns[7].Width = 80; } - /// - /// 结果表双击事件,在地球场景中添加缓冲区和管段的标注 - /// - /// - /// + + private void FrmGBJCresult_Load(object sender, EventArgs e) + { + intalDatagridView(); + } + private void dataGridViewX1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) return; - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); + globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); + //获取globeControl1飞行目标 string scLayer = dataGridViewX1.Rows[e.RowIndex].Cells["实测图层"].Value.ToString(); string scFeatureName = dataGridViewX1.Rows[e.RowIndex].Cells["实测管段"].Value.ToString(); @@ -63,17 +61,20 @@ GSOFeatures sggsoFeatures = sggsoLayer.GetFeatureByName(sgFeatureName, false); GSOFeature sggsoFeature = sggsoFeatures[0]; - AddPolygon(scgsoFeature); + addLabelAndFlyToPosition(scgsoFeature, sggsoFeature); + } - AddMakerToLayer(globeControl1, scgsoFeature, scFeatureName); - if (sggsoFeature != null) - { - AddMakerToLayer(globeControl2, sggsoFeature, sgFeatureName); - } + void addLabelAndFlyToPosition(GSOFeature scFeature, GSOFeature sgFeature) + { + AddPolygon(scFeature); + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, scFeature); + if (sgFeature != null) + ClassSearchAnalysis.AddMakerToLineFeature(globeControl2, sgFeature); else { globeControl2.Globe.MemoryLayer.RemoveAllFeature(); - GSOGeoPolyline3D scLine = scgsoFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; if (scLine[0].Count <= 1) return; GSOGeoPoint3D pt = new GSOGeoPoint3D(); GSOPoint3d point3d = scLine.GeoCenterPoint; @@ -83,147 +84,32 @@ globeControl2.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 200); } } - /// - /// 双屏中通知增加实测数据的缓冲区 - /// - /// + private void AddPolygon(GSOFeature scFeature) { - GSOFeature new_feat= new GSOFeature(); + GSOFeature new_feat= new GSOFeature(); GSOGeoPolyline3D line = scFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D resPolygon = new GSOGeoPolygon3D(); - resPolygon = line.CreateBuffer(DoublePanelAnalysis.bufferWidth, true, 0, false, false); resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; new_feat.Geometry = resPolygon; - layerTemp.AddFeature(new_feat); - layerTemp2.AddFeature(new_feat); - + globeControl1.Globe.MemoryLayer.AddFeature(new_feat); + globeControl2.Globe.MemoryLayer.AddFeature(new_feat); globeControl1.Refresh(); globeControl2.Refresh(); } - /// - /// 地球场景中添加lable标注 - /// - /// - /// - /// - private void AddMakerToLayer(GSOGlobeControl glb, GSOFeature gsoFeature, string FeatureName) - { - glb.Globe.MemoryLayer.RemoveAllFeature(); - GSOFeature radiusMarkerFeature; - if (gsoFeature == null) return; - GSOGeoPolyline3D selLine = gsoFeature.Geometry as GSOGeoPolyline3D; - - if (selLine[0].Count <= 1) return; - 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(); - } - /// - /// 获取指定图层中最后一个feature对象的名称对应的整数 - /// - /// - /// - public int getLabelName(GSOLayer layer) - { - int nid = -1; - if (layer.GetAllFeatures().Length <= 0) - { - nid = 0; - } - else - { - string id = layer.GetAllFeatures()[layer.GetAllFeatures().Length - 1].Name; - int.TryParse(id, out nid); - } - return nid; - } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - 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) - continue; - GSOGeoPoint3D pointItem = gfeat.Geometry as GSOGeoPoint3D; - if (pointItem.X != point.X || pointItem.Y != point.Y || pointItem.Z != point.Z) continue; - layer.RemoveAt(i); - break; - } - point.AltitudeMode = EnumAltitudeMode.RelativeToGround; - 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; - } - /// - /// - /// - /// - /// private void FrmGBJCresult_FormClosing(object sender, FormClosingEventArgs e) { globeControl1.Globe.MemoryLayer.RemoveAllFeature(); globeControl2.Globe.MemoryLayer.RemoveAllFeature(); - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); + globeControl1.Refresh(); + globeControl2.Refresh(); } - /// - /// 导出EXCEL - /// - /// - /// + private void buttonEXPexcel_Click(object sender, EventArgs e) { try diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs index f386814..80427c3 100644 --- a/ClassGSOTool.cs +++ b/ClassGSOTool.cs @@ -143,7 +143,6 @@ } } #endregion - } } /// diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 5658f3c..e43d638 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index e89f552..7a8afb2 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -9,13 +9,11 @@ { static class DoublePanelAnalysis { - public static GSOGlobeControl globeControl1 = null; - public static GSOGlobeControl globeControl2 = null; public static int bufferWidth = 8; public static string strLabel; public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2) + GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); @@ -27,11 +25,7 @@ out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); } - /// - /// 清除所有高亮Feature - /// - /// - public static void clearFeatureHighLight() + public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { ClearHighlight(globeControl1); ClearHighlight(globeControl2); @@ -54,14 +48,8 @@ } } - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer,string road) + static void intalDataTable(DataTable dt) { - DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); dt.Columns.Add("实测管段"); dt.Columns.Add("施工图层"); @@ -71,24 +59,36 @@ dt.Columns.Add("垂直距离/m"); dt.Columns.Add("垂直净距国标/m"); dt.Columns.Add("检测结果"); + } + + /// + /// 单Feature对比方法 + /// + /// + /// + 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); + CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; - CreateRanQiDataTable(scLayer, sgLayer, road, dt); + CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; - CreateGongDianDataTable(scLayer, sgLayer, road, dt); + CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } return dt; } + /// /// 生成给排水监测结果表格 /// @@ -96,83 +96,58 @@ /// /// /// - public static void CreateJiPaiShuiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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) - { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + if (scFeature.GetFieldAsString("所属道路") != road) continue; - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - //**判断同一个Feature - - if (sgFeatures.Length >= 1) - { + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - sgFeature = GetSameFeature2(scFeature, scLayer, sgLayer, bufferWidth); + 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 (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; + 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); - JiShuiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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.01"; - } - else - { - dr[7] = scLayer.Caption.Contains("给水") ? "0.03" : "0.015"; - } - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } - } - else - { - 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); - } - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + globeControl2); + JiShuiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, + verticalDistance, dt); } } /// @@ -182,65 +157,55 @@ /// /// /// - public static void CreateRanQiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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) - { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - //**判断同一个Feature - if (sgFeatures.Length >= 1) - { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + 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); - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - RanQiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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 - { - 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); - } - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + globeControl2); + RanQiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, + verticalDistance, dt); } } /// @@ -250,7 +215,8 @@ /// /// /// - public static void CreateGongDianDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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++) @@ -260,55 +226,131 @@ GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - GSOFeature sgFeature = null; GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) - { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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 - { - 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); - } + 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 /// /// 给排水规范审核 /// @@ -319,7 +361,8 @@ /// /// /// - public static void JiShuiAnalysis(string scLayerName, string sgLayerName,GSOFeature scFeature,GSOFeature sgFeature, double horizonDistance, double verticalDistance,DataTable dt) + public static void JiShuiAnalysis(string scLayerName, string sgLayerName, GSOFeature scFeature, + GSOFeature sgFeature, double horizonDistance, double verticalDistance, DataTable dt) { bool dtBool = false; @@ -412,226 +455,8 @@ dr[8] = dr[8] + "超标"; } - if (dtBool) - { - dt.Rows.Add(dr); - //count++; - } - } - - #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 GetSameFeature2(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 - - /// - /// 判断同一根管段 - /// - /// - /// - /// - /// - /// - public static GSOFeature GetSameFeature(GSOFeature scFeature, GSOLayer scLayer, GSOLayer sgLayer,double bufferWidth) - { - GSOFeature reFeature = null; - GSOFeatures sgFeaturesList = new GSOFeatures(); - double maxLength = 0; - //实测管段找施工管段 - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, false); - GSOFeatures sgFeatureTrues = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - GSOFeature featurePolygon = new GSOFeature(); - featurePolygon.Geometry = bufferPolygon; - - //由施工管段反向寻找实测管段 - if (sgFeatures.Length == 0) reFeature = null; - else - { - for (int i = 0; i < sgFeatures.Length; i++) - { - GSOGeoPolyline3D sgLine = sgFeatures[i].Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D tempBufferPolygon = sgLine.CreateBuffer(bufferWidth, true, 5, true, false); - - GSOFeatures scFeatures = scLayer.FindFeaturesInPolygon(tempBufferPolygon, false); - if (scFeatures.Length == 0) reFeature = null; - else - { - for (int j = 0; j < scFeatures.Length; j++) - { - if (scFeatures[j].Name == scFeature.Name) - { - sgFeaturesList.Add(sgFeatures[i]); - break; - } - } - } - } - - //长度判断 - if (sgFeaturesList.Length == 0) reFeature = null; - else - { - if (sgFeaturesList.Length == 1) - reFeature = sgFeaturesList[0]; - else - { - for (int m = 0; m < sgFeaturesList.Length; m++) - { - double tempLength = 0; - - GSOFeature feature = sgFeaturesList[m]; - bool isFullInPolygon = false; - for (int n = 0; n < sgFeatureTrues.Length; n++) - { - if (feature.ID == sgFeatureTrues[n].ID) - { - isFullInPolygon = true; - break; - } - } - if (isFullInPolygon) - { - GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; - tempLength = line.GetSpaceLength(false, 6378137); - } - else - { - GSOFeatures fs = new GSOFeatures(); - int result = 0; - GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result); - if (result == 0) - { - //MessageBox.Show("表示用来切割的线、面不合法!"); - } - else if (result == 2) - { - //MessageBox.Show("表示线、面无交点!"); - } - else 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); - } - } - } - } - - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - - if (m == 0) - { - reFeature = sgFeaturesList[0]; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - reFeature = sgFeaturesList[m]; - maxLength = lengthAbs; - } - } - } - } - } - return reFeature; + if (!dtBool) return; + dt.Rows.Add(dr); } /// /// 燃气规范审核 @@ -683,10 +508,8 @@ } dr[8] = dr[8] + "超标"; - if (dtBool) - { - dt.Rows.Add(dr); - } + if (!dtBool) return; + dt.Rows.Add(dr); } /// /// 供电规范审核 @@ -738,13 +561,10 @@ } dr[8] = dr[8] + "超标"; - if (dtBool) - { - dt.Rows.Add(dr); - } + if (!dtBool) return; + dt.Rows.Add(dr); } - #region wxl 重构 碰撞审查,覆土审查,水平净距审查,垂直净距审查 //TODO LIST:UNDONE /// diff --git a/FrmGBJC.cs b/FrmGBJC.cs index afd5411..38ade64 100644 --- a/FrmGBJC.cs +++ b/FrmGBJC.cs @@ -21,8 +21,8 @@ { this.globeControl1 = _globeControl1; this.globeControl2 = _globeControl2; - DoublePanelAnalysis.globeControl1 = globeControl1; - DoublePanelAnalysis.globeControl2 = globeControl2; + //DoublePanelAnalysis.globeControl1 = globeControl1; + //DoublePanelAnalysis.globeControl2 = globeControl2; this.layerTemp = _layerTemp; this.layerTemp2 = _layerTemp2; InitializeComponent(); @@ -72,21 +72,13 @@ } } } - /// - /// 施工图层列表点击事件 - /// - /// - /// + private void listBoxSG_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxSG.SelectedItem == null) return; textBoxSG.Text = listBoxSG.SelectedItem.ToString(); } - /// - /// 实测图层列表点击事件 - /// - /// - /// + private void listBoxSC_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxSC.SelectedItem == null) return; @@ -112,11 +104,6 @@ } } - /// - /// 确定检测 - /// - /// - /// private void buttonOK_Click(object sender, EventArgs e) { invalParam(); @@ -127,9 +114,9 @@ return; DataTable dt = DoublePanelAnalysis.lineFeatureCompare(scLayer, sgLayer, - comboBoxRoad.SelectedItem.ToString()); + comboBoxRoad.SelectedItem.ToString(), globeControl1, globeControl2); - FrmGBJCresult rs = new FrmGBJCresult(globeControl1, globeControl2, dt, layerTemp, layerTemp2); + FrmGBJCresult rs = new FrmGBJCresult(globeControl1, globeControl2, dt); rs.Show(); this.Close(); } diff --git a/FrmGBJCresult.cs b/FrmGBJCresult.cs index 7be6604..c1931c0 100644 --- a/FrmGBJCresult.cs +++ b/FrmGBJCresult.cs @@ -13,21 +13,17 @@ DataTable dt; GSOGlobeControl globeControl1; GSOGlobeControl globeControl2; - GSOLayer layerTemp; - GSOLayer layerTemp2; - public FrmGBJCresult(GSOGlobeControl _golbeControl1, GSOGlobeControl _golbeControl2, DataTable _dt,GSOLayer _layerTemp,GSOLayer _layerTemp2) + public FrmGBJCresult(GSOGlobeControl _golbeControl1, GSOGlobeControl _golbeControl2, DataTable _dt) { globeControl1=_golbeControl1; globeControl2 = _golbeControl2; dt = _dt; - layerTemp = _layerTemp; - layerTemp2 = _layerTemp2; InitializeComponent(); labelX1.Text = DoublePanelAnalysis.strLabel; } - private void FrmGBJCresult_Load(object sender, EventArgs e) + void intalDatagridView() { dataGridViewX1.DataSource = dt; dataGridViewX1.Columns[0].Width = 80; @@ -39,16 +35,18 @@ dataGridViewX1.Columns[6].Width = 70; dataGridViewX1.Columns[7].Width = 80; } - /// - /// 结果表双击事件,在地球场景中添加缓冲区和管段的标注 - /// - /// - /// + + private void FrmGBJCresult_Load(object sender, EventArgs e) + { + intalDatagridView(); + } + private void dataGridViewX1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) return; - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); + globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); + //获取globeControl1飞行目标 string scLayer = dataGridViewX1.Rows[e.RowIndex].Cells["实测图层"].Value.ToString(); string scFeatureName = dataGridViewX1.Rows[e.RowIndex].Cells["实测管段"].Value.ToString(); @@ -63,17 +61,20 @@ GSOFeatures sggsoFeatures = sggsoLayer.GetFeatureByName(sgFeatureName, false); GSOFeature sggsoFeature = sggsoFeatures[0]; - AddPolygon(scgsoFeature); + addLabelAndFlyToPosition(scgsoFeature, sggsoFeature); + } - AddMakerToLayer(globeControl1, scgsoFeature, scFeatureName); - if (sggsoFeature != null) - { - AddMakerToLayer(globeControl2, sggsoFeature, sgFeatureName); - } + void addLabelAndFlyToPosition(GSOFeature scFeature, GSOFeature sgFeature) + { + AddPolygon(scFeature); + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, scFeature); + if (sgFeature != null) + ClassSearchAnalysis.AddMakerToLineFeature(globeControl2, sgFeature); else { globeControl2.Globe.MemoryLayer.RemoveAllFeature(); - GSOGeoPolyline3D scLine = scgsoFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; if (scLine[0].Count <= 1) return; GSOGeoPoint3D pt = new GSOGeoPoint3D(); GSOPoint3d point3d = scLine.GeoCenterPoint; @@ -83,147 +84,32 @@ globeControl2.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 200); } } - /// - /// 双屏中通知增加实测数据的缓冲区 - /// - /// + private void AddPolygon(GSOFeature scFeature) { - GSOFeature new_feat= new GSOFeature(); + GSOFeature new_feat= new GSOFeature(); GSOGeoPolyline3D line = scFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D resPolygon = new GSOGeoPolygon3D(); - resPolygon = line.CreateBuffer(DoublePanelAnalysis.bufferWidth, true, 0, false, false); resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; new_feat.Geometry = resPolygon; - layerTemp.AddFeature(new_feat); - layerTemp2.AddFeature(new_feat); - + globeControl1.Globe.MemoryLayer.AddFeature(new_feat); + globeControl2.Globe.MemoryLayer.AddFeature(new_feat); globeControl1.Refresh(); globeControl2.Refresh(); } - /// - /// 地球场景中添加lable标注 - /// - /// - /// - /// - private void AddMakerToLayer(GSOGlobeControl glb, GSOFeature gsoFeature, string FeatureName) - { - glb.Globe.MemoryLayer.RemoveAllFeature(); - GSOFeature radiusMarkerFeature; - if (gsoFeature == null) return; - GSOGeoPolyline3D selLine = gsoFeature.Geometry as GSOGeoPolyline3D; - - if (selLine[0].Count <= 1) return; - 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(); - } - /// - /// 获取指定图层中最后一个feature对象的名称对应的整数 - /// - /// - /// - public int getLabelName(GSOLayer layer) - { - int nid = -1; - if (layer.GetAllFeatures().Length <= 0) - { - nid = 0; - } - else - { - string id = layer.GetAllFeatures()[layer.GetAllFeatures().Length - 1].Name; - int.TryParse(id, out nid); - } - return nid; - } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - 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) - continue; - GSOGeoPoint3D pointItem = gfeat.Geometry as GSOGeoPoint3D; - if (pointItem.X != point.X || pointItem.Y != point.Y || pointItem.Z != point.Z) continue; - layer.RemoveAt(i); - break; - } - point.AltitudeMode = EnumAltitudeMode.RelativeToGround; - 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; - } - /// - /// - /// - /// - /// private void FrmGBJCresult_FormClosing(object sender, FormClosingEventArgs e) { globeControl1.Globe.MemoryLayer.RemoveAllFeature(); globeControl2.Globe.MemoryLayer.RemoveAllFeature(); - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); + globeControl1.Refresh(); + globeControl2.Refresh(); } - /// - /// 导出EXCEL - /// - /// - /// + private void buttonEXPexcel_Click(object sender, EventArgs e) { try diff --git a/MainFrm.cs b/MainFrm.cs index 90e7786..8d8e53b 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -2876,7 +2876,6 @@ FullScreen(); } break; - default: break; } diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs index f386814..80427c3 100644 --- a/ClassGSOTool.cs +++ b/ClassGSOTool.cs @@ -143,7 +143,6 @@ } } #endregion - } } /// diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 5658f3c..e43d638 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index e89f552..7a8afb2 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -9,13 +9,11 @@ { static class DoublePanelAnalysis { - public static GSOGlobeControl globeControl1 = null; - public static GSOGlobeControl globeControl2 = null; public static int bufferWidth = 8; public static string strLabel; public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2) + GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); @@ -27,11 +25,7 @@ out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); } - /// - /// 清除所有高亮Feature - /// - /// - public static void clearFeatureHighLight() + public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { ClearHighlight(globeControl1); ClearHighlight(globeControl2); @@ -54,14 +48,8 @@ } } - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer,string road) + static void intalDataTable(DataTable dt) { - DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); dt.Columns.Add("实测管段"); dt.Columns.Add("施工图层"); @@ -71,24 +59,36 @@ dt.Columns.Add("垂直距离/m"); dt.Columns.Add("垂直净距国标/m"); dt.Columns.Add("检测结果"); + } + + /// + /// 单Feature对比方法 + /// + /// + /// + 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); + CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; - CreateRanQiDataTable(scLayer, sgLayer, road, dt); + CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; - CreateGongDianDataTable(scLayer, sgLayer, road, dt); + CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } return dt; } + /// /// 生成给排水监测结果表格 /// @@ -96,83 +96,58 @@ /// /// /// - public static void CreateJiPaiShuiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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) - { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + if (scFeature.GetFieldAsString("所属道路") != road) continue; - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - //**判断同一个Feature - - if (sgFeatures.Length >= 1) - { + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - sgFeature = GetSameFeature2(scFeature, scLayer, sgLayer, bufferWidth); + 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 (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; + 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); - JiShuiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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.01"; - } - else - { - dr[7] = scLayer.Caption.Contains("给水") ? "0.03" : "0.015"; - } - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } - } - else - { - 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); - } - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + globeControl2); + JiShuiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, + verticalDistance, dt); } } /// @@ -182,65 +157,55 @@ /// /// /// - public static void CreateRanQiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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) - { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - //**判断同一个Feature - if (sgFeatures.Length >= 1) - { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + 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); - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - RanQiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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 - { - 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); - } - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + globeControl2); + RanQiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, + verticalDistance, dt); } } /// @@ -250,7 +215,8 @@ /// /// /// - public static void CreateGongDianDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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++) @@ -260,55 +226,131 @@ GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - GSOFeature sgFeature = null; GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) - { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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 - { - 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); - } + 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 /// /// 给排水规范审核 /// @@ -319,7 +361,8 @@ /// /// /// - public static void JiShuiAnalysis(string scLayerName, string sgLayerName,GSOFeature scFeature,GSOFeature sgFeature, double horizonDistance, double verticalDistance,DataTable dt) + public static void JiShuiAnalysis(string scLayerName, string sgLayerName, GSOFeature scFeature, + GSOFeature sgFeature, double horizonDistance, double verticalDistance, DataTable dt) { bool dtBool = false; @@ -412,226 +455,8 @@ dr[8] = dr[8] + "超标"; } - if (dtBool) - { - dt.Rows.Add(dr); - //count++; - } - } - - #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 GetSameFeature2(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 - - /// - /// 判断同一根管段 - /// - /// - /// - /// - /// - /// - public static GSOFeature GetSameFeature(GSOFeature scFeature, GSOLayer scLayer, GSOLayer sgLayer,double bufferWidth) - { - GSOFeature reFeature = null; - GSOFeatures sgFeaturesList = new GSOFeatures(); - double maxLength = 0; - //实测管段找施工管段 - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, false); - GSOFeatures sgFeatureTrues = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - GSOFeature featurePolygon = new GSOFeature(); - featurePolygon.Geometry = bufferPolygon; - - //由施工管段反向寻找实测管段 - if (sgFeatures.Length == 0) reFeature = null; - else - { - for (int i = 0; i < sgFeatures.Length; i++) - { - GSOGeoPolyline3D sgLine = sgFeatures[i].Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D tempBufferPolygon = sgLine.CreateBuffer(bufferWidth, true, 5, true, false); - - GSOFeatures scFeatures = scLayer.FindFeaturesInPolygon(tempBufferPolygon, false); - if (scFeatures.Length == 0) reFeature = null; - else - { - for (int j = 0; j < scFeatures.Length; j++) - { - if (scFeatures[j].Name == scFeature.Name) - { - sgFeaturesList.Add(sgFeatures[i]); - break; - } - } - } - } - - //长度判断 - if (sgFeaturesList.Length == 0) reFeature = null; - else - { - if (sgFeaturesList.Length == 1) - reFeature = sgFeaturesList[0]; - else - { - for (int m = 0; m < sgFeaturesList.Length; m++) - { - double tempLength = 0; - - GSOFeature feature = sgFeaturesList[m]; - bool isFullInPolygon = false; - for (int n = 0; n < sgFeatureTrues.Length; n++) - { - if (feature.ID == sgFeatureTrues[n].ID) - { - isFullInPolygon = true; - break; - } - } - if (isFullInPolygon) - { - GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; - tempLength = line.GetSpaceLength(false, 6378137); - } - else - { - GSOFeatures fs = new GSOFeatures(); - int result = 0; - GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result); - if (result == 0) - { - //MessageBox.Show("表示用来切割的线、面不合法!"); - } - else if (result == 2) - { - //MessageBox.Show("表示线、面无交点!"); - } - else 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); - } - } - } - } - - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - - if (m == 0) - { - reFeature = sgFeaturesList[0]; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - reFeature = sgFeaturesList[m]; - maxLength = lengthAbs; - } - } - } - } - } - return reFeature; + if (!dtBool) return; + dt.Rows.Add(dr); } /// /// 燃气规范审核 @@ -683,10 +508,8 @@ } dr[8] = dr[8] + "超标"; - if (dtBool) - { - dt.Rows.Add(dr); - } + if (!dtBool) return; + dt.Rows.Add(dr); } /// /// 供电规范审核 @@ -738,13 +561,10 @@ } dr[8] = dr[8] + "超标"; - if (dtBool) - { - dt.Rows.Add(dr); - } + if (!dtBool) return; + dt.Rows.Add(dr); } - #region wxl 重构 碰撞审查,覆土审查,水平净距审查,垂直净距审查 //TODO LIST:UNDONE /// diff --git a/FrmGBJC.cs b/FrmGBJC.cs index afd5411..38ade64 100644 --- a/FrmGBJC.cs +++ b/FrmGBJC.cs @@ -21,8 +21,8 @@ { this.globeControl1 = _globeControl1; this.globeControl2 = _globeControl2; - DoublePanelAnalysis.globeControl1 = globeControl1; - DoublePanelAnalysis.globeControl2 = globeControl2; + //DoublePanelAnalysis.globeControl1 = globeControl1; + //DoublePanelAnalysis.globeControl2 = globeControl2; this.layerTemp = _layerTemp; this.layerTemp2 = _layerTemp2; InitializeComponent(); @@ -72,21 +72,13 @@ } } } - /// - /// 施工图层列表点击事件 - /// - /// - /// + private void listBoxSG_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxSG.SelectedItem == null) return; textBoxSG.Text = listBoxSG.SelectedItem.ToString(); } - /// - /// 实测图层列表点击事件 - /// - /// - /// + private void listBoxSC_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxSC.SelectedItem == null) return; @@ -112,11 +104,6 @@ } } - /// - /// 确定检测 - /// - /// - /// private void buttonOK_Click(object sender, EventArgs e) { invalParam(); @@ -127,9 +114,9 @@ return; DataTable dt = DoublePanelAnalysis.lineFeatureCompare(scLayer, sgLayer, - comboBoxRoad.SelectedItem.ToString()); + comboBoxRoad.SelectedItem.ToString(), globeControl1, globeControl2); - FrmGBJCresult rs = new FrmGBJCresult(globeControl1, globeControl2, dt, layerTemp, layerTemp2); + FrmGBJCresult rs = new FrmGBJCresult(globeControl1, globeControl2, dt); rs.Show(); this.Close(); } diff --git a/FrmGBJCresult.cs b/FrmGBJCresult.cs index 7be6604..c1931c0 100644 --- a/FrmGBJCresult.cs +++ b/FrmGBJCresult.cs @@ -13,21 +13,17 @@ DataTable dt; GSOGlobeControl globeControl1; GSOGlobeControl globeControl2; - GSOLayer layerTemp; - GSOLayer layerTemp2; - public FrmGBJCresult(GSOGlobeControl _golbeControl1, GSOGlobeControl _golbeControl2, DataTable _dt,GSOLayer _layerTemp,GSOLayer _layerTemp2) + public FrmGBJCresult(GSOGlobeControl _golbeControl1, GSOGlobeControl _golbeControl2, DataTable _dt) { globeControl1=_golbeControl1; globeControl2 = _golbeControl2; dt = _dt; - layerTemp = _layerTemp; - layerTemp2 = _layerTemp2; InitializeComponent(); labelX1.Text = DoublePanelAnalysis.strLabel; } - private void FrmGBJCresult_Load(object sender, EventArgs e) + void intalDatagridView() { dataGridViewX1.DataSource = dt; dataGridViewX1.Columns[0].Width = 80; @@ -39,16 +35,18 @@ dataGridViewX1.Columns[6].Width = 70; dataGridViewX1.Columns[7].Width = 80; } - /// - /// 结果表双击事件,在地球场景中添加缓冲区和管段的标注 - /// - /// - /// + + private void FrmGBJCresult_Load(object sender, EventArgs e) + { + intalDatagridView(); + } + private void dataGridViewX1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) return; - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); + globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); + //获取globeControl1飞行目标 string scLayer = dataGridViewX1.Rows[e.RowIndex].Cells["实测图层"].Value.ToString(); string scFeatureName = dataGridViewX1.Rows[e.RowIndex].Cells["实测管段"].Value.ToString(); @@ -63,17 +61,20 @@ GSOFeatures sggsoFeatures = sggsoLayer.GetFeatureByName(sgFeatureName, false); GSOFeature sggsoFeature = sggsoFeatures[0]; - AddPolygon(scgsoFeature); + addLabelAndFlyToPosition(scgsoFeature, sggsoFeature); + } - AddMakerToLayer(globeControl1, scgsoFeature, scFeatureName); - if (sggsoFeature != null) - { - AddMakerToLayer(globeControl2, sggsoFeature, sgFeatureName); - } + void addLabelAndFlyToPosition(GSOFeature scFeature, GSOFeature sgFeature) + { + AddPolygon(scFeature); + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, scFeature); + if (sgFeature != null) + ClassSearchAnalysis.AddMakerToLineFeature(globeControl2, sgFeature); else { globeControl2.Globe.MemoryLayer.RemoveAllFeature(); - GSOGeoPolyline3D scLine = scgsoFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; if (scLine[0].Count <= 1) return; GSOGeoPoint3D pt = new GSOGeoPoint3D(); GSOPoint3d point3d = scLine.GeoCenterPoint; @@ -83,147 +84,32 @@ globeControl2.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 200); } } - /// - /// 双屏中通知增加实测数据的缓冲区 - /// - /// + private void AddPolygon(GSOFeature scFeature) { - GSOFeature new_feat= new GSOFeature(); + GSOFeature new_feat= new GSOFeature(); GSOGeoPolyline3D line = scFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D resPolygon = new GSOGeoPolygon3D(); - resPolygon = line.CreateBuffer(DoublePanelAnalysis.bufferWidth, true, 0, false, false); resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; new_feat.Geometry = resPolygon; - layerTemp.AddFeature(new_feat); - layerTemp2.AddFeature(new_feat); - + globeControl1.Globe.MemoryLayer.AddFeature(new_feat); + globeControl2.Globe.MemoryLayer.AddFeature(new_feat); globeControl1.Refresh(); globeControl2.Refresh(); } - /// - /// 地球场景中添加lable标注 - /// - /// - /// - /// - private void AddMakerToLayer(GSOGlobeControl glb, GSOFeature gsoFeature, string FeatureName) - { - glb.Globe.MemoryLayer.RemoveAllFeature(); - GSOFeature radiusMarkerFeature; - if (gsoFeature == null) return; - GSOGeoPolyline3D selLine = gsoFeature.Geometry as GSOGeoPolyline3D; - - if (selLine[0].Count <= 1) return; - 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(); - } - /// - /// 获取指定图层中最后一个feature对象的名称对应的整数 - /// - /// - /// - public int getLabelName(GSOLayer layer) - { - int nid = -1; - if (layer.GetAllFeatures().Length <= 0) - { - nid = 0; - } - else - { - string id = layer.GetAllFeatures()[layer.GetAllFeatures().Length - 1].Name; - int.TryParse(id, out nid); - } - return nid; - } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - 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) - continue; - GSOGeoPoint3D pointItem = gfeat.Geometry as GSOGeoPoint3D; - if (pointItem.X != point.X || pointItem.Y != point.Y || pointItem.Z != point.Z) continue; - layer.RemoveAt(i); - break; - } - point.AltitudeMode = EnumAltitudeMode.RelativeToGround; - 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; - } - /// - /// - /// - /// - /// private void FrmGBJCresult_FormClosing(object sender, FormClosingEventArgs e) { globeControl1.Globe.MemoryLayer.RemoveAllFeature(); globeControl2.Globe.MemoryLayer.RemoveAllFeature(); - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); + globeControl1.Refresh(); + globeControl2.Refresh(); } - /// - /// 导出EXCEL - /// - /// - /// + private void buttonEXPexcel_Click(object sender, EventArgs e) { try diff --git a/MainFrm.cs b/MainFrm.cs index 90e7786..8d8e53b 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -2876,7 +2876,6 @@ FullScreen(); } break; - default: break; } diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe index 53109f7..c7b82be 100644 --- a/bin/x86/Debug/Cyberpipe.exe +++ b/bin/x86/Debug/Cyberpipe.exe Binary files differ diff --git a/ClassGSOTool.cs b/ClassGSOTool.cs index f386814..80427c3 100644 --- a/ClassGSOTool.cs +++ b/ClassGSOTool.cs @@ -143,7 +143,6 @@ } } #endregion - } } /// diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 5658f3c..e43d638 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index e89f552..7a8afb2 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -9,13 +9,11 @@ { static class DoublePanelAnalysis { - public static GSOGlobeControl globeControl1 = null; - public static GSOGlobeControl globeControl2 = null; public static int bufferWidth = 8; public static string strLabel; public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2) + GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); @@ -27,11 +25,7 @@ out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); } - /// - /// 清除所有高亮Feature - /// - /// - public static void clearFeatureHighLight() + public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { ClearHighlight(globeControl1); ClearHighlight(globeControl2); @@ -54,14 +48,8 @@ } } - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer,string road) + static void intalDataTable(DataTable dt) { - DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); dt.Columns.Add("实测管段"); dt.Columns.Add("施工图层"); @@ -71,24 +59,36 @@ dt.Columns.Add("垂直距离/m"); dt.Columns.Add("垂直净距国标/m"); dt.Columns.Add("检测结果"); + } + + /// + /// 单Feature对比方法 + /// + /// + /// + 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); + CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; - CreateRanQiDataTable(scLayer, sgLayer, road, dt); + CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; - CreateGongDianDataTable(scLayer, sgLayer, road, dt); + CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } return dt; } + /// /// 生成给排水监测结果表格 /// @@ -96,83 +96,58 @@ /// /// /// - public static void CreateJiPaiShuiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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) - { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + if (scFeature.GetFieldAsString("所属道路") != road) continue; - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - //**判断同一个Feature - - if (sgFeatures.Length >= 1) - { + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - sgFeature = GetSameFeature2(scFeature, scLayer, sgLayer, bufferWidth); + 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 (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; + 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); - JiShuiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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.01"; - } - else - { - dr[7] = scLayer.Caption.Contains("给水") ? "0.03" : "0.015"; - } - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } - } - else - { - 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); - } - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + globeControl2); + JiShuiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, + verticalDistance, dt); } } /// @@ -182,65 +157,55 @@ /// /// /// - public static void CreateRanQiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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) - { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - //**判断同一个Feature - if (sgFeatures.Length >= 1) - { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + 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); - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - RanQiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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 - { - 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); - } - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + globeControl2); + RanQiAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, + verticalDistance, dt); } } /// @@ -250,7 +215,8 @@ /// /// /// - public static void CreateGongDianDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) + 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++) @@ -260,55 +226,131 @@ GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - GSOFeature sgFeature = null; GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) - { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - 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 - { - 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); - } + 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 /// /// 给排水规范审核 /// @@ -319,7 +361,8 @@ /// /// /// - public static void JiShuiAnalysis(string scLayerName, string sgLayerName,GSOFeature scFeature,GSOFeature sgFeature, double horizonDistance, double verticalDistance,DataTable dt) + public static void JiShuiAnalysis(string scLayerName, string sgLayerName, GSOFeature scFeature, + GSOFeature sgFeature, double horizonDistance, double verticalDistance, DataTable dt) { bool dtBool = false; @@ -412,226 +455,8 @@ dr[8] = dr[8] + "超标"; } - if (dtBool) - { - dt.Rows.Add(dr); - //count++; - } - } - - #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 GetSameFeature2(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 - - /// - /// 判断同一根管段 - /// - /// - /// - /// - /// - /// - public static GSOFeature GetSameFeature(GSOFeature scFeature, GSOLayer scLayer, GSOLayer sgLayer,double bufferWidth) - { - GSOFeature reFeature = null; - GSOFeatures sgFeaturesList = new GSOFeatures(); - double maxLength = 0; - //实测管段找施工管段 - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); - - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, false); - GSOFeatures sgFeatureTrues = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - GSOFeature featurePolygon = new GSOFeature(); - featurePolygon.Geometry = bufferPolygon; - - //由施工管段反向寻找实测管段 - if (sgFeatures.Length == 0) reFeature = null; - else - { - for (int i = 0; i < sgFeatures.Length; i++) - { - GSOGeoPolyline3D sgLine = sgFeatures[i].Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D tempBufferPolygon = sgLine.CreateBuffer(bufferWidth, true, 5, true, false); - - GSOFeatures scFeatures = scLayer.FindFeaturesInPolygon(tempBufferPolygon, false); - if (scFeatures.Length == 0) reFeature = null; - else - { - for (int j = 0; j < scFeatures.Length; j++) - { - if (scFeatures[j].Name == scFeature.Name) - { - sgFeaturesList.Add(sgFeatures[i]); - break; - } - } - } - } - - //长度判断 - if (sgFeaturesList.Length == 0) reFeature = null; - else - { - if (sgFeaturesList.Length == 1) - reFeature = sgFeaturesList[0]; - else - { - for (int m = 0; m < sgFeaturesList.Length; m++) - { - double tempLength = 0; - - GSOFeature feature = sgFeaturesList[m]; - bool isFullInPolygon = false; - for (int n = 0; n < sgFeatureTrues.Length; n++) - { - if (feature.ID == sgFeatureTrues[n].ID) - { - isFullInPolygon = true; - break; - } - } - if (isFullInPolygon) - { - GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; - tempLength = line.GetSpaceLength(false, 6378137); - } - else - { - GSOFeatures fs = new GSOFeatures(); - int result = 0; - GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result); - if (result == 0) - { - //MessageBox.Show("表示用来切割的线、面不合法!"); - } - else if (result == 2) - { - //MessageBox.Show("表示线、面无交点!"); - } - else 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); - } - } - } - } - - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - - if (m == 0) - { - reFeature = sgFeaturesList[0]; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - reFeature = sgFeaturesList[m]; - maxLength = lengthAbs; - } - } - } - } - } - return reFeature; + if (!dtBool) return; + dt.Rows.Add(dr); } /// /// 燃气规范审核 @@ -683,10 +508,8 @@ } dr[8] = dr[8] + "超标"; - if (dtBool) - { - dt.Rows.Add(dr); - } + if (!dtBool) return; + dt.Rows.Add(dr); } /// /// 供电规范审核 @@ -738,13 +561,10 @@ } dr[8] = dr[8] + "超标"; - if (dtBool) - { - dt.Rows.Add(dr); - } + if (!dtBool) return; + dt.Rows.Add(dr); } - #region wxl 重构 碰撞审查,覆土审查,水平净距审查,垂直净距审查 //TODO LIST:UNDONE /// diff --git a/FrmGBJC.cs b/FrmGBJC.cs index afd5411..38ade64 100644 --- a/FrmGBJC.cs +++ b/FrmGBJC.cs @@ -21,8 +21,8 @@ { this.globeControl1 = _globeControl1; this.globeControl2 = _globeControl2; - DoublePanelAnalysis.globeControl1 = globeControl1; - DoublePanelAnalysis.globeControl2 = globeControl2; + //DoublePanelAnalysis.globeControl1 = globeControl1; + //DoublePanelAnalysis.globeControl2 = globeControl2; this.layerTemp = _layerTemp; this.layerTemp2 = _layerTemp2; InitializeComponent(); @@ -72,21 +72,13 @@ } } } - /// - /// 施工图层列表点击事件 - /// - /// - /// + private void listBoxSG_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxSG.SelectedItem == null) return; textBoxSG.Text = listBoxSG.SelectedItem.ToString(); } - /// - /// 实测图层列表点击事件 - /// - /// - /// + private void listBoxSC_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxSC.SelectedItem == null) return; @@ -112,11 +104,6 @@ } } - /// - /// 确定检测 - /// - /// - /// private void buttonOK_Click(object sender, EventArgs e) { invalParam(); @@ -127,9 +114,9 @@ return; DataTable dt = DoublePanelAnalysis.lineFeatureCompare(scLayer, sgLayer, - comboBoxRoad.SelectedItem.ToString()); + comboBoxRoad.SelectedItem.ToString(), globeControl1, globeControl2); - FrmGBJCresult rs = new FrmGBJCresult(globeControl1, globeControl2, dt, layerTemp, layerTemp2); + FrmGBJCresult rs = new FrmGBJCresult(globeControl1, globeControl2, dt); rs.Show(); this.Close(); } diff --git a/FrmGBJCresult.cs b/FrmGBJCresult.cs index 7be6604..c1931c0 100644 --- a/FrmGBJCresult.cs +++ b/FrmGBJCresult.cs @@ -13,21 +13,17 @@ DataTable dt; GSOGlobeControl globeControl1; GSOGlobeControl globeControl2; - GSOLayer layerTemp; - GSOLayer layerTemp2; - public FrmGBJCresult(GSOGlobeControl _golbeControl1, GSOGlobeControl _golbeControl2, DataTable _dt,GSOLayer _layerTemp,GSOLayer _layerTemp2) + public FrmGBJCresult(GSOGlobeControl _golbeControl1, GSOGlobeControl _golbeControl2, DataTable _dt) { globeControl1=_golbeControl1; globeControl2 = _golbeControl2; dt = _dt; - layerTemp = _layerTemp; - layerTemp2 = _layerTemp2; InitializeComponent(); labelX1.Text = DoublePanelAnalysis.strLabel; } - private void FrmGBJCresult_Load(object sender, EventArgs e) + void intalDatagridView() { dataGridViewX1.DataSource = dt; dataGridViewX1.Columns[0].Width = 80; @@ -39,16 +35,18 @@ dataGridViewX1.Columns[6].Width = 70; dataGridViewX1.Columns[7].Width = 80; } - /// - /// 结果表双击事件,在地球场景中添加缓冲区和管段的标注 - /// - /// - /// + + private void FrmGBJCresult_Load(object sender, EventArgs e) + { + intalDatagridView(); + } + private void dataGridViewX1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) return; - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); + globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); + //获取globeControl1飞行目标 string scLayer = dataGridViewX1.Rows[e.RowIndex].Cells["实测图层"].Value.ToString(); string scFeatureName = dataGridViewX1.Rows[e.RowIndex].Cells["实测管段"].Value.ToString(); @@ -63,17 +61,20 @@ GSOFeatures sggsoFeatures = sggsoLayer.GetFeatureByName(sgFeatureName, false); GSOFeature sggsoFeature = sggsoFeatures[0]; - AddPolygon(scgsoFeature); + addLabelAndFlyToPosition(scgsoFeature, sggsoFeature); + } - AddMakerToLayer(globeControl1, scgsoFeature, scFeatureName); - if (sggsoFeature != null) - { - AddMakerToLayer(globeControl2, sggsoFeature, sgFeatureName); - } + void addLabelAndFlyToPosition(GSOFeature scFeature, GSOFeature sgFeature) + { + AddPolygon(scFeature); + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, scFeature); + if (sgFeature != null) + ClassSearchAnalysis.AddMakerToLineFeature(globeControl2, sgFeature); else { globeControl2.Globe.MemoryLayer.RemoveAllFeature(); - GSOGeoPolyline3D scLine = scgsoFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; if (scLine[0].Count <= 1) return; GSOGeoPoint3D pt = new GSOGeoPoint3D(); GSOPoint3d point3d = scLine.GeoCenterPoint; @@ -83,147 +84,32 @@ globeControl2.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 200); } } - /// - /// 双屏中通知增加实测数据的缓冲区 - /// - /// + private void AddPolygon(GSOFeature scFeature) { - GSOFeature new_feat= new GSOFeature(); + GSOFeature new_feat= new GSOFeature(); GSOGeoPolyline3D line = scFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D resPolygon = new GSOGeoPolygon3D(); - resPolygon = line.CreateBuffer(DoublePanelAnalysis.bufferWidth, true, 0, false, false); resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; new_feat.Geometry = resPolygon; - layerTemp.AddFeature(new_feat); - layerTemp2.AddFeature(new_feat); - + globeControl1.Globe.MemoryLayer.AddFeature(new_feat); + globeControl2.Globe.MemoryLayer.AddFeature(new_feat); globeControl1.Refresh(); globeControl2.Refresh(); } - /// - /// 地球场景中添加lable标注 - /// - /// - /// - /// - private void AddMakerToLayer(GSOGlobeControl glb, GSOFeature gsoFeature, string FeatureName) - { - glb.Globe.MemoryLayer.RemoveAllFeature(); - GSOFeature radiusMarkerFeature; - if (gsoFeature == null) return; - GSOGeoPolyline3D selLine = gsoFeature.Geometry as GSOGeoPolyline3D; - - if (selLine[0].Count <= 1) return; - 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(); - } - /// - /// 获取指定图层中最后一个feature对象的名称对应的整数 - /// - /// - /// - public int getLabelName(GSOLayer layer) - { - int nid = -1; - if (layer.GetAllFeatures().Length <= 0) - { - nid = 0; - } - else - { - string id = layer.GetAllFeatures()[layer.GetAllFeatures().Length - 1].Name; - int.TryParse(id, out nid); - } - return nid; - } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - 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) - continue; - GSOGeoPoint3D pointItem = gfeat.Geometry as GSOGeoPoint3D; - if (pointItem.X != point.X || pointItem.Y != point.Y || pointItem.Z != point.Z) continue; - layer.RemoveAt(i); - break; - } - point.AltitudeMode = EnumAltitudeMode.RelativeToGround; - 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; - } - /// - /// - /// - /// - /// private void FrmGBJCresult_FormClosing(object sender, FormClosingEventArgs e) { globeControl1.Globe.MemoryLayer.RemoveAllFeature(); globeControl2.Globe.MemoryLayer.RemoveAllFeature(); - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); + globeControl1.Refresh(); + globeControl2.Refresh(); } - /// - /// 导出EXCEL - /// - /// - /// + private void buttonEXPexcel_Click(object sender, EventArgs e) { try diff --git a/MainFrm.cs b/MainFrm.cs index 90e7786..8d8e53b 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -2876,7 +2876,6 @@ FullScreen(); } break; - default: break; } diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe index 53109f7..c7b82be 100644 --- a/bin/x86/Debug/Cyberpipe.exe +++ b/bin/x86/Debug/Cyberpipe.exe Binary files differ diff --git a/bin/x86/Debug/Cyberpipe.pdb b/bin/x86/Debug/Cyberpipe.pdb index 7dc881c..5547a58 100644 --- a/bin/x86/Debug/Cyberpipe.pdb +++ b/bin/x86/Debug/Cyberpipe.pdb Binary files differ