private void ComputeInitParams(DataTable dtinfo)
        {
            double avgx = 0, avgy = 0;

            for (int i = 0; i < dtinfo.Rows.Count; i++)
            {
                double x = Convert.ToDouble(dtinfo.Rows[i]["x"]);
                double y = Convert.ToDouble(dtinfo.Rows[i]["y"]);
                avgx += x;
                avgy += y;
            }
            avgx /= dtinfo.Rows.Count;
            avgy /= dtinfo.Rows.Count;
            Debug.WriteLine("路测中点:x" + avgx + "路测中点:x" + avgy);
            Geometric.Point endavg = new Geometric.Point(avgx, avgy, 0);

            double minx = double.MaxValue, miny = double.MaxValue, maxx = double.MinValue, maxy = double.MinValue;

            for (int i = 0; i < dtinfo.Rows.Count; i++)
            {
                //Debug.WriteLine(i);
                double          x     = Convert.ToDouble(dtinfo.Rows[i]["x"]);
                double          y     = Convert.ToDouble(dtinfo.Rows[i]["y"]);
                Geometric.Point start = new Geometric.Point(x, y, 0);

                double aziavg = LTE.Geometric.GeometricUtilities.getPolarCoord(start, endavg).theta / Math.PI * 180;
                aziavg = GeometricUtilities.ConvertGeometricArithmeticAngle(aziavg + 1);
                //Debug.WriteLine("路测中点计算角度:" + aziavg);
                dtinfo.Rows[i]["Azimuth"]  = aziavg;
                dtinfo.Rows[i]["Distance"] = distanceXY(start.X, start.Y, endavg.X, endavg.Y) + 300;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 2018.12.04
        /// 计算室外接收场强和路径损耗
        /// </summary>
        /// <param name="rayAzimuth">初始射线方位角</param>
        /// <param name="rayInclination">初始射线下倾角</param>
        /// <param name="rays"></param>
        /// <param name="isT">初级射线是否与建筑物相交</param>
        public void CalcAndMergeGGridStrengthBeam(double rayAzimuth, double rayInclination, ref List <Beam.NodeInfo> rays)
        {
            double[] receiveList = calcRayStrengthBeam(rayAzimuth, rayInclination, ref rays);

            double ReceivedPwr       = receiveList[0];
            double ReceivedPower_dbm = convertw2dbm(ReceivedPwr);

            //场强太弱,认为对栅格接收场强无影响,不合并
            if (ReceivedPower_dbm < -130)
            {
                return;
            }
            //Console.WriteLine("ReceivedPower_dbm >= -130");

            Beam.Point      t_p  = rays[rays.Count - 1].CrossPoint;
            Geometric.Point t_p1 = new Geometric.Point(t_p.m_position.x, t_p.m_position.y, t_p.m_position.z);

            int gxid = -1, gyid = -1;

            if (!GridHelper.getInstance().XYToGGrid(t_p.m_position.x, t_p.m_position.y, ref gxid, ref gyid))
            {
                return;
            }

            if (Math.Abs(t_p1.Z) < 1)
            {
                mergeGridStrengthBeam(gxid, gyid, 0, t_p1, ref rays, receiveList[2], ReceivedPwr);
            }
            else
            {
                int gzid = (int)Math.Ceiling(t_p.m_position.z / GridHelper.getInstance().getGHeight()) + 1;
                mergeGridStrengthBeam(gxid, gyid, gzid, t_p1, ref rays, receiveList[2], ReceivedPwr);
            }
        }
        public Result rayRecord()
        {
            List <ProcessArgs> paList = new List <ProcessArgs>();
            double             fromAngle = 0, toAngle = 0;
            int      eNodeB = 0, CI = 0;
            string   cellType = "";
            CellInfo cellInfo;

            if (this.manSource)  // 手动指定发射源
            {
                cellInfo                       = new CellInfo();
                cellInfo.SourcePoint           = new Geometric.Point(this.sourceX, this.sourceY, this.sourceZ);
                cellInfo.CI                    = this.sourceID;
                cellInfo.EIRP                  = 53;
                cellInfo.Inclination           = -7;
                cellInfo.diffracteCoefficient  = this.diffractCoeff;
                cellInfo.reflectCoefficient    = this.reflectCoeff;
                cellInfo.directCoefficient     = this.directCoeff;
                cellInfo.diffracteCoefficient2 = this.diffractCoeff2;

                if (this.manDir) // 手动指定方位角
                {
                    Geometric.Point end = new Geometric.Point(this.dirX, this.dirY, 0);
                    cellInfo.Azimuth = LTE.Geometric.GeometricUtilities.getPolarCoord(end, cellInfo.SourcePoint).theta / Math.PI * 180;
                }
                else if (this.cellName != null && this.cellName != string.Empty)  // 方位角中心线末端为指定小区
                {
                    Result rt = validateCell(ref eNodeB, ref CI, ref cellType);
                    if (!rt.ok)
                    {
                        return(rt);
                    }

                    CellInfo end = new CellInfo(this.cellName, eNodeB, CI, this.directCoeff, this.reflectCoeff, this.diffractCoeff, this.diffractCoeff2);
                    cellInfo.Azimuth = LTE.Geometric.GeometricUtilities.getPolarCoord(end.SourcePoint, cellInfo.SourcePoint).theta / Math.PI * 180;
                }
                else
                {
                    return(new Result(false, "请填写小区名称或手动指定方位角"));
                }

                fromAngle = cellInfo.Azimuth - this.incrementAngle;
                toAngle   = cellInfo.Azimuth + this.incrementAngle;
            }
            else  // 发射源为指定的小区
            {
                Result rt = validateCell(ref eNodeB, ref CI, ref cellType);
                if (!rt.ok)
                {
                    return(rt);
                }

                cellInfo  = new CellInfo(this.cellName, eNodeB, CI, this.directCoeff, this.reflectCoeff, this.diffractCoeff, this.diffractCoeff2);
                fromAngle = cellInfo.Azimuth - this.incrementAngle;
                toAngle   = cellInfo.Azimuth + this.incrementAngle;
            }

            return(parallelComputing(ref cellInfo, fromAngle, toAngle, true, false));
        }
        /// <summary>
        /// 角度约束
        /// </summary>
        /// <param name="dtinfo"></param>
        /// <param name="num"></param>
        /// <param name="angle"></param>
        /// <returns></returns>
        private DataTable ComputePointByA(DataTable dtinfo, int num, double angle)
        {
            //找到当前路测区域的中心点
            double centerx = (maxLon + minLon) / 2;
            double centery = (maxLat + minLat) / 2;

            Geometric.Point start = new Geometric.Point(centerx, centery, 0);
            LTE.Utils.PointConvertByProj.Instance.GetProjectPoint(start);
            DataTable ans = dtinfo.Clone();

            if (dtinfo.Rows.Count < num)
            {
                //MessageBox.Show(this, "ComputePointByA所筛选出的结果不足最小选点数", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(ans);
            }
            int len    = dtinfo.Rows.Count;
            int acount = 0;//已满足条件的数量

            for (int i = 0; i < len - 1 && acount < num; i++)
            {
                double x      = Convert.ToDouble(dtinfo.Rows[i]["x"]);
                double y      = Convert.ToDouble(dtinfo.Rows[i]["y"]);
                Point  curend = new Point(x, y, 0);
                double cura   = GeometricUtilities.getPolarCoord(start, curend).theta / Math.PI * 180;
                cura = GeometricUtilities.ConvertGeometricArithmeticAngle(cura + 1);
                bool flag = true;

                //与之前的每个点进行比较
                for (int j = ans.Rows.Count - 1; j >= 0; j--)
                {
                    flag = true;
                    double xf     = Convert.ToDouble(ans.Rows[j]["x"]);
                    double yf     = Convert.ToDouble(ans.Rows[j]["y"]);
                    Point  hisend = new Point(xf, yf, 0);
                    double hisa   = GeometricUtilities.getPolarCoord(start, hisend).theta / Math.PI * 180;
                    hisa = GeometricUtilities.ConvertGeometricArithmeticAngle(hisa + 1);
                    if (Math.Abs(hisa - cura) < angle)
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                {
                    DataRow thisrow = ans.NewRow();
                    thisrow["x"]         = x;
                    thisrow["y"]         = y;
                    thisrow["ReceivePW"] = Convert.ToDouble(dtinfo.Rows[i]["ReceivePW"]);
                    thisrow["CI"]        = Convert.ToInt32(dtinfo.Rows[i]["CI"]);
                    ans.Rows.Add(thisrow);
                    acount++;
                }
            }
            return(ans);
        }
Beispiel #5
0
        /// <summary>
        /// 构造小区的一个立体覆盖网格
        /// </summary>
        /// <param name="cellName"></param>
        /// <param name="lac"></param>
        /// <param name="ci"></param>
        /// <param name="gxid"></param>
        /// <param name="gyid"></param>
        /// <param name="level"></param>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="z"></param>
        /// <param name="recePower"></param>
        /// <param name="pathLoss"></param>
        public void constructGrid3D(string cellName, int lac, int ci, int gxid, int gyid, int level, double x1, double y1, double x2, double y2, double z, double recePower, double pathLoss)
        {
            IDataset   dataset   = (IDataset)pFeatureLayer.FeatureClass;
            IWorkspace workspace = dataset.Workspace;
            //Cast for an IWorkspaceEdit
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

            //start an edit session and operation
            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IFeatureCursor pFeatureCursor = pFeatureClass.Insert(true);
            IFeatureBuffer pFeatureBuffer;

            Geometric.Point p   = GridHelper.getInstance().GridToGeo(gxid, gyid);
            double          lon = p.X;
            double          lat = p.Y;

            IPoint pointA = GeometryUtilities.ConstructPoint3D(x1, y1, z);
            IPoint pointB = GeometryUtilities.ConstructPoint3D(x2, y1, z);
            IPoint pointC = GeometryUtilities.ConstructPoint3D(x2, y2, z);
            IPoint pointD = GeometryUtilities.ConstructPoint3D(x1, y2, z);

            IGeometryCollection pGeometryColl = GeometryUtilities.ConstructPolygon(new IPoint[] { pointA, pointB, pointC, pointD });

            pFeatureBuffer       = pFeatureClass.CreateFeatureBuffer();
            pFeatureBuffer.Shape = pGeometryColl as IGeometry;
            pFeatureBuffer.set_Value(this.GXIDIndex, gxid);
            pFeatureBuffer.set_Value(this.GYIDIndex, gyid);
            pFeatureBuffer.set_Value(this.LevelIndex, level);
            pFeatureBuffer.set_Value(this.eNodeBIndex, lac);
            pFeatureBuffer.set_Value(this.CIIndex, ci);
            pFeatureBuffer.set_Value(this.cellNameIndex, cellName);
            pFeatureBuffer.set_Value(this.RecePowerIndex, recePower);
            pFeatureBuffer.set_Value(this.PathLossIndex, pathLoss);
            pFeatureBuffer.set_Value(this.LongitudeIndex, lon);
            pFeatureBuffer.set_Value(this.LatitudeIndex, lat);

            pFeatureCursor.InsertFeature(pFeatureBuffer);

            //一次性提交
            pFeatureCursor.Flush();

            //stop editing
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            //IFeatureClassManage pFeatureClassManage = (IFeatureClassManage)pFeatureClass;
            //pFeatureClassManage.UpdateExtent();

            GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
            //GISMapApplication.Instance.FullExtent(pFeatureLayer.AreaOfInterest);
        }
        private void getGridID(ref int minxid, ref int minyid, ref int maxxid, ref int maxyid)
        {
            Geometric.Point pMin = new Geometric.Point();
            pMin.X = this.minLongitude;
            pMin.Y = this.minLatitude;
            pMin.Z = 0;
            LTE.Utils.PointConvertByProj.Instance.GetProjectPoint(pMin);

            Geometric.Point pMax = new Geometric.Point();
            pMax.X = this.maxLongitude;
            pMax.Y = this.maxLatitude;
            pMax.Z = 0;
            LTE.Utils.PointConvertByProj.Instance.GetProjectPoint(pMax);

            GridHelper.getInstance().XYToGGrid(pMin.X, pMin.Y, ref minxid, ref minyid);
            GridHelper.getInstance().XYToGGrid(pMax.X, pMax.Y, ref maxxid, ref maxyid);
        }
        /// <summary>
        /// 获取中心点在范围内的地面栅格中心点
        /// </summary>
        /// <returns></returns>
        public static int constructGGrids(ref Geometric.Point p1, ref Geometric.Point p2,
                                          ref Geometric.Point p3, ref Geometric.Point p4)
        {
            //Console.WriteLine("{0}", 1);
            ggrids = new Dictionary <string, Point>();

            Hashtable ht = new Hashtable();

            Grid3D gid1 = new Grid3D(), gid2 = new Grid3D(), gid3 = new Grid3D(), gid4 = new Grid3D();

            GridHelper.getInstance().PointXYZToGrid3D1(p1, ref gid1);
            GridHelper.getInstance().PointXYZToGrid3D1(p2, ref gid2);
            GridHelper.getInstance().PointXYZToGrid3D1(p3, ref gid3);
            GridHelper.getInstance().PointXYZToGrid3D1(p4, ref gid4);

            //Console.WriteLine("from: {0}", from * 180 / Math.PI);
            //Console.WriteLine("to: {0}", to * 180 / Math.PI);
            //Console.WriteLine("alpha: {0}", alpha * 180 / Math.PI);
            //Console.WriteLine("theta: {0}", theta * 180 / Math.PI);

            ht["x1"] = gid1.gxid;
            ht["x2"] = gid2.gxid;
            ht["x3"] = gid3.gxid;
            ht["x4"] = gid4.gxid;
            ht["y1"] = gid1.gyid;
            ht["y2"] = gid2.gyid;
            ht["y3"] = gid3.gyid;
            ht["y4"] = gid4.gyid;
            DataTable grids = IbatisHelper.ExecuteQueryForDataTable("getGroundGridsCenter", ht);
            //Console.WriteLine("{0}", grids.Rows.Count);
            double x, y, z;
            int    gxid, gyid;
            string key;

            for (int i = 0, cnt = grids.Rows.Count; i < cnt; i++)
            {
                gxid = Convert.ToInt32(grids.Rows[i]["GXID"]);
                gyid = Convert.ToInt32(grids.Rows[i]["GYID"]);
                x    = Convert.ToDouble(grids.Rows[i]["CX"]);
                y    = Convert.ToDouble(grids.Rows[i]["CY"]);
                z    = Convert.ToDouble(grids.Rows[i]["Dem"]);
                key  = string.Format("{0},{1}", gxid, gyid);
                ggrids.Add(key, new Point(x, y, z));
            }
            return(ggrids.Count);
        }
Beispiel #8
0
        static double leftBound = 666918, rightBound = 670080, downBound = 3542960, upBound = 3548826; // 南京 第一次压缩
        private void initRange()
        {
            #region 经纬度 转 xy
            LTE.Geometric.Point pt  = new Geometric.Point(this.minLongitude, this.minLatitude, 0);
            LTE.Geometric.Point pt1 = new Geometric.Point(this.maxLongitude, this.maxLatitude, 0);
            pt  = LTE.Utils.PointConvertByProj.Instance.GetGeoPoint(pt);
            pt1 = LTE.Utils.PointConvertByProj.Instance.GetGeoPoint(pt1);
            //IPoint pt = GeometryUtilities.ConstructPoint3D(this.minLongitude, this.minLatitude, 0);
            //IPoint pt1 = GeometryUtilities.ConstructPoint3D(this.maxLongitude, this.maxLatitude, 0);
            //pt = PointConvert.Instance.GetProjectPoint(pt);
            //pt1 = PointConvert.Instance.GetProjectPoint(pt1);
            #endregion

            leftBound  = pt.X;
            downBound  = pt.Y;
            rightBound = pt1.X;
            upBound    = pt1.Y;
        }
        /// <summary>
        /// 从数据库表tbGrid3D中取出所有符合条件的数据,并以GXID,GYID,GZID排序,组成空间网格集合
        /// </summary>
        /// <returns></returns>
        public static void constructGrid3D(ref Geometric.Point p1, ref Geometric.Point p2,
                                           ref Geometric.Point p3, ref Geometric.Point p4)
        {
            Hashtable para = new Hashtable();

            Grid3D gid1 = new Grid3D(), gid2 = new Grid3D(), gid3 = new Grid3D(), gid4 = new Grid3D();

            GridHelper.getInstance().PointXYZToGrid3D1(p1, ref gid1);
            GridHelper.getInstance().PointXYZToGrid3D1(p2, ref gid2);
            GridHelper.getInstance().PointXYZToGrid3D1(p3, ref gid3);
            GridHelper.getInstance().PointXYZToGrid3D1(p4, ref gid4);

            para["x1"] = gid1.gxid;
            para["x2"] = gid2.gxid;
            para["x3"] = gid3.gxid;
            para["x4"] = gid4.gxid;
            para["y1"] = gid1.gyid;
            para["y2"] = gid2.gyid;
            para["y3"] = gid3.gyid;
            para["y4"] = gid4.gyid;
            DataTable dt = IbatisHelper.ExecuteQueryForDataTable("GetBuildingGrid3D1", para);

            //Console.WriteLine(string.Format("{0} {1} {3}  {4} {5} {6} {7}", gid1.gxid, gid2.gxid, gid3.gxid, gid4.gxid, gid1.gyid, gid2.gyid, gid3.gyid, gid4.gyid);
            for (int i = 0; i < dt.Rows.Count; i++)//按行遍历DataTable
            {
                int buildingid = Convert.ToInt32(dt.Rows[i][0].ToString());
                //gxid,gyid,gzid
                string value = dt.Rows[i][1].ToString() + "," + dt.Rows[i][2].ToString() + "," + dt.Rows[i][3].ToString();
                if (bgrid3d.ContainsKey(buildingid))
                {
                    bgrid3d[buildingid].Add(value);
                }
                else
                {
                    List <string> list = new List <string>();
                    list.Add(value);
                    bgrid3d.Add(buildingid, list);
                }
            }
        }
Beispiel #10
0
        public Result rayTracing()
        {
            Result rt = this.validateCell();

            if (!rt.ok)
            {
                return(rt);
            }

            CellInfo cellInfo = new CellInfo(this.cellName, 0, 0);

            LTE.Geometric.Point p = new Geometric.Point(this.longitude, this.latitude, 0);
            p = LTE.Utils.PointConvertByProj.Instance.GetGeoPoint(p);

            RayTracing interAnalysis = new RayTracing(cellInfo, 3, 2, false);
            string     msg           = interAnalysis.SingleRayAnalysis(p.X, p.Y, p.Z);

            if (msg == "")
            {
                return(new Result(false, "射线到达建筑物顶面或经过若干次反射超出地图范围以致无法到达地面"));
            }
            return(new Result(true, msg));
        }
Beispiel #11
0
        void writeFinalResultToDB()
        {
            System.Data.DataTable dtable = new System.Data.DataTable();
            dtable.Columns.Add("id");
            dtable.Columns.Add("x");
            dtable.Columns.Add("y");
            dtable.Columns.Add("z");
            dtable.Columns.Add("Longitude");
            dtable.Columns.Add("Latitude");

            for (int i = 0; i < FinalResult.Count; i++)
            {
                System.Data.DataRow thisrow = dtable.NewRow();
                thisrow["id"] = i;
                thisrow["x"]  = Math.Round(FinalResult[i].x, 3);
                thisrow["y"]  = Math.Round(FinalResult[i].y, 3);
                thisrow["z"]  = Math.Round(FinalResult[i].z, 3);
                LTE.Geometric.Point pt = new Geometric.Point(FinalResult[i].x, FinalResult[i].y, 0);
                pt = LTE.Utils.PointConvertByProj.Instance.GetGeoPoint(pt);
                //IPoint pt = GeometryUtilities.ConstructPoint3D(FinalResult[i].x, FinalResult[i].y, 0);
                //PointConvert.Instance.GetGeoPoint(pt);
                thisrow["Longitude"] = Math.Round(pt.X, 6);
                thisrow["Latitude"]  = Math.Round(pt.Y, 6);
                dtable.Rows.Add(thisrow);
            }

            IbatisHelper.ExecuteDelete("DeleteInfSource", null);
            using (SqlBulkCopy bcp = new SqlBulkCopy(DataUtil.ConnectionString))
            {
                bcp.BatchSize            = dtable.Rows.Count;
                bcp.BulkCopyTimeout      = 1000;
                bcp.DestinationTableName = "tbInfSource";
                bcp.WriteToServer(dtable);
                bcp.Close();
            }
            dtable.Clear();
        }
        double constraint_low_bound   = 0.02;   // 策略3的控制参数

        //public Result smoothBuildingPoints()
        //{
        //    IbatisHelper.ExecuteDelete("DeleteBuildingVertex", null);

        //    DataTable dt = new DataTable();
        //    dt.Columns.Add("BuildingID", System.Type.GetType("System.Int32"));
        //    dt.Columns.Add("VertexLong", System.Type.GetType("System.Double"));
        //    dt.Columns.Add("VertexLat", System.Type.GetType("System.Double"));
        //    dt.Columns.Add("VertexX", System.Type.GetType("System.Double"));
        //    dt.Columns.Add("VertexY", System.Type.GetType("System.Double"));
        //    dt.Columns.Add("VIndex", System.Type.GetType("System.Int16"));

        //    Hashtable ht = new Hashtable();
        //    int pageindex = 0;
        //    int pagesize = 10000;
        //    ht["pageindex"] = pageindex;
        //    ht["pagesize"] = pagesize;
        //    BuildingGrid3D.constructBuildingVertexOriginalByBatch(pageParam: ht);
        //    while (BuildingGrid3D.buildingVertexOriginal.Count > 0)
        //    {
        //        int minBid, maxBid;
        //        BuildingGrid3D.getAllBuildingIDRange(out minBid, out maxBid);

        //        for (int i = minBid; i <= maxBid; i++)
        //        {
        //            List<LTE.Geometric.Point> bpoints = BuildingGrid3D.getBuildingVertexOriginal(i);

        //            List<LTE.Geometric.Point> ps = Process(ref bpoints);  // 2018-05-08
        //            if (ps.Count < 20)
        //                ps = bpoints;

        //            for (int j = 0; j < ps.Count; j++)
        //            {
        //                //使用proj.net库转换坐标,by JinHaijia
        //                LTE.Geometric.Point pCopy=new LTE.Geometric.Point(ps[j]);
        //                pCopy = LTE.Utils.PointConvertByProj.Instance.GetGeoPoint(pCopy);

        //                //旧版使用arcgis接口转换坐标
        //                //ESRI.ArcGIS.Geometry.IPoint p = GeometryUtilities.ConstructPoint2D(ps[j].X, ps[j].Y);
        //                //PointConvert.Instance.GetGeoPoint(p);

        //                //System.Diagnostics.Debug.WriteLine("transfNew long:" + pCopy.X + " latitude:" + pCopy.Y);
        //                //System.Diagnostics.Debug.WriteLine("transfOld long:" + p.X + " latitude:" + p.Y);
        //                //System.Diagnostics.Debug.WriteLine("_________");

        //                DataRow dr = dt.NewRow();
        //                dr["BuildingID"] = i;
        //                dr["VertexLong"] = pCopy.X;
        //                dr["VertexLat"] = pCopy.Y;
        //                dr["VertexX"] = ps[j].X;
        //                dr["VertexY"] = ps[j].Y;
        //                dr["VIndex"] = j;
        //                dt.Rows.Add(dr);
        //            }
        //            if (dt.Rows.Count >= 5000)
        //            {
        //                DataUtil.BCPDataTableImport(dt, "tbBuildingVertex");
        //                dt.Clear();
        //            }
        //        }
        //        DataUtil.BCPDataTableImport(dt, "tbBuildingVertex");
        //        dt.Clear();
        //        BuildingGrid3D.clearBuildingVertexOriginal();
        //        ht["pageindex"] = ++pageindex;
        //        BuildingGrid3D.constructBuildingVertexOriginalByBatch(pageParam: ht);
        //    }
        //    return new Result(true,"建筑物顶点平滑完成");
        //}


        public Result smoothBuildingPoints()
        {
            BuildingGrid3D.constructBuildingVertexOriginal();
            int minBid, maxBid;

            BuildingGrid3D.getAllBuildingIDRange(out minBid, out maxBid);

            DataTable dt = new DataTable();

            dt.Columns.Add("BuildingID", System.Type.GetType("System.Int32"));
            dt.Columns.Add("VertexLong", System.Type.GetType("System.Double"));
            dt.Columns.Add("VertexLat", System.Type.GetType("System.Double"));
            dt.Columns.Add("VertexX", System.Type.GetType("System.Double"));
            dt.Columns.Add("VertexY", System.Type.GetType("System.Double"));
            dt.Columns.Add("VIndex", System.Type.GetType("System.Int16"));

            try
            {
                IbatisHelper.ExecuteDelete("DeleteBuildingVertex", null);
            }
            catch (Exception e)
            {
                return(new Result(false, e.ToString()));
            }

            for (int i = minBid; i <= maxBid; i++)
            {
                List <LTE.Geometric.Point> bpoints = BuildingGrid3D.getBuildingVertexOriginal(i);

                List <LTE.Geometric.Point> ps = Process(ref bpoints);  // 2018-05-08


                if (ps.Count < 20)
                {
                    ps = bpoints;
                }

                for (int j = 0; j < ps.Count; j++)
                {
                    LTE.Geometric.Point p     = new Geometric.Point(ps[j].X, ps[j].Y, 0);
                    LTE.Geometric.Point pCopy = new LTE.Geometric.Point(ps[j]);
                    p = LTE.Utils.PointConvertByProj.Instance.GetGeoPoint(p);

                    DataRow dr = dt.NewRow();
                    dr["BuildingID"] = i;
                    dr["VertexLong"] = p.X;
                    dr["VertexLat"]  = p.Y;
                    dr["VertexX"]    = ps[j].X;
                    dr["VertexY"]    = ps[j].Y;
                    dr["VIndex"]     = j;
                    dt.Rows.Add(dr);
                }
                if (dt.Rows.Count >= 5000)
                {
                    DataUtil.BCPDataTableImport(dt, "tbBuildingVertex");
                    dt.Clear();
                }
            }
            DataUtil.BCPDataTableImport(dt, "tbBuildingVertex");
            dt.Clear();
            BuildingGrid3D.clearBuildingVertexOriginal();

            return(new Result(true));
        }
        /// <summary>
        /// 构建建筑物底面点数据和中心点以及高度数据,顶面所有点
        /// </summary>
        public static void constructBuildingData(ref Geometric.Point p1, ref Geometric.Point p2,
                                                 ref Geometric.Point p3, ref Geometric.Point p4)
        {
            DateTime t0, t1, t2, t3;

            t0 = DateTime.Now;

            Hashtable ht = new Hashtable();

            Grid3D gid1 = new Grid3D(), gid2 = new Grid3D(), gid3 = new Grid3D(), gid4 = new Grid3D();

            GridHelper.getInstance().PointXYZToGrid3D1(p1, ref gid1);
            GridHelper.getInstance().PointXYZToGrid3D1(p2, ref gid2);
            GridHelper.getInstance().PointXYZToGrid3D1(p3, ref gid3);
            GridHelper.getInstance().PointXYZToGrid3D1(p4, ref gid4);

            ht["x1"] = gid1.gxid;
            ht["x2"] = gid2.gxid;
            ht["x3"] = gid3.gxid;
            ht["x4"] = gid4.gxid;
            ht["y1"] = gid1.gyid;
            ht["y2"] = gid2.gyid;
            ht["y3"] = gid3.gyid;
            ht["y4"] = gid4.gyid;

            DataTable dt = IbatisHelper.ExecuteQueryForDataTable("GetBuildingCenter", ht);

            int    bid;
            double x, y, z, altitude;

            for (int i = 0; i < dt.Rows.Count; i++)//按行遍历DataTable
            {
                bid = Convert.ToInt32(dt.Rows[i]["BuildingID"]);
                if (bid > maxID)
                {
                    maxID = bid;
                }
                if (bid < minID)
                {
                    minID = bid;
                }
                x        = Convert.ToDouble(dt.Rows[i]["BCenterX"]);
                y        = Convert.ToDouble(dt.Rows[i]["BCenterY"]);
                z        = Convert.ToDouble(dt.Rows[i]["BHeight"]);
                altitude = Convert.ToDouble(dt.Rows[i]["BAltitude"]); // 地形
                buildingCenter.Add(bid, new Point(x, y, 0));
                buildingHeight.Add(bid, z + altitude);                // 地形
                buildingAltitude.Add(bid, altitude);                  // 地形
            }

            t1 = DateTime.Now;

            dt = IbatisHelper.ExecuteQueryForDataTable("GetBuildingVertex", ht);
            List <Point> vcollection;
            Point        t;

            //string path = @"f:\t2.txt";
            //StreamWriter sw = File.CreateText(path);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                bid = Convert.ToInt32(dt.Rows[i]["BuildingID"]);
                x   = Convert.ToDouble(dt.Rows[i]["VertexX"]);
                y   = Convert.ToDouble(dt.Rows[i]["VertexY"]);
                t   = new Point(x, y, 0);

                if (buildingVertex.ContainsKey(bid))
                {
                    buildingVertex[bid].Add(t);
                }
                else
                {
                    vcollection = new List <Point>();
                    vcollection.Add(t);
                    buildingVertex.Add(bid, vcollection);
                }
            }
            //sw.Close();
            t2 = DateTime.Now;

            dt = IbatisHelper.ExecuteQueryForDataTable("getBuildingTopVertex", ht);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                bid = Convert.ToInt32(dt.Rows[i]["BuildingID"]);
                x   = Convert.ToDouble(dt.Rows[i]["CX"]);
                y   = Convert.ToDouble(dt.Rows[i]["CY"]);
                z   = buildingHeight[bid];
                t   = new Point(x, y, z);

                //sw.Write(bid + ": " + c.X + " " + c.Y + "\n");

                if (buildingTopVertex.ContainsKey(bid))
                {
                    buildingTopVertex[bid].Add(t);
                }
                else
                {
                    vcollection = new List <Point>();
                    vcollection.Add(t);
                    buildingTopVertex.Add(bid, vcollection);
                }
            }
            //sw.Close();
            t3 = DateTime.Now;

            Console.WriteLine(string.Format("建筑物底面中心:{0}秒", (t1 - t0).TotalMilliseconds / 1000));
            Console.WriteLine(string.Format("建筑物底面顶点:{0}秒", (t2 - t1).TotalMilliseconds / 1000));
            Console.WriteLine(string.Format("建筑物顶面顶点:{0}", (t3 - t2).TotalMilliseconds / 1000));
        }
        /// <summary>
        /// 区域覆盖
        /// </summary>
        /// <param name="mingxid"></param>
        /// <param name="mingyid"></param>
        /// <param name="maxgxid"></param>
        /// <param name="maxgyid"></param>
        public bool constuctAreaGrids(int mingxid, int mingyid, int maxgxid, int maxgyid, string layerName)
        {
            DataTable gridTable = new DataTable();
            Hashtable ht        = new Hashtable();

            ht["MinGXID"] = mingxid;
            ht["MaxGXID"] = maxgxid;
            ht["MinGYID"] = mingyid;
            ht["MaxGYID"] = maxgyid;
            gridTable     = IbatisHelper.ExecuteQueryForDataTable("GetSpecifiedAreaGrids", ht);
            if (gridTable.Rows.Count < 1)
            {
                return(false);
            }

            /*
             *<select id="GetSpecifiedAreaGrids" parameterClass="Hashtable">
             *          select a.GXID, a.GYID, a.eNodeB, a.CI, d.MinLong, d.MinLat, d.MaxLong, d.MaxLat, a.ReceivedPowerdbm, a.PathLoss from tbGridPathloss a ,
             *          (select c.GXID, c.GYID, c.eNodeB, c.CI, max(c.ReceivedPowerdbm) ReceivedPowerdbm from tbGridPathloss c where c.GXID between '$MinGXID$' and '$MaxGXID$' and c.GYID between '$MinGYID$' and '$MaxGYID$'  group by c.gxid, c.gyid, c.eNodeB, c.ci having max(c.ReceivedPowerdbm) > -130 ) b,
             *          tbGridDem d
             *          where a.gxid = b.gxid and a.gyid = b.gyid and a.eNodeB = b.eNodeB and a.ci = b.ci and a.gxid = d.gxid and a.gyid = d.gyid
             *      </select>
             */
            IFeatureWorkspace featureWorkspace = MapWorkSpace.getWorkSpace();
            IFeatureClass     fclass           = featureWorkspace.OpenFeatureClass(layerName);

            //IFeatureLayer flayer = new FeatureLayer();
            pFeatureLayer.FeatureClass = pFeatureClass;

            //IFeatureLayer flayer = GISMapApplication.Instance.GetLayer(LayerNames.AreaCoverGrids) as IFeatureLayer;
            //FeatureUtilities.DeleteFeatureLayerFeatrues(flayer);

            //IFeatureClass fclass = flayer.FeatureClass;

            IDataset   dataset   = (IDataset)fclass;
            IWorkspace workspace = dataset.Workspace;
            //Cast for an IWorkspaceEdit
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

            //start an edit session and operation
            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IFeatureCursor pFeatureCursor = fclass.Insert(true);
            IFeatureBuffer pFeatureBuffer;

            //int gxid, gyid, lac, ci;
            //float x1, y1, x2, y2;
            //float recePower, pathLoss;
            int    lac, ci, gxid, gyid, level;
            double x1, y1, x2, y2, z;
            double recePower, pathLoss;
            double gbaseheight = GridHelper.getInstance().getGBaseHeight();
            double gheight     = GridHelper.getInstance().getGHeight();

            //循环添加
            int cnt = 0;

            //循环添加
            foreach (DataRow dataRow in gridTable.Rows)
            {
                if (cnt++ % 1000 == 0)
                {
                    Console.WriteLine("已计算  " + cnt + "/" + gridTable.Rows.Count);
                }
                gxid  = int.Parse(dataRow["GXID"].ToString());
                gyid  = int.Parse(dataRow["GYID"].ToString());
                level = int.Parse(dataRow["Level"].ToString());
                Geometric.Point p   = GridHelper.getInstance().GridToGeo(gxid, gyid);
                double          lon = p.X;
                double          lat = p.Y;
                //lac = int.Parse(dataRow["eNodeB"].ToString());
                //ci = int.Parse(dataRow["CI"].ToString());
                recePower = double.Parse(dataRow["ReceivedPowerdbm"].ToString());
                pathLoss  = double.Parse(dataRow["PathLoss"].ToString());

                if (!(double.TryParse(dataRow["MinX"].ToString(), out x1) &&
                      double.TryParse(dataRow["MinY"].ToString(), out y1) &&
                      double.TryParse(dataRow["MaxX"].ToString(), out x2) &&
                      double.TryParse(dataRow["MaxY"].ToString(), out y2)))
                {
                    continue;
                }

                z = gheight * (level - 1) + gbaseheight;

                IPoint pointA = GeometryUtilities.ConstructPoint3D(x1, y1, z);
                IPoint pointB = GeometryUtilities.ConstructPoint3D(x2, y1, z);
                IPoint pointC = GeometryUtilities.ConstructPoint3D(x2, y2, z);
                IPoint pointD = GeometryUtilities.ConstructPoint3D(x1, y2, z);

                IGeometryCollection pGeometryColl = GeometryUtilities.ConstructPolygon(new IPoint[] { pointA, pointB, pointC, pointD });
                GeometryUtilities.MakeZAware(pGeometryColl as IGeometry);

                pFeatureBuffer       = pFeatureClass.CreateFeatureBuffer();
                pFeatureBuffer.Shape = pGeometryColl as IGeometry;
                pFeatureBuffer.set_Value(this.GXIDIndex, gxid);
                pFeatureBuffer.set_Value(this.GYIDIndex, gyid);
                pFeatureBuffer.set_Value(this.eNodeBIndex, 0);
                pFeatureBuffer.set_Value(this.CIIndex, 0);
                pFeatureBuffer.set_Value(this.cellNameIndex, "");
                pFeatureBuffer.set_Value(this.LongitudeIndex, lon);
                pFeatureBuffer.set_Value(this.LatitudeIndex, lat);
                pFeatureBuffer.set_Value(this.LevelIndex, level);
                if (recePower > -41)
                {
                    pFeatureBuffer.set_Value(this.RecePowerIndex, -41);
                }
                //else if(recePower < -110)
                //    pFeatureBuffer.set_Value(this.RecePowerIndex, -110);
                else
                {
                    pFeatureBuffer.set_Value(this.RecePowerIndex, recePower);
                }
                pFeatureBuffer.set_Value(this.PathLossIndex, pathLoss);
                pFeatureCursor.InsertFeature(pFeatureBuffer);
            }

            //一次性提交
            pFeatureCursor.Flush();

            //stop editing
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            IFeatureClassManage pFeatureClassManage = (IFeatureClassManage)pFeatureClass;

            pFeatureClassManage.UpdateExtent();

            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureClassManage);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(dataset);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(workspace);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);

            //GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
            return(true);
        }
        /// <summary>
        /// 构造小区覆盖网格
        /// </summary>
        /// <param name="cellname"></param>
        /// <param name="enodeb"></param>
        /// <param name="ci"></param>
        public bool constuctCellGrids(string cellname, int enodeb, int ci)
        {
            DataTable gridTable = new DataTable();
            Hashtable ht        = new Hashtable();

            ht["eNodeB"] = enodeb;
            ht["CI"]     = ci;
            gridTable    = IbatisHelper.ExecuteQueryForDataTable("GetSpecifiedCellGrids", ht);
            if (gridTable.Rows.Count < 1)
            {
                return(false);
            }

            IDataset       dataset       = (IDataset)pFeatureLayer.FeatureClass;
            IWorkspace     workspace     = dataset.Workspace;
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IFeatureCursor pFeatureCursor = pFeatureClass.Insert(true);
            IFeatureBuffer pFeatureBuffer;

            int    gxid, gyid, level;
            double x1, y1, x2, y2, z;
            double recePower, pathLoss;
            double gheight = GridHelper.getInstance().getGHeight();
            //循环添加
            int cnt = 0;
            //初始化进度信息
            LoadInfo loadInfo = new LoadInfo();

            loadInfo.count = gridTable.Rows.Count;
            loadInfo.loadCreate();

            foreach (DataRow dataRow in gridTable.Rows)
            {
                if (cnt++ % 1000 == 0)
                {
                    loadInfo.cnt = cnt;
                    loadInfo.loadUpdate();
                    Console.WriteLine("已计算  " + cnt + "/" + gridTable.Rows.Count);
                }
                gxid  = int.Parse(dataRow["Gxid"].ToString());
                gyid  = int.Parse(dataRow["Gyid"].ToString());
                level = int.Parse(dataRow["Level"].ToString());

                Geometric.Point p   = GridHelper.getInstance().GridToGeo(gxid, gyid);
                double          lon = p.X;
                double          lat = p.Y;

                //if (!(float.TryParse(dataRow["MinX"].ToString(), out x1) && float.TryParse(dataRow["MinY"].ToString(), out y1) && float.TryParse(dataRow["MaxX"].ToString(), out x2) && float.TryParse(dataRow["MaxY"].ToString(), out y2) && float.TryParse(dataRow["ReceivedPowerdbm"].ToString(), out recePower) && float.TryParse(dataRow["PathLoss"].ToString(), out pathLoss)))
                //    continue;

                if (!(double.TryParse(dataRow["MinX"].ToString(), out x1) && double.TryParse(dataRow["MinY"].ToString(), out y1)))
                {
                    continue;
                }
                if (!(double.TryParse(dataRow["MaxX"].ToString(), out x2) && double.TryParse(dataRow["MaxY"].ToString(), out y2)))
                {
                    continue;
                }
                if (!(double.TryParse(dataRow["ReceivedPowerdbm"].ToString(), out recePower) && double.TryParse(dataRow["PathLoss"].ToString(), out pathLoss)))
                {
                    continue;
                }
                z = gheight * level;

                IPoint pointA = GeometryUtilities.ConstructPoint3D(x1, y1, z);
                IPoint pointB = GeometryUtilities.ConstructPoint3D(x2, y1, z);
                IPoint pointC = GeometryUtilities.ConstructPoint3D(x2, y2, z);
                IPoint pointD = GeometryUtilities.ConstructPoint3D(x1, y2, z);

                IGeometryCollection pGeometryColl = GeometryUtilities.ConstructPolygon(new IPoint[] { pointA, pointB, pointC, pointD });
                GeometryUtilities.MakeZAware(pGeometryColl as IGeometry);

                pFeatureBuffer       = pFeatureClass.CreateFeatureBuffer();
                pFeatureBuffer.Shape = pGeometryColl as IGeometry;
                pFeatureBuffer.set_Value(this.GXIDIndex, gxid);
                pFeatureBuffer.set_Value(this.GYIDIndex, gyid);
                pFeatureBuffer.set_Value(this.eNodeBIndex, enodeb);
                pFeatureBuffer.set_Value(this.CIIndex, ci);
                pFeatureBuffer.set_Value(this.cellNameIndex, cellname);
                pFeatureBuffer.set_Value(this.LevelIndex, level);
                pFeatureBuffer.set_Value(this.LongitudeIndex, lon);
                pFeatureBuffer.set_Value(this.LatitudeIndex, lat);


                if (recePower > -41)
                {
                    pFeatureBuffer.set_Value(this.RecePowerIndex, -41);
                }
                //else if(recePower < -110)
                //    pFeatureBuffer.set_Value(this.RecePowerIndex, -110);
                else
                {
                    pFeatureBuffer.set_Value(this.RecePowerIndex, recePower);
                }
                pFeatureBuffer.set_Value(this.PathLossIndex, pathLoss);
                pFeatureCursor.InsertFeature(pFeatureBuffer);

                //释放AO对象
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureBuffer);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pGeometryColl);
            }

            //一次性提交
            pFeatureCursor.Flush();

            //stop editing
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            IFeatureClassManage pFeatureClassManage = (IFeatureClassManage)pFeatureClass;

            pFeatureClassManage.UpdateExtent();

            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureClassManage);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(dataset);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(workspace);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);

            //更新完成进度信息
            loadInfo.cnt = cnt;
            loadInfo.loadUpdate();
            //GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
            return(true);
        }
        // 2018.12.12
        public void getPaths1()
        {
            for (int i = 0; i < m_leaves.Count; i++)
            {
                Rays rays = new Rays();

                Vector3 s = new Vector3(ref m_source.m_position);

                int nodeIndex = m_leaves[i];

                // 收集多边形
                int order = 0;
                // 只有靠近发射源的面 nodeIndex == 0
                List <Vector3> pts = new List <Vector3>();
                while (nodeIndex != 0)  // m_polygonCache 中,第一个面是靠近目标的面,最后一个面是靠近发射源的面
                {
                    m_polygonCache[order++] = new Polygon(ref m_solutionNodes[nodeIndex].m_polygon);

                    // 得到 poly 的中心
                    Polygon poly = m_solutionNodes[nodeIndex].m_clipedPolygon;
                    float   cx = 0, cy = 0, cz = 0;
                    int     n = poly.m_points.Count;
                    for (int k = 0; k < n; k++)
                    {
                        cx += poly.m_points[k].x;
                        cy += poly.m_points[k].y;
                        cz += poly.m_points[k].z;
                    }
                    Vector3 pt = new Vector3(cx / n, cy / n, cz / n);
                    pts.Add(pt);

                    nodeIndex = m_solutionNodes[nodeIndex].m_parent;
                }

                bool    ok = true;
                Vector3 t;
                int     prePolyId = -1;
                for (int j = order - 1; j >= 0; j--)  // 从靠近源的面开始
                {
                    Polygon poly = m_polygonCache[j];

                    t = pts[j];

                    Ray ray = new Ray(ref s, ref t);
                    if (m_room.getKD().rayCastAny(ref ray, poly.m_id, prePolyId))  // 非法路径
                    {
                        ok = false;
                        break;
                    }

                    s         = t;
                    prePolyId = poly.m_id;

                    NodeInfo rayInfo;
                    if (j == order - 1)
                    {
                        rayInfo = Ray.createRay(ref ray);
                    }
                    else
                    {
                        Vector4 pleq = poly.getPleq();
                        rayInfo = Ray.createRay(ref ray, ref pleq);
                    }
                    rayInfo.buildingID = poly.m_buildingID;
                    rays.m_rays.Add(rayInfo);
                }

                if (ok)  // 整个路径段合法
                {
                    double rayAzimuth          = 0;
                    double rayIncination       = 0;
                    LTE.Geometric.Point startp = new Geometric.Point(rays.m_rays[0].PointOfIncidence.m_position.x, rays.m_rays[0].PointOfIncidence.m_position.y, rays.m_rays[0].PointOfIncidence.m_position.z);
                    LTE.Geometric.Point endp   = new Geometric.Point(rays.m_rays[0].CrossPoint.m_position.x, rays.m_rays[0].CrossPoint.m_position.y, rays.m_rays[0].CrossPoint.m_position.z);
                    LTE.Geometric.GeometricUtilities.getAzimuth_Inclination(startp, endp, out rayAzimuth, out rayIncination);
                    double[] ret = this.calcStrength.calcRayStrengthBeam(rayAzimuth, rayIncination, ref rays.m_rays);
                    rays.emitPwrDbm = this.calcStrength.convertw2dbm(ret[2]);
                    rays.recvPwrDbm = this.calcStrength.convertw2dbm(ret[0]);

                    m_rays.Add(rays);
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// 构造小区立体顶面覆盖网格
        /// </summary>
        /// <param name="cellname"></param>
        /// <param name="lac"></param>
        /// <param name="ci"></param>
        public void constuctCellGrid3Dtops(string cellname, int eNodeB, int ci)
        {
            DataTable gridTable = new DataTable();
            Hashtable ht        = new Hashtable();

            ht["eNodeB"] = eNodeB;
            ht["CI"]     = ci;
            gridTable    = IbatisHelper.ExecuteQueryForDataTable("GetSpecifiedCellGrid3Ds", ht);
            //gridTable = IbatisHelper.ExecuteQueryForDataTable("GetAreaGrid3Ds", null);

            IDataset   dataset   = (IDataset)pFeatureLayer.FeatureClass;
            IWorkspace workspace = dataset.Workspace;
            //Cast for an IWorkspaceEdit
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

            //start an edit session and operation
            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IFeatureCursor pFeatureCursor = pFeatureClass.Insert(true);
            IFeatureBuffer pFeatureBuffer;

            int    gxid, gyid, level;
            double x1, y1, x2, y2, z;
            double recePower, pathLoss;
            double gbaseheight = GridHelper.getInstance().getGBaseHeight();
            double gheight     = GridHelper.getInstance().getGHeight();

            //循环添加
            foreach (DataRow dataRow in gridTable.Rows)
            {
                gxid  = int.Parse(dataRow["Gxid"].ToString());
                gyid  = int.Parse(dataRow["Gyid"].ToString());
                level = int.Parse(dataRow["level"].ToString());
                Geometric.Point p   = GridHelper.getInstance().GridToGeo(gxid, gyid);
                double          lon = p.X;
                double          lat = p.Y;
                if (!(double.TryParse(dataRow["MinX"].ToString(), out x1) && double.TryParse(dataRow["MinY"].ToString(), out y1) && double.TryParse(dataRow["MaxX"].ToString(), out x2) && double.TryParse(dataRow["MaxY"].ToString(), out y2) && double.TryParse(dataRow["ReceivedPowerdbm"].ToString(), out recePower) && double.TryParse(dataRow["PathLoss"].ToString(), out pathLoss)))
                {
                    continue;
                }
                z = gheight * (level - 1) + gbaseheight;

                IPoint pointA = GeometryUtilities.ConstructPoint3D(x1, y1, z);
                IPoint pointB = GeometryUtilities.ConstructPoint3D(x2, y1, z);
                IPoint pointC = GeometryUtilities.ConstructPoint3D(x2, y2, z);
                IPoint pointD = GeometryUtilities.ConstructPoint3D(x1, y2, z);

                IGeometryCollection pGeometryColl = GeometryUtilities.ConstructPolygon(new IPoint[] { pointA, pointB, pointC, pointD });
                GeometryUtilities.MakeZAware(pGeometryColl as IGeometry);


                pFeatureBuffer       = pFeatureClass.CreateFeatureBuffer();
                pFeatureBuffer.Shape = pGeometryColl as IGeometry;
                pFeatureBuffer.set_Value(this.GXIDIndex, gxid);
                pFeatureBuffer.set_Value(this.GYIDIndex, gyid);
                pFeatureBuffer.set_Value(this.LevelIndex, level);
                pFeatureBuffer.set_Value(this.eNodeBIndex, eNodeB);
                pFeatureBuffer.set_Value(this.CIIndex, ci);
                pFeatureBuffer.set_Value(this.cellNameIndex, cellname);
                pFeatureBuffer.set_Value(this.LongitudeIndex, lon);
                pFeatureBuffer.set_Value(this.LatitudeIndex, lat);
                if (recePower > -41)
                {
                    pFeatureBuffer.set_Value(this.RecePowerIndex, -41);
                }
                //else if (recePower < -110)
                //    pFeatureBuffer.set_Value(this.RecePowerIndex, -110);
                else
                {
                    pFeatureBuffer.set_Value(this.RecePowerIndex, recePower);
                }
                pFeatureBuffer.set_Value(this.PathLossIndex, pathLoss);
                pFeatureCursor.InsertFeature(pFeatureBuffer);
            }

            //一次性提交
            pFeatureCursor.Flush();

            //stop editing
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            //IFeatureClassManage pFeatureClassManage = (IFeatureClassManage)pFeatureClass;
            //pFeatureClassManage.UpdateExtent();

            GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
            //GISMapApplication.Instance.FullExtent(pFeatureLayer.AreaOfInterest);
        }
        /// <summary>
        /// 刷新虚拟干扰源图层
        /// </summary>
        public bool ConstuctSelectPoints(string fromname)
        {
            Hashtable ht = new Hashtable();

            ht["fromName"] = fromname;
            DataTable virTable = IbatisHelper.ExecuteQueryForDataTable("GetSelectedPoint", ht);

            if (virTable.Rows.Count < 2)
            {
                return(false);
            }
            IDataset   dataset   = (IDataset)pFeatureClass;
            IWorkspace workspace = dataset.Workspace;
            //Cast for an IWorkspaceEdit
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

            //start an edit session and operation
            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IFeatureCursor pFeatureCursor = pFeatureClass.Insert(true);
            IFeatureBuffer pFeatureBuffer;


            //循环添加
            double circRadius = 60;//扇区生成的半径大小
            double every      = 1;


            foreach (DataRow vir in virTable.Rows)
            {
                int    ci        = Convert.ToInt32(vir["CI"]);
                string fromName  = Convert.ToString(vir["fromName"]);
                double ReceivePW = Convert.ToDouble(vir["ReceivePW"]);
                double azimuth   = Convert.ToDouble(vir["Azimuth"]);



                pFeatureBuffer = pFeatureClass.CreateFeatureBuffer();//创建图元缓冲


                double x = Convert.ToDouble(vir["x"]);
                double y = Convert.ToDouble(vir["y"]);

                IPoint startPoint = GeometryUtilities.ConstructPoint3D(x, y, 0);

                LTE.Geometric.Point p = new Geometric.Point(x, y, 0);
                PointConvertByProj.Instance.GetGeoPoint(p);

                double Direction = (450 - azimuth) % 360;

                IPoint leftPoint  = GeometryUtilities.ConstructPoint3D(circRadius * Math.Cos((Direction - 18 * every) * Math.PI / 180) + x, y + circRadius * Math.Sin((Direction - 18 * every) * Math.PI / 180), 0);
                IPoint rightPoint = GeometryUtilities.ConstructPoint3D(circRadius * Math.Cos((Direction + 18 * every) * Math.PI / 180) + x, y + circRadius * Math.Sin((Direction + 9 * every) * Math.PI / 180), 0);

                IGeometryCollection pGeometryColl = GeometryUtilities.ConstructPolygon(new IPoint[] { startPoint, leftPoint, rightPoint });
                GeometryUtilities.MakeZAware(pGeometryColl as IGeometry);

                ///暂时没添加经纬度

                pFeatureBuffer.Shape = pGeometryColl as IGeometry;
                pFeatureBuffer.set_Value(CIIndex, ci);
                pFeatureBuffer.set_Value(FromIndex, fromName);
                pFeatureBuffer.set_Value(AziIndex, azimuth);
                pFeatureBuffer.set_Value(LonIndex, p.X);
                pFeatureBuffer.set_Value(LatIndex, p.Y);
                pFeatureBuffer.set_Value(RecPwIndex, 10 * (Math.Log10(ReceivePW) + 3));
                pFeatureCursor.InsertFeature(pFeatureBuffer);
            }

            //一次性提交
            pFeatureCursor.Flush();

            //stop editing
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
            return(true);
            //GISMapApplication.Instance.FullExtent(pFeatureLayer.AreaOfInterest);
        }
        private Boolean CompleteAzimuth(DataTable dtinfo)
        {
            tb.Clear();
            double avgx = 0, avgy = 0;

            for (int i = 0; i < dtinfo.Rows.Count; i++)
            {
                double x = Convert.ToDouble(dtinfo.Rows[i]["x"]);
                double y = Convert.ToDouble(dtinfo.Rows[i]["y"]);
                avgx += x;
                avgy += y;
            }
            avgx /= dtinfo.Rows.Count;
            avgy /= dtinfo.Rows.Count;
            Debug.WriteLine("路测中点:x" + avgx + "路测中点:x" + avgy);
            Geometric.Point endavg = new Geometric.Point(avgx, avgy, 0);

            double minx = double.MaxValue, miny = double.MaxValue, maxx = double.MinValue, maxy = double.MinValue;

            for (int i = 0; i < dtinfo.Rows.Count; i++)
            {
                //Debug.WriteLine(i);
                double x = Convert.ToDouble(dtinfo.Rows[i]["x"]);
                double y = Convert.ToDouble(dtinfo.Rows[i]["y"]);

                if (x < minx)
                {
                    minx = x;
                }
                if (x > maxx)
                {
                    maxx = x;
                }
                if (y < miny)
                {
                    miny = y;
                }
                if (y > maxy)
                {
                    maxy = y;
                }

                Geometric.Point start = new Geometric.Point(x, y, 0);

                double aziavg = LTE.Geometric.GeometricUtilities.getPolarCoord(start, endavg).theta / Math.PI * 180;
                aziavg = GeometricUtilities.ConvertGeometricArithmeticAngle(aziavg + 1);
                Debug.WriteLine("路测中点计算角度:" + aziavg);
                DataRow thisrow = tb.NewRow();
                thisrow["fromName"]  = this.virname;
                thisrow["x"]         = x;
                thisrow["y"]         = y;
                thisrow["ReceivePW"] = dtinfo.Rows[i]["ReceivePW"];
                thisrow["CI"]        = dtinfo.Rows[i]["CI"];
                thisrow["Azimuth"]   = aziavg;
                thisrow["Distance"]  = distanceXY(start.X, start.Y, endavg.X, endavg.Y) + 300;
                tb.Rows.Add(thisrow);
            }
            if (maxx - minx < 100 || maxy - maxx < 100)
            {
                tb.Clear();
                return(false);
            }
            return(true);
        }
        // 2018.12.13
        public void getPaths()
        {
            for (int i = 0; i < m_leaves.Count; i++)
            {
                int nodeIndex = m_leaves[i];

                // 收集 beam 多边形
                int order = 0;
                List <List <Vector3> > pts = new List <List <Vector3> >(); // 每个多边形内的点
                int maxCnt = 0, minCnt = 1000000;
                // 只有靠近发射源的面 nodeIndex == 0
                while (nodeIndex != 0)  // m_polygonCache 中,第一个面是靠近目标的面,最后一个面是靠近发射源的面
                {
                    m_polygonCache[order++] = new Polygon(ref m_solutionNodes[nodeIndex].m_polygon);

                    List <Vector3> pt = m_solutionNodes[nodeIndex].m_polygon.getInerPoints(10, ref m_solutionNodes[nodeIndex].m_clipedPolygon.m_points);

                    if (pt.Count == 0)
                    {
                        // 得到 poly 的中心
                        Polygon poly = m_solutionNodes[nodeIndex].m_clipedPolygon;
                        float   cx = 0, cy = 0, cz = 0;
                        int     n = poly.m_points.Count;
                        for (int k = 0; k < n; k++)
                        {
                            cx += poly.m_points[k].x;
                            cy += poly.m_points[k].y;
                            cz += poly.m_points[k].z;
                        }
                        Vector3 tmp = new Vector3(cx / n, cy / n, cz / n);
                        pt.Add(tmp);
                    }

                    pts.Add(pt);
                    maxCnt = Math.Max(maxCnt, pt.Count);
                    minCnt = Math.Min(minCnt, pt.Count);

                    nodeIndex = m_solutionNodes[nodeIndex].m_parent;
                }

                int times = (maxCnt + minCnt) / 2;
                if (times == 0)
                {
                    times = 1;
                }

                int pre   = m_rays.Count;
                HashSet <String> pathExist = new HashSet <string>();

                #region 随机组合 times 条主路径
                for (int k = 0; k < times; k++)
                {
                    string route = "";

                    bool    ok = true;
                    Vector3 t;
                    int     prePolyId = -1;
                    Rays    rays      = new Rays();
                    Vector3 s         = new Vector3(ref m_source.m_position);
                    for (int j = order - 1; j >= 0; j--)  // 从靠近源的面开始
                    {
                        Polygon poly = m_polygonCache[j];

                        int id = rand.Next(0, pts[j].Count);
                        t      = pts[j][id];
                        route += string.Format("{0}", id) + ",";

                        Ray ray = new Ray(ref s, ref t);
                        if (m_room.getKD().rayCastAny(ref ray, poly.m_id, prePolyId))  // 非法路径
                        {
                            ok = false;
                            break;
                        }

                        s         = t;
                        prePolyId = poly.m_id;

                        NodeInfo rayInfo;
                        if (j == order - 1)
                        {
                            rayInfo = Ray.createRay(ref ray);
                        }
                        else
                        {
                            Vector4 pleq = poly.getPleq();
                            rayInfo = Ray.createRay(ref ray, ref pleq);
                        }
                        rayInfo.buildingID = poly.m_buildingID;

                        if (double.IsNaN(rayInfo.Angle) || double.IsInfinity(rayInfo.Angle))
                        {
                            ok = false;
                            break;
                        }

                        if (pathExist.Contains(route))  // 该路径已经存在过了
                        {
                            ok = false;
                        }
                        else
                        {
                            rays.m_rays.Add(rayInfo);
                        }
                    }

                    if (ok)  // 整个路径段合法
                    {
                        pathExist.Add(route);

                        double rayAzimuth          = 0;
                        double rayIncination       = 0;
                        LTE.Geometric.Point startp = new Geometric.Point(rays.m_rays[0].PointOfIncidence.m_position.x, rays.m_rays[0].PointOfIncidence.m_position.y, rays.m_rays[0].PointOfIncidence.m_position.z);
                        LTE.Geometric.Point endp   = new Geometric.Point(rays.m_rays[0].CrossPoint.m_position.x, rays.m_rays[0].CrossPoint.m_position.y, rays.m_rays[0].CrossPoint.m_position.z);
                        LTE.Geometric.GeometricUtilities.getAzimuth_Inclination(startp, endp, out rayAzimuth, out rayIncination);
                        double[] ret = this.calcStrength.calcRayStrengthBeam(rayAzimuth, rayIncination, ref rays.m_rays);
                        rays.emitPwrDbm = this.calcStrength.convertw2dbm(ret[2]);
                        rays.recvPwrDbm = this.calcStrength.convertw2dbm(ret[0]);

                        m_rays.Add(rays);
                        rayCount += rays.m_rays.Count;
                    }
                }
                #endregion

                #region 加入最短主路径  2018.12.20
                //if (m_rays.Count - pre > 0 && times > 1)
                //{
                //    List<Vector3> ss = new List<Vector3>();
                //    ss.Add(new Vector3(ref m_source.m_position));
                //    pts.Add(ss);
                //    string route = "";
                //    Vector3[] path = plane(ref pts, maxCnt, ref route);  // 多阶段图最短路径
                //    if (!pathExist.Contains(route))  // 该路径未被加入
                //    {
                //        bool ok = true;
                //        Vector3 t;
                //        int prePolyId = -1;
                //        Rays rays = new Rays();
                //        Vector3 s = path[order];
                //        for (int j = order - 1; j >= 0; j--)  // 从靠近源的面开始
                //        {
                //            Polygon poly = m_polygonCache[j];

                //            t = path[j];

                //            Ray ray = new Ray(ref s, ref t);
                //            if (m_room.getKD().rayCastAny(ref ray, poly.m_id, prePolyId))  // 非法路径
                //            {
                //                ok = false;
                //                break;
                //            }

                //            s = t;
                //            prePolyId = poly.m_id;

                //            NodeInfo rayInfo;
                //            if (j == order - 1)
                //            {
                //                rayInfo = Ray.createRay(ref ray);
                //            }
                //            else
                //            {
                //                Vector4 pleq = poly.getPleq();
                //                rayInfo = Ray.createRay(ref ray, ref pleq);
                //            }
                //            rayInfo.buildingID = poly.m_buildingID;

                //            if (double.IsNaN(rayInfo.Angle) || double.IsInfinity(rayInfo.Angle))
                //            {
                //                ok = false;
                //                break;
                //            }

                //            rays.m_rays.Add(rayInfo);
                //        }

                //        if (ok)  // 整个路径段合法
                //        {
                //            double rayAzimuth = 0;
                //            double rayIncination = 0;
                //            LTE.Geometric.Point startp = new Geometric.Point(rays.m_rays[0].PointOfIncidence.m_position.x, rays.m_rays[0].PointOfIncidence.m_position.y, rays.m_rays[0].PointOfIncidence.m_position.z);
                //            LTE.Geometric.Point endp = new Geometric.Point(rays.m_rays[0].CrossPoint.m_position.x, rays.m_rays[0].CrossPoint.m_position.y, rays.m_rays[0].CrossPoint.m_position.z);
                //            LTE.Geometric.GeometricUtilities.getAzimuth_Inclination(startp, endp, out rayAzimuth, out rayIncination);
                //            double[] ret = this.calcStrength.calcRayStrengthBeam(rayAzimuth, rayIncination, ref rays.m_rays);
                //            rays.emitPwrDbm = this.calcStrength.convertw2dbm(ret[2]);
                //            rays.recvPwrDbm = this.calcStrength.convertw2dbm(ret[0]);

                //            m_rays.Add(rays);
                //        }
                //    }
                //}
                #endregion
            }
        }
Beispiel #21
0
        // 根据强弱相间点对栅格打分
        private Result strongWeakLoc()
        {
            Pt.Sort(new StrongWeakPtCmp());

            // 加载加速结构
            RayTracing inter = new RayTracing();

            inter.SinglePrepare(leftBound, rightBound, downBound, upBound);

            // 从每个点发出360*360条射线,经过的格子分值加1,分数最高的格子为可能位置
            Dictionary <string, int> dic = new Dictionary <string, int>();

            for (int i = 0; i < Pt.Count && i < 20; i++)
            {
                for (int j = 0; j < 360; j++)
                {
                    for (int h = 3; h < 100; h += 3)
                    {
                        double angle = (double)(j) / 180.0 * Math.PI;
                        LTE.Geometric.Point    endPoint = new Geometric.Point(Pt[i].strong.X + Math.Cos(angle), Pt[i].strong.Y + Math.Sin(angle), (double)h);
                        LTE.Geometric.Vector3D dir      = LTE.Geometric.Vector3D.constructVector(Pt[i].strong, endPoint);
                        inter.SingleRayJudge(Pt[i].strong, dir, ref dic, true);

                        LTE.Geometric.Point    endPoint1 = new Geometric.Point(Pt[i].weak.X + Math.Cos(angle), Pt[i].weak.Y + Math.Sin(angle), (double)h);
                        LTE.Geometric.Vector3D dir1      = LTE.Geometric.Vector3D.constructVector(Pt[i].weak, endPoint1);
                        inter.SingleRayJudge(Pt[i].weak, dir1, ref dic, false);
                    }
                }
            }

            if (dic.Count == 0)
            {
                return(new Result(false, "强弱点对未推出合理结果"));
            }

            // 挑选分数最高的格子
            var maxKey    = (from d in dic orderby d.Value descending select d.Key).First();
            var allMaxKey = (from d in dic where d.Value == dic[maxKey] select d.Key).ToArray();

            int    cnt = 0;
            double X = 0, Y = 0, Z = 0;

            if (allMaxKey.Count() > 5)
            {
                foreach (string a in allMaxKey)  // 有多个分数最高的格子
                {
                    string[] num = a.Split(',');
                    GridHelper.getInstance().AccGridToXYZ(Convert.ToInt32(num[0]), Convert.ToInt32(num[1]), Convert.ToInt32(num[2]), ref X, ref Y, ref Z);

                    Pt3D pt = new Pt3D(X, Y, Z);
                    if (inBound(ref pt))
                    {
                        StrongWeakResult.Add(pt);
                    }
                }
            }
            else
            {
                var dicSort = from objDic in dic orderby objDic.Value descending select objDic;
                foreach (KeyValuePair <string, int> kvp in dicSort)
                {
                    string[] num = kvp.Key.Split(',');
                    GridHelper.getInstance().AccGridToXYZ(Convert.ToInt32(num[0]), Convert.ToInt32(num[1]), 0, ref X, ref Y, ref Z);

                    ++cnt;

                    Pt3D pt = new Pt3D(X, Y, Z);
                    if (inBound(ref pt))
                    {
                        StrongWeakResult.Add(pt);
                    }

                    if (cnt > 5)
                    {
                        break;
                    }
                }
            }
            return(new Result(true));
        }
        // 虚拟路测场强填写
        public static void DTStrength()
        {
            // 读取原始路测
            DataTable tb1  = IbatisHelper.ExecuteQueryForDataTable("getDT1", null);
            int       n    = tb1.Rows.Count;
            List <DT> tbDT = new List <DT>();

            for (int i = 0; i < tb1.Rows.Count; i++)
            {
                DT dt = new DT();
                dt.id     = Convert.ToInt32(tb1.Rows[i]["id"].ToString());
                dt.roadID = Convert.ToInt32(tb1.Rows[i]["roadID"].ToString());
                dt.ci     = Convert.ToInt32(tb1.Rows[i]["ci"].ToString());
                //dt.longitude = Convert.ToDouble(tb1.Rows[i]["longtitude"].ToString());
                //dt.latitude = Convert.ToDouble(tb1.Rows[i]["latitude"].ToString());
                dt.x = Convert.ToDouble(tb1.Rows[i]["x"].ToString());
                dt.y = Convert.ToDouble(tb1.Rows[i]["y"].ToString());
                tbDT.Add(dt);
            }

            // 得到网格编号,写入数据库
            System.Data.DataTable tb = new System.Data.DataTable();
            tb.Columns.Add("id");
            tb.Columns.Add("dateTime");
            tb.Columns.Add("GXID");
            tb.Columns.Add("GYID");
            tb.Columns.Add("ci");
            tb.Columns.Add("RoadID");
            tb.Columns.Add("x");
            tb.Columns.Add("y");
            tb.Columns.Add("longtitude");
            tb.Columns.Add("latitude");
            tb.Columns.Add("RecePowerDbm");


            int xid = 0, yid = 0;

            for (int i = 0; i < tbDT.Count; i++)
            {
                GridHelper.getInstance().XYToGGrid(tbDT[i].x, tbDT[i].y, ref xid, ref yid); // 网格编号

                //IPoint p = new PointClass();
                Geometric.Point p = new Geometric.Point();
                p.X = tbDT[i].x;
                p.Y = tbDT[i].y;
                p.Z = 0;
                LTE.Utils.PointConvertByProj.Instance.GetGeoPoint(p);

                DateTime dt = DateTime.Now;

                System.Data.DataRow thisrow = tb.NewRow();
                thisrow["id"]           = tbDT[i].id;
                thisrow["dateTime"]     = dt.ToLocalTime().ToString();
                thisrow["GXID"]         = xid;
                thisrow["GYID"]         = yid;
                thisrow["ci"]           = tbDT[i].ci;
                thisrow["RoadID"]       = tbDT[i].roadID;
                thisrow["x"]            = tbDT[i].x;
                thisrow["y"]            = tbDT[i].y;
                thisrow["longtitude"]   = Math.Round(p.X, 6);
                thisrow["latitude"]     = Math.Round(p.Y, 6);
                thisrow["RecePowerDbm"] = 0;
                tb.Rows.Add(thisrow);
            }

            // 删除原始路测
            IbatisHelper.ExecuteDelete("DeleteDT", null);

            using (SqlBulkCopy bcp = new SqlBulkCopy(DataUtil.ConnectionString))
            {
                bcp.BatchSize            = tb.Rows.Count;
                bcp.BulkCopyTimeout      = 1000;
                bcp.DestinationTableName = "tbDT";
                bcp.WriteToServer(tb);
                bcp.Close();
            }
            tb.Clear();

            // 得到网格对应的路测数据
            IbatisHelper.ExecuteUpdate("UpdateDT1", null);
            IbatisHelper.ExecuteUpdate("UpdateDT2", null);
        }
Beispiel #23
0
        /// <summary>
        /// 网内干扰分析
        /// </summary>
        /// <returns></returns>
        public Result defectAnalysis()
        {
            // 经纬度转换为栅格ID
            LTE.Geometric.Point pMin = new Geometric.Point();
            pMin.X = this.minLongitude;
            pMin.Y = this.minLatitude;
            pMin.Z = 0;
            pMin   = LTE.Utils.PointConvertByProj.Instance.GetProjectPoint(pMin);

            LTE.Geometric.Point pMax = new Geometric.Point();
            pMax.X = this.maxLongitude;
            pMax.Y = this.maxLatitude;
            pMax.Z = 0;
            pMax   = LTE.Utils.PointConvertByProj.Instance.GetProjectPoint(pMax);

            int minxid = 0, minyid = 0, maxxid = 0, maxyid = 0;

            GridHelper.getInstance().XYToGGrid(pMin.X, pMin.Y, ref minxid, ref minyid);
            GridHelper.getInstance().XYToGGrid(pMax.X, pMax.Y, ref maxxid, ref maxyid);
            //GridHelper.getInstance().LngLatToGGrid(pMin.X, pMin.Y, ref minxid, ref minyid);
            //GridHelper.getInstance().LngLatToGGrid(pMax.X, pMax.Y, ref maxxid, ref maxyid);

            double    T  = 6; // 门限
            double    T1 = 6;
            Hashtable ht = new Hashtable();

            ht["MinGXID"] = minxid;
            ht["MinGYID"] = minyid;
            ht["MaxGXID"] = maxxid;
            ht["MaxGYID"] = maxyid;

            System.Data.DataTable dtable = new System.Data.DataTable();
            dtable.Columns.Add("GXID");
            dtable.Columns.Add("GYID");
            dtable.Columns.Add("GZID");
            dtable.Columns.Add("type");
            dtable.Columns.Add("CI");
            dtable.Columns.Add("PCI");
            dtable.Columns.Add("ReceivedPowerdbm");
            dtable.Columns.Add("explain");

            double effective = -110;  // 有效信号阈值

            DataTable tb1 = IbatisHelper.ExecuteQueryForDataTable("CoverAnalysis", ht);
            DataTable tb2 = IbatisHelper.ExecuteQueryForDataTable("CoverAnalysis3D", ht);
            int       cnt = tb1.Rows.Count + tb2.Rows.Count;

            //if (cnt < 1)
            //{
            //    return new Result(false, "当前区域未进行覆盖计算");
            //}
            if (cnt < 0.85 * (maxxid - minxid + 1) * (maxyid - minyid + 1))
            {
                return(new Result(false, "当前区域已计算覆盖率过小,请对此区域重新计算小区覆盖"));
            }

            #region 地面初始化
            DataTable tb = tb1;
            int       n  = tb.Rows.Count;
            //if (n < 1)
            //    return new Result(false, "当前区域未进行覆盖计算");

            Dictionary <string, List <Sub> >    dic = new Dictionary <string, List <Sub> >();    // 栅格的其它信息
            Dictionary <string, List <double> > xy  = new Dictionary <string, List <double> >(); // 栅格位置

            int             weak     = 0;                                                        // 弱覆盖
            List <Analysis> exessive = new List <Analysis>();                                    // 过覆盖
            List <Analysis> overlap  = new List <Analysis>();                                    // 重叠覆盖
            int             pcim3    = 0;                                                        // pci mod 3 对打
            int             pcic     = 0;                                                        // pci 冲突
            int             pcih     = 0;                                                        // pci 混淆

            for (int i = 0; i < n; i++)
            {
                int    x    = Convert.ToInt32(tb.Rows[i]["GXID"].ToString());
                int    y    = Convert.ToInt32(tb.Rows[i]["GYID"].ToString());
                double minX = Convert.ToDouble(tb.Rows[i]["minX"].ToString());
                double minY = Convert.ToDouble(tb.Rows[i]["minY"].ToString());
                double maxX = Convert.ToDouble(tb.Rows[i]["maxX"].ToString());
                double maxY = Convert.ToDouble(tb.Rows[i]["maxY"].ToString());
                double p    = Convert.ToDouble(tb.Rows[i]["ReceivedPowerdbm"].ToString());
                int    ci   = Convert.ToInt32(tb.Rows[i]["ci"].ToString());
                int    pci  = Convert.ToInt32(tb.Rows[i]["pci"].ToString());

                string key = string.Format("{0},{1}", x, y);

                if (!xy.Keys.Contains(key))
                {
                    xy[key] = new List <double>();
                    xy[key].Add(minX);
                    xy[key].Add(minY);
                    xy[key].Add(maxX);
                    xy[key].Add(maxY);
                }

                if (dic.Keys.Contains(key))
                {
                    dic[key].Add(new Sub(p, ci, pci));
                }
                else
                {
                    dic[key] = new List <Sub>();
                    dic[key].Add(new Sub(p, ci, pci));
                }
            }

            #endregion

            #region 立体初始化
            int             weak1     = 0;                     // 弱覆盖点数
            int             pcim31    = 0;                     // pci mod3 对打
            int             pcih1     = 0;                     // pci 混淆数
            int             pcic1     = 0;                     // pci 冲突数
            List <Analysis> overlap1  = new List <Analysis>(); // 重叠覆盖
            List <Analysis> exessive1 = new List <Analysis>(); // 过覆盖

            tb = tb2;
            n  = tb.Rows.Count;
            //if (n < 1)
            //    return new Result(false, "当前区域未进行覆盖计算");

            double h = GridHelper.getInstance().getGHeight();

            Dictionary <string, List <Sub> >    dic1 = new Dictionary <string, List <Sub> >();
            Dictionary <string, List <double> > xy1  = new Dictionary <string, List <double> >();


            for (int i = 0; i < n; i++)
            {
                int    x    = Convert.ToInt32(tb.Rows[i]["GXID"].ToString());
                int    y    = Convert.ToInt32(tb.Rows[i]["GYID"].ToString());
                int    z    = Convert.ToInt32(tb.Rows[i]["level"].ToString());
                double minX = Convert.ToDouble(tb.Rows[i]["minX"].ToString());
                double minY = Convert.ToDouble(tb.Rows[i]["minY"].ToString());
                double maxX = Convert.ToDouble(tb.Rows[i]["maxX"].ToString());
                double maxY = Convert.ToDouble(tb.Rows[i]["maxY"].ToString());
                double p    = Convert.ToDouble(tb.Rows[i]["ReceivedPowerdbm"].ToString());
                int    ci   = Convert.ToInt32(tb.Rows[i]["ci"].ToString());
                int    pci  = Convert.ToInt32(tb.Rows[i]["pci"].ToString());

                string key = string.Format("{0},{1},{2}", x, y, z);

                if (!dic1.Keys.Contains(key))
                {
                    xy1[key] = new List <double>();
                    xy1[key].Add(minX);
                    xy1[key].Add(minY);
                    xy1[key].Add(maxX);
                    xy1[key].Add(maxY);
                    xy1[key].Add(z * h);
                }

                if (dic1.Keys.Contains(key))
                {
                    dic1[key].Add(new Sub(p, ci, pci));
                }
                else
                {
                    dic1[key] = new List <Sub>();
                    dic1[key].Add(new Sub(p, ci, pci));
                }
            }
            #endregion

            LoadInfo loadInfo   = new LoadInfo();
            int      count      = dic.Keys.Count + dic1.Keys.Count;
            int      updateSize = (int)Math.Round(count * 0.02);
            loadInfo.loadCountAdd(count);
            int cnt1 = 0;
            #region 地面
            foreach (string key in dic.Keys)
            {
                if (updateSize == ++cnt1)
                {
                    loadInfo.loadHashAdd(updateSize);
                    cnt1 = 0;
                }
                dic[key].Sort(new SubCompare());  // 按功率从大到小排序

                string[] id  = key.Split(',');
                int      xid = Convert.ToInt32(id[0]);
                int      yid = Convert.ToInt32(id[1]);

                // 弱覆盖
                if (dic[key][0].p < -95)// && dic[key][m] > -110)
                {
                    weak++;

                    System.Data.DataRow thisrow = dtable.NewRow();
                    thisrow["GXID"]             = xid;
                    thisrow["GYID"]             = yid;
                    thisrow["GZID"]             = 0;
                    thisrow["type"]             = (short)DefectType.Weak;
                    thisrow["CI"]               = dic[key][0].ci;
                    thisrow["PCI"]              = dic[key][0].pci;
                    thisrow["ReceivedPowerdbm"] = dic[key][0].p;
                    thisrow["explain"]          = "";
                    dtable.Rows.Add(thisrow);
                }

                // 当前栅格只接收到了1个信号,不存在pci模3对打、过覆盖、重叠覆盖、pci冲突、pci混淆
                if (dic[key].Count < 2)
                {
                    continue;
                }

                // 过覆盖
                if (dic[key][0].p > effective && dic[key][1].p > effective && Math.Abs(dic[key][0].p - dic[key][1].p) < T1)
                {
                    Analysis A = new Analysis(xid, yid, xy[key][0], xy[key][1], xy[key][2], xy[key][3]);
                    exessive.Add(A);

                    System.Data.DataRow thisrow = dtable.NewRow();
                    thisrow["GXID"]             = xid;
                    thisrow["GYID"]             = yid;
                    thisrow["GZID"]             = 0;
                    thisrow["type"]             = (short)DefectType.Excessive;
                    thisrow["CI"]               = dic[key][0].ci;
                    thisrow["PCI"]              = dic[key][0].pci;
                    thisrow["ReceivedPowerdbm"] = dic[key][0].p;
                    thisrow["explain"]          = string.Format("{0}:{1};{2}:{3}", dic[key][0].ci, dic[key][0].p, dic[key][1].ci, dic[key][1].p);;
                    dtable.Rows.Add(thisrow);
                }

                // 当前栅格接收到了 2 个信号
                if (dic[key].Count == 2)
                {
                    // pci mod3 对打
                    if (dic[key][0].p > effective && dic[key][1].p > effective && dic[key][0].pci % 3 == dic[key][1].pci % 3)
                    {
                        ++pcim3;

                        System.Data.DataRow thisrow = dtable.NewRow();
                        thisrow["GXID"]             = xid;
                        thisrow["GYID"]             = yid;
                        thisrow["GZID"]             = 0;
                        thisrow["type"]             = (short)DefectType.PCImod3;
                        thisrow["CI"]               = dic[key][0].ci;
                        thisrow["PCI"]              = dic[key][0].pci;
                        thisrow["ReceivedPowerdbm"] = dic[key][0].p;
                        thisrow["explain"]          = string.Format("{0}:{1},{2};{3}:{4},{5}", dic[key][0].ci, dic[key][0].pci,
                                                                    dic[key][0].p, dic[key][1].ci, dic[key][1].pci, dic[key][1].p);
                        dtable.Rows.Add(thisrow);
                    }

                    // pci 冲突
                    if (dic[key][0].p > effective && dic[key][1].p > effective && dic[key][0].pci == dic[key][1].pci)
                    {
                        ++pcic;

                        System.Data.DataRow thisrow = dtable.NewRow();
                        thisrow["GXID"]             = xid;
                        thisrow["GYID"]             = yid;
                        thisrow["GZID"]             = 0;
                        thisrow["type"]             = (short)DefectType.PCIconflict;
                        thisrow["CI"]               = dic[key][0].ci;
                        thisrow["PCI"]              = dic[key][0].pci;
                        thisrow["ReceivedPowerdbm"] = dic[key][0].p;
                        thisrow["explain"]          = string.Format("{0}:{1},{2};{3}:{4},{5}", dic[key][0].ci, dic[key][0].pci,
                                                                    dic[key][0].p, dic[key][1].ci, dic[key][1].pci, dic[key][1].p);
                        dtable.Rows.Add(thisrow);
                    }
                }

                else if (dic[key].Count > 2)  // 当前栅格接收到了>2个信号
                {
                    // 重叠覆盖
                    if (dic[key][0].p > effective && dic[key][1].p > effective && dic[key][2].p > effective &&
                        Math.Abs(dic[key][0].p - dic[key][1].p) < T && Math.Abs(dic[key][0].p - dic[key][2].p) < T &&
                        Math.Abs(dic[key][1].p - dic[key][2].p) < T)
                    {
                        Analysis A = new Analysis(xid, yid, xy[key][0], xy[key][1], xy[key][2], xy[key][3]);
                        overlap.Add(A);

                        System.Data.DataRow thisrow = dtable.NewRow();
                        thisrow["GXID"]             = xid;
                        thisrow["GYID"]             = yid;
                        thisrow["GZID"]             = 0;
                        thisrow["type"]             = (short)DefectType.Overlapped;
                        thisrow["CI"]               = dic[key][0].ci;
                        thisrow["PCI"]              = dic[key][0].pci;
                        thisrow["ReceivedPowerdbm"] = dic[key][0].p;
                        thisrow["explain"]          = string.Format("{0}:{1};{2}:{3};{4}:{5}", dic[key][0].ci, dic[key][0].p, dic[key][1].ci, dic[key][1].p, dic[key][2].ci, dic[key][2].p);
                        dtable.Rows.Add(thisrow);
                    }

                    // pci mod3 对打
                    if (dic[key][0].p > effective && dic[key][1].p > effective && dic[key][2].p > effective &&
                        (dic[key][0].pci % 3 == dic[key][1].pci % 3 || dic[key][0].pci % 3 == dic[key][2].pci % 3))
                    {
                        ++pcim3;

                        System.Data.DataRow thisrow = dtable.NewRow();
                        thisrow["GXID"]             = xid;
                        thisrow["GYID"]             = yid;
                        thisrow["GZID"]             = 0;
                        thisrow["type"]             = (short)DefectType.PCImod3;
                        thisrow["CI"]               = dic[key][0].ci;
                        thisrow["PCI"]              = dic[key][0].pci;
                        thisrow["ReceivedPowerdbm"] = dic[key][0].p;
                        thisrow["explain"]          = string.Format("{0}:{1},{2};{3}:{4},{5};{6}:{7},{8}", dic[key][0].ci,
                                                                    dic[key][0].pci, dic[key][0].p, dic[key][1].ci, dic[key][1].pci, dic[key][1].p,
                                                                    dic[key][2].ci, dic[key][2].pci, dic[key][2].p);
                        dtable.Rows.Add(thisrow);
                    }

                    // pci 冲突
                    if (dic[key][0].p > effective && dic[key][1].p > effective && dic[key][2].p > effective &&
                        (dic[key][0].pci == dic[key][1].pci || dic[key][0].pci == dic[key][2].pci))
                    {
                        ++pcic;

                        System.Data.DataRow thisrow = dtable.NewRow();
                        thisrow["GXID"]             = xid;
                        thisrow["GYID"]             = yid;
                        thisrow["GZID"]             = 0;
                        thisrow["type"]             = (short)DefectType.PCIconflict;
                        thisrow["CI"]               = dic[key][0].ci;
                        thisrow["PCI"]              = dic[key][0].pci;
                        thisrow["ReceivedPowerdbm"] = dic[key][0].p;
                        thisrow["explain"]          = string.Format("{0}:{1},{2};{3}:{4},{5};{6}:{7},{8}", dic[key][0].ci,
                                                                    dic[key][0].pci, dic[key][0].p, dic[key][1].ci, dic[key][1].pci, dic[key][1].p,
                                                                    dic[key][2].ci, dic[key][2].pci, dic[key][2].p);
                        dtable.Rows.Add(thisrow);
                    }

                    // pci 混淆
                    if (dic[key][0].p > effective && dic[key][1].p > effective && dic[key][2].p > effective &&
                        dic[key][1].pci == dic[key][2].pci)
                    {
                        ++pcih;

                        System.Data.DataRow thisrow = dtable.NewRow();
                        thisrow["GXID"]             = xid;
                        thisrow["GYID"]             = yid;
                        thisrow["GZID"]             = 0;
                        thisrow["type"]             = (short)DefectType.PCIconfusion;
                        thisrow["CI"]               = dic[key][0].ci;
                        thisrow["PCI"]              = dic[key][0].pci;
                        thisrow["ReceivedPowerdbm"] = dic[key][0].p;
                        thisrow["explain"]          = string.Format("{0}:{1},{2};{3}:{4},{5};{6}:{7},{8}", dic[key][0].ci,
                                                                    dic[key][0].pci, dic[key][0].p, dic[key][1].ci, dic[key][1].pci, dic[key][1].p,
                                                                    dic[key][2].ci, dic[key][2].pci, dic[key][2].p);
                        dtable.Rows.Add(thisrow);
                    }
                }
            }

            #endregion
            //-----------------------------------------------

            #region  立体

            foreach (string key in dic1.Keys)
            {
                if (updateSize == ++cnt1)
                {
                    loadInfo.loadHashAdd(updateSize);
                    cnt1 = 0;
                }
                dic1[key].Sort(new SubCompare());
                int m = dic1[key].Count - 1;

                string[] id  = key.Split(',');
                int      xid = Convert.ToInt32(id[0]);
                int      yid = Convert.ToInt32(id[1]);
                int      zid = Convert.ToInt32(id[2]);

                if (dic1[key][0].p < -95) // && dic1[key][m] > -110)
                {
                    ++weak1;

                    System.Data.DataRow thisrow = dtable.NewRow();
                    thisrow["GXID"]             = xid;
                    thisrow["GYID"]             = yid;
                    thisrow["GZID"]             = zid;
                    thisrow["type"]             = (short)DefectType.Weak;
                    thisrow["CI"]               = dic1[key][0].ci;
                    thisrow["PCI"]              = dic1[key][0].pci;
                    thisrow["ReceivedPowerdbm"] = dic1[key][0].p;
                    thisrow["explain"]          = "";
                    dtable.Rows.Add(thisrow);
                }

                if (dic1[key][0].p < -110)
                {
                    continue;
                }

                // 当前栅格只接收到一个信号,不存在pci模3对打、过覆盖、重叠覆盖、PCI冲突、PCI混淆
                if (dic1[key].Count < 2)
                {
                    continue;
                }

                // 过覆盖
                if (dic1[key][0].p > effective && dic1[key][1].p > effective && Math.Abs(dic1[key][0].p - dic1[key][1].p) < T1)
                {
                    Analysis A = new Analysis(xid, yid, zid, xy1[key][0], xy1[key][1], xy1[key][2], xy1[key][3], zid * h);
                    exessive1.Add(A);

                    System.Data.DataRow thisrow = dtable.NewRow();
                    thisrow["GXID"]             = xid;
                    thisrow["GYID"]             = yid;
                    thisrow["GZID"]             = zid;
                    thisrow["type"]             = (short)DefectType.Excessive;
                    thisrow["CI"]               = dic1[key][0].ci;
                    thisrow["PCI"]              = dic1[key][0].pci;
                    thisrow["ReceivedPowerdbm"] = dic1[key][0].p;
                    thisrow["explain"]          = string.Format("{0}:{1};{2}:{3}", dic1[key][0].ci, dic1[key][0].p, dic1[key][1].ci, dic1[key][1].p);;
                    dtable.Rows.Add(thisrow);
                }

                // 当前栅格接收到了 2 个信号
                if (dic1[key].Count == 2)
                {
                    // pci mod3 对打
                    if (dic1[key][0].p > effective && dic1[key][1].p > effective && dic1[key][0].pci % 3 == dic1[key][1].pci % 3)
                    {
                        ++pcim31;

                        System.Data.DataRow thisrow = dtable.NewRow();
                        thisrow["GXID"]             = xid;
                        thisrow["GYID"]             = yid;
                        thisrow["GZID"]             = zid;
                        thisrow["type"]             = (short)DefectType.PCImod3;
                        thisrow["CI"]               = dic1[key][0].ci;
                        thisrow["PCI"]              = dic1[key][0].pci;
                        thisrow["ReceivedPowerdbm"] = dic1[key][0].p;
                        thisrow["explain"]          = string.Format("{0}:{1},{2};{3}:{4},{5}", dic1[key][0].ci, dic1[key][0].pci,
                                                                    dic1[key][0].p, dic1[key][1].ci, dic1[key][1].pci, dic1[key][1].p);
                        dtable.Rows.Add(thisrow);
                    }

                    // pci 冲突
                    if (dic1[key][0].p > effective && dic1[key][1].p > effective && dic1[key][0].pci == dic1[key][1].pci)
                    {
                        ++pcic1;

                        System.Data.DataRow thisrow = dtable.NewRow();
                        thisrow["GXID"]             = xid;
                        thisrow["GYID"]             = yid;
                        thisrow["GZID"]             = zid;
                        thisrow["type"]             = (short)DefectType.PCIconflict;
                        thisrow["CI"]               = dic1[key][0].ci;
                        thisrow["PCI"]              = dic1[key][0].pci;
                        thisrow["ReceivedPowerdbm"] = dic1[key][0].p;
                        thisrow["explain"]          = string.Format("{0}:{1},{2};{3}:{4},{5}", dic1[key][0].ci, dic1[key][0].pci,
                                                                    dic1[key][0].p, dic1[key][1].ci, dic1[key][1].pci, dic1[key][1].p);
                        dtable.Rows.Add(thisrow);
                    }
                }

                else if (dic1[key].Count > 2)  // 当前栅格接收到了>2个信号
                {
                    // 重叠覆盖
                    if (dic1[key][0].p > effective && dic1[key][1].p > effective && dic1[key][2].p > effective &&
                        Math.Abs(dic1[key][0].p - dic1[key][1].p) < T && Math.Abs(dic1[key][0].p - dic1[key][2].p) < T &&
                        Math.Abs(dic1[key][1].p - dic1[key][2].p) < T)
                    {
                        Analysis A = new Analysis(xid, yid, zid, xy1[key][0], xy1[key][1], xy1[key][2], xy1[key][3], zid * h);
                        overlap1.Add(A);

                        System.Data.DataRow thisrow = dtable.NewRow();
                        thisrow["GXID"]             = xid;
                        thisrow["GYID"]             = yid;
                        thisrow["GZID"]             = zid;
                        thisrow["type"]             = (short)DefectType.Overlapped;
                        thisrow["CI"]               = dic1[key][0].ci;
                        thisrow["PCI"]              = dic1[key][0].pci;
                        thisrow["ReceivedPowerdbm"] = dic1[key][0].p;
                        thisrow["explain"]          = string.Format("{0}:{1};{2}:{3};{4}:{5}", dic1[key][0].ci, dic1[key][0].p, dic1[key][1].ci, dic1[key][1].p, dic1[key][2].ci, dic1[key][2].p);
                        dtable.Rows.Add(thisrow);
                    }

                    // pci mod3 对打
                    if (dic1[key][0].p > effective && dic1[key][1].p > effective && dic1[key][2].p > effective &&
                        (dic1[key][0].pci % 3 == dic1[key][1].pci % 3 || dic1[key][0].pci % 3 == dic1[key][2].pci % 3))
                    {
                        ++pcim31;

                        System.Data.DataRow thisrow = dtable.NewRow();
                        thisrow["GXID"]             = xid;
                        thisrow["GYID"]             = yid;
                        thisrow["GZID"]             = zid;
                        thisrow["type"]             = (short)DefectType.PCImod3;
                        thisrow["CI"]               = dic1[key][0].ci;
                        thisrow["PCI"]              = dic1[key][0].pci;
                        thisrow["ReceivedPowerdbm"] = dic1[key][0].p;
                        thisrow["explain"]          = string.Format("{0}:{1},{2};{3}:{4},{5};{6}:{7},{8}", dic1[key][0].ci,
                                                                    dic1[key][0].pci, dic1[key][0].p, dic1[key][1].ci, dic1[key][1].pci, dic1[key][1].p,
                                                                    dic1[key][2].ci, dic1[key][2].pci, dic1[key][2].p);
                        dtable.Rows.Add(thisrow);
                    }

                    // pci 冲突
                    if (dic1[key][0].p > effective && dic1[key][1].p > effective && dic1[key][2].p > effective &&
                        (dic1[key][0].pci == dic1[key][1].pci || dic1[key][0].pci == dic1[key][2].pci))
                    {
                        ++pcic1;

                        System.Data.DataRow thisrow = dtable.NewRow();
                        thisrow["GXID"]             = xid;
                        thisrow["GYID"]             = yid;
                        thisrow["GZID"]             = zid;
                        thisrow["type"]             = (short)DefectType.PCIconflict;
                        thisrow["CI"]               = dic1[key][0].ci;
                        thisrow["PCI"]              = dic1[key][0].pci;
                        thisrow["ReceivedPowerdbm"] = dic1[key][0].p;
                        thisrow["explain"]          = string.Format("{0}:{1},{2};{3}:{4},{5};{6}:{7},{8}", dic1[key][0].ci,
                                                                    dic1[key][0].pci, dic1[key][0].p, dic1[key][1].ci, dic1[key][1].pci, dic1[key][1].p,
                                                                    dic1[key][2].ci, dic1[key][2].pci, dic1[key][2].p);
                        dtable.Rows.Add(thisrow);
                    }

                    // pci 混淆
                    if (dic1[key][0].p > effective && dic1[key][1].p > effective && dic1[key][2].p > effective &&
                        dic1[key][1].pci == dic1[key][2].pci)
                    {
                        ++pcih1;

                        System.Data.DataRow thisrow = dtable.NewRow();
                        thisrow["GXID"]             = xid;
                        thisrow["GYID"]             = yid;
                        thisrow["GZID"]             = zid;
                        thisrow["type"]             = (short)DefectType.PCIconfusion;
                        thisrow["CI"]               = dic1[key][0].ci;
                        thisrow["PCI"]              = dic1[key][0].pci;
                        thisrow["ReceivedPowerdbm"] = dic1[key][0].p;
                        thisrow["explain"]          = string.Format("{0}:{1},{2};{3}:{4},{5};{6}:{7},{8}", dic1[key][0].ci,
                                                                    dic1[key][0].pci, dic1[key][0].p, dic1[key][1].ci, dic1[key][1].pci, dic1[key][1].p,
                                                                    dic1[key][2].ci, dic1[key][2].pci, dic1[key][2].p);
                        dtable.Rows.Add(thisrow);
                    }
                }
            }

            using (System.Data.SqlClient.SqlBulkCopy bcp = new System.Data.SqlClient.SqlBulkCopy(DataUtil.ConnectionString))
            {
                bcp.BatchSize            = dtable.Rows.Count;
                bcp.BulkCopyTimeout      = 1000;
                bcp.DestinationTableName = "tbDefect";
                bcp.WriteToServer(dtable);
                bcp.Close();
            }
            dtable.Clear();

            double total  = dic.Count + dic1.Count;
            double totalG = dic.Count;
            double totalB = dic1.Count;

            string mess = string.Format(" 地面---总栅格数:{0}\n 弱覆盖点数:{1}, 占比:{2}\n 过覆盖点数:{3}, 占比:{4}\n 重叠覆盖点数:{5}, 占比:{6}\n PCI模3对打点数:{7}, 占比:{8}\n PCI冲突点数:{9}, 占比:{10}\n PCI混淆点数:{11}, 占比:{12}\n",
                                        dic.Count,
                                        weak, weak / totalG,
                                        exessive.Count, exessive.Count / totalG,
                                        overlap.Count, overlap.Count / totalG,
                                        pcim3, pcim3 / totalG,
                                        pcic, pcic / totalG,
                                        pcih, pcih / totalG);

            string mess3D = string.Format(" 立体---总栅格数:{0}\n 弱覆盖点数:{1}, 占比:{2}\n 过覆盖点数:{3}, 占比:{4}\n 重叠覆盖点数:{5}, 占比:{6}\n PCI模3对打点数:{7}, 占比:{8}\n PCI冲突点数:{9}, 占比:{10}\n PCI混淆点数:{11}, 占比:{12}\n",
                                          dic1.Count,
                                          weak1, weak1 / totalB,
                                          exessive1.Count, exessive1.Count / totalB,
                                          overlap1.Count, overlap1.Count / totalB,
                                          pcim31, pcim31 / totalB,
                                          pcic1, pcic1 / totalB,
                                          pcih1, pcih1 / totalB);

            string messAll = string.Format(" 总计---总栅格数:{0}\n 弱覆盖点数:{1}, 占比:{2}\n 过覆盖点数:{3}, 占比:{4}\n 重叠覆盖点数:{5}, 占比:{6}\n PCI模3对打点数:{7}, 占比:{8}\n PCI冲突点数:{9}, 占比:{10}\n PCI混淆点数:{11}, 占比:{12}\n",
                                           total,
                                           weak + weak1, (weak + weak1) / total,
                                           (exessive.Count + exessive1.Count), (exessive.Count + exessive1.Count) / total,
                                           (overlap.Count + overlap1.Count), (overlap.Count + overlap1.Count) / total,
                                           (pcim3 + pcim31), (pcim3 + pcim31) / total,
                                           (pcic + pcic1), (pcic + pcic1) / total,
                                           (pcih + pcih1), (pcih + pcih1) / total);
            return(new Result(true, mess + mess3D + messAll));

            #endregion
        }