using System; using System.Collections.Generic; using System.Linq; using System.Text; using GeoScene.Data; using GeoScene.Engine; using GeoScene.Globe; using System.Collections; using System.Drawing; using System.Data; namespace Cyberpipe { static class DoublePanelAnalysis { public static GSOGlobeControl globeControl1 = null; public static GSOGlobeControl globeControl2 = null; public static GSOLayer layerTemp = null; public static GSOLayer layerTemp2 = null; public static int bufferWidth = 8; public static string strLabel; /// <summary> /// 计算水平距离 /// </summary> /// <param name="line1"></param> /// <param name="line2"></param> /// <returns></returns> public static double HorizonDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2) { GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); GSOPoint3d pntProIntersect1 = new GSOPoint3d(); GSOPoint3d pntProIntersect2 = new GSOPoint3d(); GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D; GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D; double dDist = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); return dDist; } /// <summary> /// 计算垂直距离 /// </summary> /// <param name="line1"></param> /// <param name="line2"></param> /// <returns></returns> public static double VerticalDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2) { GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); GSOPoint3d pntProIntersect1 = new GSOPoint3d(); GSOPoint3d pntProIntersect2 = new GSOPoint3d(); GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D; GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D; double dDist = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); //地球中添加标注 //GSOPoint3d markerPosition = new GSOPoint3d(); //markerPosition = LabelVerticalDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true); return dDist; } /// <summary> /// 添加垂直标注 /// </summary> /// <param name="markerLayer"></param> /// <param name="pntIntersect1"></param> /// <param name="pntIntersect2"></param> /// <param name="distance"></param> /// <param name="markerVisible"></param> /// <returns></returns> private static GSOPoint3d LabelVerticalDistance(GSOLayer markerLayer, GSOLayer markerLayer2, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) { if (pntIntersect1 == null || pntIntersect2 == null) { return new GSOPoint3d(); } GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); GSOPoint3ds point3ds = new GSOPoint3ds(); point3ds.Add(pntIntersect1); point3ds.Add(pntIntersect2); disline.AddPart(point3ds); GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D();//创建线的风格 //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 style.LineColor = Color.Red; style.LineWidth = 5; //设置线的宽度为5 style.VertexVisible = true; //显示线的节点 disline.Style = style; //把风格添加到线上 disline.AltitudeMode = EnumAltitudeMode.Absolute; GSOFeature line = new GSOFeature(); line.Geometry = disline; GSOGeoMarker dismarker = new GSOGeoMarker(); dismarker.X = pntIntersect1.X; dismarker.Y = pntIntersect1.Y; dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; dismarker.Text = "垂直" + distance.ToString("0.00") + "米"; dismarker.AltitudeMode = EnumAltitudeMode.Absolute; GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); GSOTextStyle styleText = new GSOTextStyle(); styleText.IsSizeFixed = true; styleText.ForeColor = Color.Red; styleText.FontSize = 20; styleMarker.TextStyle = styleText; dismarker.Style = styleMarker; GSOFeature marker = new GSOFeature(); marker.Geometry = dismarker; line.Visible = marker.Visible = markerVisible; markerLayer.AddFeature(line); markerLayer.AddFeature(marker); markerLayer2.AddFeature(line); markerLayer2.AddFeature(marker); return dismarker.Position; } /// <summary> /// 添加水平标注 /// </summary> /// <param name="markerLayer"></param> /// <param name="pntIntersect1"></param> /// <param name="pntIntersect2"></param> /// <param name="distance"></param> /// <param name="markerVisible"></param> /// <returns></returns> private static GSOPoint3d LabelHorizontalDistance(GSOLayer markerLayer, GSOLayer markerLayer2, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) { if (pntIntersect1 == null || pntIntersect2 == null) { return new GSOPoint3d(); } GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); GSOPoint3ds point3ds = new GSOPoint3ds(); point3ds.Add(pntIntersect1); point3ds.Add(pntIntersect2); disline.AddPart(point3ds); GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 style.LineColor = Color.Red; style.LineWidth = 5; //设置线的宽度为3 style.VertexVisible = true; //显示线的节点 disline.Style = style; //把风格添加到线上 disline.AltitudeMode = EnumAltitudeMode.Absolute; GSOFeature line = new GSOFeature(); line.Geometry = disline; GSOGeoMarker dismarker = new GSOGeoMarker(); dismarker.X = pntIntersect1.X; dismarker.Y = pntIntersect1.Y; dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; dismarker.Text = "水平" + distance.ToString("0.00") + "米"; dismarker.AltitudeMode = EnumAltitudeMode.Absolute; GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); GSOTextStyle styleText = new GSOTextStyle(); styleText.IsSizeFixed = true; styleText.ForeColor = Color.Red; styleText.FontSize = 20; styleMarker.TextStyle = styleText; dismarker.Style = styleMarker; GSOFeature marker = new GSOFeature(); marker.Geometry = dismarker; line.Visible = marker.Visible = markerVisible; markerLayer.AddFeature(line); markerLayer.AddFeature(marker); markerLayer2.AddFeature(line); markerLayer2.AddFeature(marker); return dismarker.Position; } /// <summary> /// 清除所有高亮Feature /// </summary> /// <param name="glb"></param> public static void clearFeatureHighLight() { //layerTemp.RemoveAllFeature(); //layerTemp2.RemoveAllFeature(); //清除gbl1中高亮 for (int i = 0; i < globeControl1.Globe.Layers.Count; i++) { GSOLayer layer = globeControl1.Globe.Layers[i]; if (layer is GSOFeatureLayer) { GSOFeatures feats = layer.GetAllFeatures(); for (int j = 0; j < feats.Length; j++) { GSOFeature feat = feats[j]; feat.HighLight = false; } } } //清除gbl2中高亮 for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) { GSOLayer layer = globeControl2.Globe.Layers[i]; if (layer is GSOFeatureLayer) { GSOFeatures feats = layer.GetAllFeatures(); for (int j = 0; j < feats.Length; j++) { GSOFeature feat = feats[j]; feat.HighLight = false; } } } } /// <summary> /// 单Feature对比方法 /// </summary> /// <param name="srcFeature"></param> /// <param name="dscFeature"></param> public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer,string road) { DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); dt.Columns.Add("实测管段"); dt.Columns.Add("施工图层"); dt.Columns.Add("施工管段"); dt.Columns.Add("水平距离/m"); dt.Columns.Add("水平净距国标/m"); dt.Columns.Add("垂直距离/m"); dt.Columns.Add("垂直净距国标/m"); dt.Columns.Add("检测结果"); if (scLayer.Caption.Contains("给水") || scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { strLabel = "目标图层包含不符合《给水排水构筑物工程施工及验收规范》(GB50141-2008)要求的管段,具体内容如下:"; CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; CreateRanQiDataTable(scLayer, sgLayer, road, dt); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; CreateGongDianDataTable(scLayer, sgLayer, road, dt); } return dt; } /// <summary> /// 生成给排水监测结果表格 /// </summary> /// <param name="scLayer"></param> /// <param name="sgLayer"></param> /// <param name="road"></param> /// <param name="dt"></param> public static void CreateJiPaiShuiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) { //给排水监测 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); GSOFeature sgFeature = null; GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); //**判断同一个Feature if (sgFeatures.Length >= 1) { sgFeature = GetSameFeature2(scFeature, scLayer, sgLayer, bufferWidth); /* sgFeature = sgFeatures[0]; * */ if (sgFeature != null) { GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance = HorizonDistance(scLine, sgLine);//水平净距 double verticalDistance = VerticalDistance(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); } } } } /// <summary> /// 生成燃气监测结果表格 /// </summary> /// <param name="scLayer"></param> /// <param name="sgLayer"></param> /// <param name="road"></param> /// <param name="dt"></param> public static void CreateRanQiDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) { //燃气监测 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); 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 = HorizonDistance(scLine, sgLine);//水平净距 double verticalDistance = VerticalDistance(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); } } else { continue; } } } /// <summary> /// 生成供电监测结果表格 /// </summary> /// <param name="scLayer"></param> /// <param name="sgLayer"></param> /// <param name="road"></param> /// <param name="dt"></param> public static void CreateGongDianDataTable(GSOLayer scLayer, GSOLayer sgLayer, string road, DataTable dt) { //供电监测 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); 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 = HorizonDistance(scLine, sgLine);//水平净距 double verticalDistance = VerticalDistance(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); } } else { continue; } } } /// <summary> /// 给排水规范审核 /// </summary> /// <param name="scLayerName"></param> /// <param name="sgLayerName"></param> /// <param name="scFeature"></param> /// <param name="sgFeature"></param> /// <param name="horizonDistance"></param> /// <param name="verticalDistance"></param> /// <param name="dt"></param> public static void JiShuiAnalysis(string scLayerName, string sgLayerName,GSOFeature scFeature,GSOFeature sgFeature, double horizonDistance, double verticalDistance,DataTable dt) { bool dtBool = false; DataRow dr = dt.NewRow(); dr[0] = scLayerName; dr[1] = scFeature.GetFieldAsString("编号"); dr[2] = sgLayerName; dr[3] = sgFeature.GetFieldAsString("编号"); if (scLayerName.Contains("给水")) { //水平 if (horizonDistance > 0.03) { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.03"; dr[8] = dr[8].ToString() + "水平净距"; scFeature.HighLight = true; dtBool = true; } else { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.03"; } //垂直 if (Math.Abs(verticalDistance) > 0.03) { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.03"; dr[8] = dr[8].ToString() + "垂直净距"; scFeature.HighLight = true; dtBool = true; } else { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.03"; } dr[8] = dr[8] + "超标"; } else { if (horizonDistance > 0.015) { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.015"; scFeature.HighLight = true; dr[8] = dr[8] + "水平净距"; dtBool = true; } else { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.015"; } if (scFeature.GetFieldAsDouble("起始管底高程") <= 1) { if (Math.Abs(verticalDistance) > 0.01) { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.01"; scFeature.HighLight = true; dr[8] = dr[8].ToString() + "垂直净距"; dtBool = true; } else { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.01"; } } else { if (Math.Abs(verticalDistance) > 0.015) { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.015"; scFeature.HighLight = true; dr[8] = dr[8].ToString() + "垂直净距"; dtBool = true; } else { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.015"; } } dr[8] = dr[8].ToString() + "超标"; } if (dtBool == true) { 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; // double tempLength = line.GetSpaceLength(false, 6378137); 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; } else if (sgFeaturesList.Length == 1) { return sgFeaturesList[0]; } else { reFeature = sgFeaturesList[0]; double maxLength = Double.MaxValue; for (int m = 0; m < sgFeaturesList.Length; m++) { GSOFeature tempFeature = sgFeaturesList[m]; double tempLength = getLineLength(tempFeature, sgLayer, bufferPolygon); double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); if (lengthAbs < maxLength) { reFeature = sgFeaturesList[m]; maxLength = lengthAbs; } } } return reFeature; } #endregion /// <summary> /// 判断同一根管段 /// </summary> /// <param name="scFeature"></param> /// <param name="scLayer"></param> /// <param name="sgLayer"></param> /// <param name="bufferWidth"></param> /// <returns></returns> 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) { 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) { for (int j = 0; j < scFeatures.Length; j++) { //TODO LIST:? if (scFeatures[j].Name == scFeature.Name) { sgFeaturesList.Add(sgFeatures[i]); break; } } } else { reFeature = null; } } //长度判断 if (sgFeaturesList.Length != 0) { 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 == true) { 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); } } } } /* GSOGeoPolyline3D tempSGLine = sgFeaturesList[m].Geometry as GSOGeoPolyline3D; double tempLength = tempSGLine.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; } // reFeature = sgFeaturesList[m]; } } } else { reFeature = null; } } else { reFeature = null; } return reFeature; } /// <summary> /// 燃气规范审核 /// </summary> /// <param name="scLayerName"></param> /// <param name="sgLayerName"></param> /// <param name="scFeature"></param> /// <param name="sgFeature"></param> /// <param name="horizonDistance"></param> /// <param name="verticalDistance"></param> /// <param name="dt"></param> public static void RanQiAnalysis(string scLayerName, string sgLayerName, GSOFeature scFeature, GSOFeature sgFeature, double horizonDistance, double verticalDistance, DataTable dt) { bool dtBool = false; DataRow dr = dt.NewRow(); dr[0] = scLayerName; dr[1] = scFeature.GetFieldAsString("编号"); dr[2] = sgLayerName; dr[3] = sgFeature.GetFieldAsString("编号"); //水平 if (horizonDistance > 0.06) { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.06"; dr[8] = dr[8].ToString() + "水平净距"; scFeature.HighLight = true; dtBool = true; } else { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.06"; } //垂直 if (Math.Abs(verticalDistance) > 0.06) { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.06"; dr[8] = dr[8].ToString() + "垂直净距"; scFeature.HighLight = true; dtBool = true; } else { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.06"; } dr[8] = dr[8] + "超标"; if (dtBool == true) { dt.Rows.Add(dr); } } /// <summary> /// 供电规范审核 /// </summary> /// <param name="scLayerName"></param> /// <param name="sgLayerName"></param> /// <param name="scFeature"></param> /// <param name="sgFeature"></param> /// <param name="horizonDistance"></param> /// <param name="verticalDistance"></param> /// <param name="dt"></param> public static void GongDianAnalysis(string scLayerName, string sgLayerName, GSOFeature scFeature, GSOFeature sgFeature, double horizonDistance, double verticalDistance, DataTable dt) { bool dtBool = false; DataRow dr = dt.NewRow(); dr[0] = scLayerName; dr[1] = scFeature.GetFieldAsString("编号"); dr[2] = sgLayerName; dr[3] = sgFeature.GetFieldAsString("编号"); //水平 if (horizonDistance > 0.02) { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.02"; dr[8] = dr[8].ToString() + "水平净距"; scFeature.HighLight = true; dtBool = true; } else { dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[5] = "0.02"; } //垂直 if (Math.Abs(verticalDistance) > 0.02) { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.02"; dr[8] = dr[8].ToString() + "垂直净距"; scFeature.HighLight = true; dtBool = true; } else { dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00"); dr[7] = "0.02"; } dr[8] = dr[8] + "超标"; if (dtBool == true) { dt.Rows.Add(dr); } } } }