Newer
Older
GHFX_REFACTOR / DoublePanelAnalysis.cs
xiaowei on 18 Nov 2016 38 KB 重构一键审核代码
using System;
using System.Collections.Generic;
using System.Data;
using GeoScene.Data;
using GeoScene.Engine;
using GeoScene.Globe;

namespace Cyberpipe
{
    static class DoublePanelAnalysis
    {
        public static 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)
        {
            GSOPoint3d pntIntersect1 = new GSOPoint3d();
            GSOPoint3d pntIntersect2 = new GSOPoint3d();
            GSOPoint3d pntProIntersect1 = new GSOPoint3d();
            GSOPoint3d pntProIntersect2 = new GSOPoint3d();
            vertical = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2,
                out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false);
            horizon = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2,
                out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false);
        }

        /// <summary>
        /// 清除所有高亮Feature
        /// </summary>
        /// <param name="glb"></param>
        public static void clearFeatureHighLight()
        {
            ClearHighlight(globeControl1);
            ClearHighlight(globeControl2);
        }

        static void ClearHighlight(GSOGlobeControl ctl)
        {
            for (int i = 0; i < ctl.Globe.Layers.Count; i++)
            {
                GSOLayer layer = ctl.Globe.Layers[i];
                if (layer is GSOFeatureLayer)
                {
                    GSOFeatures feats = layer.GetAllFeatures();
                    for (int j = 0; j < feats.Length; j++)
                    {
                        GSOFeature feat = feats[j];
                        feat.HighLight = false;
                    }
                }
            }
        }

        /// <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);

                        if (sgFeature != null)
                        {
                            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);
                    }
                }
            }
        }
        /// <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, 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);
                    }
                }
            }
        }
        /// <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) 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);

                //**判断同一个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);
                }
            }
        }
        /// <summary>
        /// 给排水规范审核
        /// </summary>
        /// <param name="scLayerName"></param>
        /// <param name="sgLayerName"></param>
        /// <param name="scFeature"></param>
        /// <param name="sgFeature"></param>
        /// <param name="horizonDistance"></param>
        /// <param name="verticalDistance"></param>
        /// <param name="dt"></param>
        public static void JiShuiAnalysis(string scLayerName, string sgLayerName,GSOFeature scFeature,GSOFeature sgFeature, double horizonDistance, double verticalDistance,DataTable dt)
        {
            bool dtBool = false;

            DataRow dr = dt.NewRow();
            dr[0] = scLayerName;
            dr[1] = scFeature.GetFieldAsString("编号");
            dr[2] = sgLayerName;
            dr[3] = sgFeature.GetFieldAsString("编号");

            if (scLayerName.Contains("给水"))
            {
                //水平
                if (horizonDistance > 0.03)
                {
                    dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                    dr[5] = "0.03";
                    dr[8] = dr[8] + "水平净距";
                    scFeature.HighLight = true;
                    dtBool = true;
                }
                else
                {
                    dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                    dr[5] = "0.03";
                }
                //垂直
                if (Math.Abs(verticalDistance) > 0.03)
                {
                    dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                    dr[7] = "0.03";
                    dr[8] = dr[8] + "垂直净距";
                    scFeature.HighLight = true;
                    dtBool = true;
                }
                else
                {
                    dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                    dr[7] = "0.03";
                }
                dr[8] = dr[8] + "超标";
            }
            else
            {
                if (horizonDistance > 0.015)
                {
                    dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                    dr[5] = "0.015";
                    scFeature.HighLight = true;
                    dr[8] = dr[8] + "水平净距";
                    dtBool = true;
                }
                else
                {
                    dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                    dr[5] = "0.015";
                }
                if (scFeature.GetFieldAsDouble("起始管底高程") <= 1)
                {
                    if (Math.Abs(verticalDistance) > 0.01)
                    {
                        dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                        dr[7] = "0.01";
                        scFeature.HighLight = true;
                        dr[8] = dr[8] + "垂直净距";
                        dtBool = true;
                    }
                    else
                    {
                        dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                        dr[7] = "0.01";
                    }
                }
                else
                {
                    if (Math.Abs(verticalDistance) > 0.015)
                    {
                        dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                        dr[7] = "0.015";
                        scFeature.HighLight = true;
                        dr[8] = dr[8] + "垂直净距";
                        dtBool = true;
                    }
                    else
                    {
                        dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                        dr[7] = "0.015";
                    }
                }

                dr[8] = dr[8] + "超标";
            }

            if (dtBool)
            {
                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

        /// <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) 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;
        }
        /// <summary>
        /// 燃气规范审核
        /// </summary>
        /// <param name="scLayerName"></param>
        /// <param name="sgLayerName"></param>
        /// <param name="scFeature"></param>
        /// <param name="sgFeature"></param>
        /// <param name="horizonDistance"></param>
        /// <param name="verticalDistance"></param>
        /// <param name="dt"></param>
        public static void RanQiAnalysis(string scLayerName, string sgLayerName, GSOFeature scFeature, GSOFeature sgFeature, double horizonDistance, double verticalDistance, DataTable dt)
        {
            bool dtBool = false;

            DataRow dr = dt.NewRow();
            dr[0] = scLayerName;
            dr[1] = scFeature.GetFieldAsString("编号");
            dr[2] = sgLayerName;
            dr[3] = sgFeature.GetFieldAsString("编号");

            //水平
            if (horizonDistance > 0.06)
            {
                dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                dr[5] = "0.06";
                dr[8] = dr[8] + "水平净距";
                scFeature.HighLight = true;
                dtBool = true;
            }
            else
            {
                dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                dr[5] = "0.06";
            }
            //垂直
            if (Math.Abs(verticalDistance) > 0.06)
            {
                dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                dr[7] = "0.06";
                dr[8] = dr[8] + "垂直净距";
                scFeature.HighLight = true;
                dtBool = true;
            }
            else
            {
                dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                dr[7] = "0.06";
            }
            dr[8] = dr[8] + "超标";

            if (dtBool)
            {
                dt.Rows.Add(dr);
            }
        }
        /// <summary>
        /// 供电规范审核
        /// </summary>
        /// <param name="scLayerName"></param>
        /// <param name="sgLayerName"></param>
        /// <param name="scFeature"></param>
        /// <param name="sgFeature"></param>
        /// <param name="horizonDistance"></param>
        /// <param name="verticalDistance"></param>
        /// <param name="dt"></param>
        public static void GongDianAnalysis(string scLayerName, string sgLayerName, GSOFeature scFeature, GSOFeature sgFeature, double horizonDistance, double verticalDistance, DataTable dt)
        {
            bool dtBool = false;

            DataRow dr = dt.NewRow();
            dr[0] = scLayerName;
            dr[1] = scFeature.GetFieldAsString("编号");
            dr[2] = sgLayerName;
            dr[3] = sgFeature.GetFieldAsString("编号");

            //水平
            if (horizonDistance > 0.02)
            {
                dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                dr[5] = "0.02";
                dr[8] = dr[8] + "水平净距";
                scFeature.HighLight = true;
                dtBool = true;
            }
            else
            {
                dr[4] = Math.Round(horizonDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                dr[5] = "0.02";
            }
            //垂直
            if (Math.Abs(verticalDistance) > 0.02)
            {
                dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                dr[7] = "0.02";
                dr[8] = dr[8] + "垂直净距";
                scFeature.HighLight = true;
                dtBool = true;
            }
            else
            {
                dr[6] = Math.Round(verticalDistance, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                dr[7] = "0.02";
            }
            dr[8] = dr[8] + "超标";

            if (dtBool)
            {
                dt.Rows.Add(dr);
            }
        }


        #region wxl 重构 碰撞审查,覆土审查,水平净距审查,垂直净距审查

        /// <summary>
        /// 获取跟选择管线垂直距离小于特定值的管线列表和选择管线的距离
        /// </summary>
        /// <param name="globeControl1">地球</param>
        /// <param name="selectedFeature">选择管线</param>
        /// <param name="_pipelineLayerNames">各图层名称</param>
        /// <param name="verticalDistance">垂直距离</param>
        /// <returns>管线列表,可为空</returns>
        public static Dictionary<GSOFeature, double> VerticalDistanceAnalysis(GSOGlobeControl globeControl1,
            GSOFeature selectedFeature, List<string> _pipelineLayerNames, double verticalDistance )
        {
            if (selectedFeature == null) return null;
            GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D;
            if (line1 == null) return null;
            GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D;
            if (pipeStyle1 == null) return null;
            GSOGeoPolygon3D polygon = line1.CreateBuffer(0.1, true, 5, true, false);//要比较的区域
            Dictionary<GSOFeature, double> result = new Dictionary<GSOFeature, double>();

            string caption = selectedFeature.Dataset.Caption;

            GSOPoint3d pntIntersect1, pntIntersect2,pntProIntersect1, pntProIntersect2 ;
            for (int i = 0; i < _pipelineLayerNames.Count; i++)
            {
                if (caption == _pipelineLayerNames[i]) continue;//排除本图层
                GSOLayer layer2 = globeControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]);
                if (layer2 == null) continue;
                GSOFeatures feats2 = FeatureStatisticsService.getLayerFeatures(polygon, layer2);
                if (feats2 == null) continue;
                for (int j = 0; j < feats2.Length; j++)
                {
                    GSOFeature feat2 = feats2[j];
                    GSOGeoPolyline3D line2 = feat2.Geometry as GSOGeoPolyline3D;
                    if (line2 == null) continue;
                    GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D;
                    if (pipeStyle2 == null) continue;
                    double dDist = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1,
                        out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false);
                    if (dDist >= verticalDistance) continue;//不符合条件
                    result.Add(feat2,dDist);
                }
            }
            return result;
        }
        /// <summary>
        /// 获取与选定管线水平距离小于特定值的<管线,管线距离>Dictionary
        /// </summary>
        /// <param name="globeControl1"></param>
        /// <param name="selectedFeature"></param>
        /// <param name="_pipelineLayerNames"></param>
        /// <param name="dis"></param>
        /// <returns>选择的为空或不是管线则返回空,否则返回符合条件的Dictionary</returns>
        public static Dictionary<GSOFeature, double> HorizontalDistanceAnalysis(GSOGlobeControl globeControl1,GSOFeature selectedFeature, List<string> _pipelineLayerNames, double dis)
        {
            if (selectedFeature == null) return null;
            GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D;
            if (line1 == null) return null;
            GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D;
            if (pipeStyle1 == null) return null;
            Dictionary<GSOFeature, double> result = new Dictionary<GSOFeature, double>();
            string caption = selectedFeature.Dataset.Caption;
            GSOGeoPolygon3D polygon = line1.CreateBuffer(dis, true, 5, true, false);
            GSOFeature new_feat = new GSOFeature();
            new_feat.Geometry = polygon;

            for (int i = 0; i < _pipelineLayerNames.Count; i++)
            {
                if (caption == _pipelineLayerNames[i]) continue;
                GSOLayer layer2 = globeControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]);
                if (layer2 == null) continue;
                GSOFeatures feats2 = FeatureStatisticsService.getLayerFeatures(polygon, layer2);
                for (int j = 0; j < feats2.Length; j++)
                {
                    GSOFeature feat2 = feats2[j];
                    GSOGeoPolyline3D line2 = feat2.Geometry as GSOGeoPolyline3D;
                    if (line2 == null) continue;
                    GSOPoint3d pntIntersect1, pntIntersect2, pntProIntersect1, pntProIntersect2;
                    double dDist = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1,
                         out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false);
                    GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D;
                    if (pipeStyle2 == null) continue;
                    result.Add(feat2,dDist);
                }
            }
            return result;
        }
        /// <summary>
        ///碰撞检测,获取与选择管线碰撞的管线
        /// </summary>
        /// <param name="globeControl1">地球</param>
        /// <param name="selectedFeature">选中的feature</param>
        /// <param name="_pipelineLayerNames">图层列表</param>
        /// <returns></returns>
        public static GSOFeatures CollisionAnalysis(GSOGlobeControl globeControl1, GSOFeature selectedFeature, List<string> _pipelineLayerNames)
        {
            if (selectedFeature == null) return null;
            GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D;
            if (line1 == null) return null;
            GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D;
            if (pipeStyle1 == null) return null;
            GSOGeoPolygon3D polygon = line1.CreateBuffer(0.1, true, 5, true, false);//要比较的区域
            GSOFeatures result = new GSOFeatures();

            string caption = selectedFeature.Dataset.Caption;
            for (int i = 0; i < _pipelineLayerNames.Count; i++)
            {
                if (caption == _pipelineLayerNames[i]) continue;//排除本图层
                GSOLayer layer2 = globeControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]);
                if (layer2 == null) continue;
                GSOFeatures feats2 = FeatureStatisticsService.getLayerFeatures(polygon, layer2);
                if (feats2 == null) continue;
                for (int j = 0; j < feats2.Length; j++)
                {
                    double horLen, verLen, dNoIntersetStartRatio=0;
                    GSOFeature feat2 = feats2[j];
                    GSOGeoPolyline3D line2 = feat2.Geometry as GSOGeoPolyline3D;
                    if (line2 == null) continue;
                    GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D;
                    if (pipeStyle2 == null) continue;
                    GSOPoint3d pntIntersect1, pntIntersect2;
                    double dDist = globeControl1.Globe.Analysis3D.ComputeTwoGeoPolylineDistance(line1, line2, out pntIntersect1,
                        out pntIntersect2,out horLen,out verLen,true,true,dNoIntersetStartRatio);
                    if (dDist <= 0 ) result.Add(feat2);
                }
            }
            return result;
        }
        #endregion
    }
}