Esempio n. 1
0
        /// <summary>
        /// 更新用于系数校正射线生成及校正的经纬度范围
        /// </summary>
        /// <returns></returns>
        public Result updateCalibrationRange()
        {
            try
            {
                //更新数据库中待生成轨迹所选区域范围,经纬度
                Hashtable paramHt = new Hashtable();
                double    maxLon  = Double.Parse(this.MaxLongitude.ToString());
                double    maxLat  = Double.Parse(this.MaxLatitude.ToString());
                double    minLon  = Double.Parse(this.MinLongitude.ToString());
                double    minLat  = Double.Parse(this.MinLatitude.ToString());
                paramHt["MaxLon"] = maxLon;
                paramHt["MaxLat"] = maxLat;
                paramHt["MinLon"] = minLon;
                paramHt["MinLat"] = minLat;

                Point pMin = new Point(minLon, minLat, 0);
                pMin = PointConvertByProj.Instance.GetProjectPoint(pMin);
                Point pMax = new Point(maxLon, maxLat, 0);
                pMax            = PointConvertByProj.Instance.GetProjectPoint(pMax);
                paramHt["MinX"] = Math.Round(pMin.X, 3);
                paramHt["MinY"] = Math.Round(pMin.Y, 3);
                paramHt["MaxX"] = Math.Round(pMax.X, 3);
                paramHt["MaxY"] = Math.Round(pMax.Y, 3);

                IbatisHelper.ExecuteDelete("DeleteRayAdjRange", null);
                IbatisHelper.ExecuteInsert("insertRayAdjRange", paramHt);

                return(new Result(true, "系数校正区域范围更新成功!"));
            }
            catch (Exception e)
            {
                return(new Result(false, "系数矫正区域范围更新失败!" + e));
            }
        }
        /// <summary>
        /// 用于更新用于定位的两个路测表
        /// </summary>
        /// <returns></returns>
        public Result UpdateDTDataForLoc()
        {
            IbatisHelper.ExecuteDelete("deleteNousetbDTInf", null);   //去除无效路测数据
            IbatisHelper.ExecuteDelete("deleteNousetbDTNoInf", null); //去除无效路测数据

            //获取tbDTData数据,对每一行数据,计算得到需要的内容,然后
            DataTable dtInfo = IbatisHelper.ExecuteQueryForDataTable("SelectTbDTInf", null);

            if (!GetTotalintoTmp(dtInfo))
            {
                return(new Result(false, "更新失败,请查看日志"));
            }
            int count = IbatisHelper.ExecuteUpdate("UpdatetbDTInfByTmp", null); //更新的行数

            IbatisHelper.ExecuteUpdate("UpdatetbDTInfByCell", null);            //根据eNodeID和CI更新btsname,cellname
            Debug.WriteLine("tbDTInf一共更新:" + count + "条数据");

            dtInfo.Clear();
            dtInfo = IbatisHelper.ExecuteQueryForDataTable("SelectTbDTNoInf", null);
            if (!GetTotalintoTmp(dtInfo))
            {
                return(new Result(false, "更新失败,请查看日志"));
            }
            count = IbatisHelper.ExecuteUpdate("UpdatetbDTNoInfByTmp", null); //更新的行数
            IbatisHelper.ExecuteUpdate("UpdatetbDTNoInfByCell", null);        //根据eNodeID和CI更新btsname,cellname
            Debug.WriteLine("tbDTNoInf一共更新:" + count + "条数据");
            return(new Result(true, "更新成功"));
        }
        public void WriteDt(DataRange dataRange)
        {
            RedisMq.subscriber.Subscribe("cover2db_finish", (channel, message) => {
                Hashtable ht     = new Hashtable();
                DataTable dtable = new DataTable();

                //数据模拟阶段,选取top k
                int sRec = 2000 * 2000;
                int k    = sRec / (canGridL * canGridW);

                ht["eNodeB"] = message;
                ht["k"]      = k;

                //删除已有的路测点
                ht["fromName"] = dataRange.infAreaId + "_" + message;
                IbatisHelper.ExecuteDelete("delSelectDt", ht);

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

                dtable.Columns.Add("ID", System.Type.GetType("System.Int32"));
                dtable.Columns.Add("x", System.Type.GetType("System.Decimal"));
                dtable.Columns.Add("y", System.Type.GetType("System.Decimal"));
                //dtable.Columns.Add("Lon", System.Type.GetType("System.Decimal"));
                //dtable.Columns.Add("Lat", System.Type.GetType("System.Decimal"));
                dtable.Columns.Add("RSRP", System.Type.GetType("System.Double"));
                dtable.Columns.Add("InfName", System.Type.GetType("System.String"));
                //dtable.Columns.Add("DtType", System.Type.GetType("System.String"));

                int initOff    = 5000;
                int uid        = (int)UIDHelper.GenUIdByRedis("DT", dt.Rows.Count) + initOff;
                string infName = dataRange.infAreaId + "_" + message;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var row         = dt.Rows[i];
                    int gxid        = (int)row["GXID"];
                    int gyid        = (int)row["GYID"];
                    double rsrp     = (double)row["ReceivedPowerdbm"];
                    Point geo       = GridHelper.getInstance().GridToGeo(gxid, gyid);
                    Point proj      = GridHelper.getInstance().GridToXY(gxid, gyid);
                    DataRow thisrow = dtable.NewRow();
                    thisrow["ID"]   = uid + i;
                    thisrow["x"]    = proj.X;
                    thisrow["y"]    = proj.Y;
                    //thisrow["Lon"] = geo.X;
                    //thisrow["Lat"] = geo.Y;
                    thisrow["RSRP"]    = rsrp;
                    thisrow["InfName"] = infName;
                    //thisrow["DtType"] = "mock";
                    dtable.Rows.Add(thisrow);
                }
                //DataUtil.BCPDataTableImport(dtable, "tbUINTF");
                SelectDT(infName, dtable);
            });
        }
        /// <summary>
        /// 选点程序
        /// </summary>
        /// <returns></returns>
        public Result GetPoints()
        {
            Init();
            AddToVirsource();
            Hashtable ht = new Hashtable();

            ht["BtsName"] = this.virname;
            ht["RSRP"]    = this.RSRPCons;
            DataTable dtinfo = IbatisHelper.ExecuteQueryForDataTable("GetDTSet", ht);//获取大于RSRP的BtsName对应的路测信息

            DataTable firstRet = ComputePointByD(dtinfo, this.pointNum, this.DisCons);

            if (firstRet != null && firstRet.Rows.Count > this.pointNum)//先进行距离筛选,
            {
                Debug.WriteLine(dtinfo.Rows.Count + "进入角度约束阶段》》》" + firstRet.Rows.Count);
                DataTable secRet = ComputePointByA(firstRet, this.pointNum, this.AngleCons);

                if (secRet != null && secRet.Rows.Count == this.pointNum)
                {
                    Debug.WriteLine("进入信息填写阶段》》》");
                    //暂时试试用干扰源计算方位角的结果,如果用干扰源计算方位角不行,则说明不行
                    if (CompleteAzimuth(secRet) && tb.Rows.Count == this.pointNum)
                    {
                        double minD = double.MaxValue, maxD = double.MinValue, avgD = 0, areax = 0, areay = 0;
                        if (TestDis(tb, ref minD, ref maxD, ref avgD, ref areax, ref areay))
                        {
                            Debug.WriteLine("干扰源的距离平均:" + avgD + "  与干扰源的最远距离" + maxD + "  与干扰源的最近距离" + minD + "  包围盒长" + areax + "  包围盒宽" + areay);
                        }
                        Hashtable ht1 = new Hashtable();
                        ht1["fromName"] = this.virname;
                        IbatisHelper.ExecuteDelete("deletetbRayLoc", ht1);
                        WriteDataToBase(100);
                        return(new Result {
                            ok = true, msg = "成功写入数据库", code = "1"
                        });;
                    }
                    else
                    {
                        Debug.WriteLine("写入失败》》》");
                        return(new Result(false, "写入失败"));
                    }
                }
                else
                {
                    Debug.WriteLine("无满足角度约束的足够数量的点》》》");
                    return(new Result(false, "无满足角度约束的足够数量的点》》》"));
                }
            }
            else
            {
                Debug.WriteLine("无满足距离约束的足够数量的点》》》");
                return(new Result(false, "无满足距离约束的足够数量的点》》》"));
            }
        }
Esempio n. 5
0
 // 删除虚拟路测
 public static Result deleteVDT()
 {
     try
     {
         IbatisHelper.ExecuteDelete("DeleteDT", null);
     }
     catch (Exception e)
     {
         return(new Result(false, e.ToString()));
     }
     return(new Result(true));
 }
        public Result overlaygrass()
        {
            DataTable dt1 = DB.IbatisHelper.ExecuteQueryForDataTable("GetFishnetShpState", null);  // Ibatis 数据访问,判断用户是否做了渔网生成

            if (dt1.Rows[0][0].ToString() == "0")
            {
                return(new Result(false, "用户未进行渔网生成"));
            }
            //     else
            //     { return new Result(true, "用户未进行渔网生成"); }

            DataTable dt2 = DB.IbatisHelper.ExecuteQueryForDataTable("GetGrass_overlayState", null); // Ibatis 数据访问,判断用户是否做了水面叠加分析,做了则删除它

            if (dt2.Rows[0][0].ToString() == "1")                                                    //存在水面叠加图层
            {
                try                                                                                  //更新加速场景表,前提条件表
                {
                    IbatisHelper.ExecuteDelete("UpdatetbDependTableDuetoGrass_overlay", null);
                    IbatisHelper.ExecuteDelete("deleteAdjcoefficient", null);
                    IbatisHelper.ExecuteUpdate("UpdatetbAccelerateGridSceneDuetoGrass_overlay", null);
                }
                catch (Exception ex)
                { return(new Result(false, ex.ToString())); }
            }


            try
            {
                GisClient.Result res = GisClient.ServiceApi.getGisLayerService().overlaygrass();
                if (res.Ok)
                {
                    //更新tbDependTabled的Grass_overlay
                    IbatisHelper.ExecuteUpdate("UpdatetbDependTableGrass_overlay", null);
                    return(new Result(true, res.Msg));
                }
                else
                {
                    return(new Result(false, res.Msg));
                }
            }
            catch (Exception e)
            {
                return(new Result(false, "远程调用失败" + e));
            }
            finally
            {
                ServiceApi.CloseConn();
            }
        }
        /// <summary>
        /// 写入数据库
        /// </summary>
        /// <param name="batchSize"></param>
        public void WriteDataToBase(int batchSize)
        {
            Hashtable ht = new Hashtable();

            ht["cellname"] = this.virname;
            IbatisHelper.ExecuteDelete("deletbSelectedPoint", ht);
            using (SqlBulkCopy bcp = new SqlBulkCopy(DataUtil.ConnectionString))
            {
                bcp.BatchSize            = batchSize;
                bcp.BulkCopyTimeout      = 1000;
                bcp.DestinationTableName = "tbSelectedPoints";
                bcp.WriteToServer(tb);
                bcp.Close();
            }
            Debug.WriteLine("入库完成");
        }
Esempio n. 8
0
        private void writeReRayToDb()
        {
            Console.WriteLine("start writing reRay to db...................................");
            // 删除旧的reRay
            Hashtable ht = new Hashtable();

            ht["CI"]     = this.cellInfo.CI;
            ht["eNodeB"] = this.cellInfo.eNodeB;
            IbatisHelper.ExecuteDelete("deleteSpecifiedReRay", ht);

            System.Data.DataTable dtable = new System.Data.DataTable();
            dtable.Columns.Add("ci");
            dtable.Columns.Add("emitX");
            dtable.Columns.Add("emitY");
            dtable.Columns.Add("emitZ");
            dtable.Columns.Add("pwrDbm");
            dtable.Columns.Add("dirX");
            dtable.Columns.Add("dirY");
            dtable.Columns.Add("dirZ");
            dtable.Columns.Add("type");

            for (int i = 0; i < this.MultiTasksReRay.Count; i++)
            {
                System.Data.DataRow thisrow = dtable.NewRow();
                thisrow["ci"]     = this.cellInfo.CI;
                thisrow["emitX"]  = Math.Round(this.MultiTasksReRay[i].emitX, 3);
                thisrow["emitY"]  = Math.Round(this.MultiTasksReRay[i].emitY, 3);
                thisrow["emitZ"]  = Math.Round(this.MultiTasksReRay[i].emitZ, 3);
                thisrow["pwrDbm"] = Math.Round(this.MultiTasksReRay[i].pwrDbm, 3);
                thisrow["dirX"]   = Math.Round(this.MultiTasksReRay[i].dirX, 4);
                thisrow["dirY"]   = Math.Round(this.MultiTasksReRay[i].dirY, 4);
                thisrow["dirZ"]   = Math.Round(this.MultiTasksReRay[i].dirZ, 4);
                thisrow["type"]   = this.MultiTasksReRay[i].type;
                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 = "tbReRay";
                bcp.WriteToServer(dtable);
                bcp.Close();
            }
            dtable.Clear();
            Console.WriteLine("tbReRay 写入结束!");
        }
Esempio n. 9
0
        public Result cluster()
        {
            DataTable dt11 = DB.IbatisHelper.ExecuteQueryForDataTable("GetClustertoDBState", null);  // Ibatis 数据访问,判断用户是否做了场景划分

            if (dt11.Rows[0][0].ToString() == "0")
            {
                return(new Result(false, "用户未进行场景划分"));
            }


            DataTable dt2 = DB.IbatisHelper.ExecuteQueryForDataTable("GetClusterShpState", null); // Ibatis 数据访问,判断用户是否做了结果图层

            if (dt2.Rows[0][0].ToString() == "1")                                                 //做了结果图层
            {
                try                                                                               //更新前提条件表
                {
                    IbatisHelper.ExecuteDelete("UpdatetbDependTableDuetoClusterShp", null);
                    IbatisHelper.ExecuteDelete("deleteAdjcoefficient", null);
                }
                catch (Exception ex)
                { return(new Result(false, ex.ToString())); }
            }

            try
            {
                GisClient.Result res = GisClient.ServiceApi.getGisLayerService().cluster();
                if (res.Ok)
                {
                    //更新tbDependTabled的Grass_overlay
                    IbatisHelper.ExecuteUpdate("UpdatetbDependTableClusterShp", null);
                    return(new Result(true, res.Msg));
                }
                else
                {
                    return(new Result(false, res.Msg));
                }
            }
            catch (Exception e)
            {
                return(new Result(false, "远程调用失败" + e));
            }
            finally
            {
                ServiceApi.CloseConn();
            }
        }
Esempio n. 10
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();
        }
Esempio n. 11
0
        public Result overlaybuilding()
        {
            DataTable dt1 = DB.IbatisHelper.ExecuteQueryForDataTable("GetFishnetShpState", null);  // Ibatis 数据访问,判断用户是否做了渔网生成

            if (dt1.Rows[0][0].ToString() == "0")
            {
                return(new Result(false, "用户未进行渔网生成"));
            }
            //     else
            //     { return new Result(true, "用户未进行渔网生成"); }

            DataTable dt2 = DB.IbatisHelper.ExecuteQueryForDataTable("GetBuilding_overlayState", null); // Ibatis 数据访问,判断用户是否做了建筑物叠加分析,做了则删除它

            if (dt2.Rows[0][0].ToString() == "1")                                                       //存在建筑物叠加图层
            {
                /*
                 * string[] de = new string[2];//聚类图层,建筑物叠加图层
                 *
                 * DataTable dt3 = DB.IbatisHelper.ExecuteQueryForDataTable("GetBuildingOverlayPosition", null);  // Ibatis 数据访问,得到建筑物叠加图层文件位置
                 * de[0] = dt3.Rows[0][0].ToString();
                 *
                 * DataTable dt4 = DB.IbatisHelper.ExecuteQueryForDataTable("GetClusterPosition", null);  // Ibatis 数据访问,得到聚类图层文件位置
                 * de[1] = dt4.Rows[0][0].ToString();
                 *
                 * string filepath;
                 *
                 *  filepath = de[0];//删除建筑物叠加图层
                 *  try
                 *  {
                 *      //    File.Delete(filepath);
                 *      string fileName = System.IO.Path.GetFileName(filepath);
                 *      string[] a = fileName.Split('.');
                 *      string name = a[0];
                 *      string b = "\\" + name + ".shp";
                 *      filepath = filepath.Replace(b, "");
                 *      DirectoryInfo Folder = new DirectoryInfo(filepath);
                 *      foreach (FileInfo file in Folder.GetFiles())
                 *      {
                 *          if (name == file.Name.Substring(0, file.Name.LastIndexOf('.')) || name + ".shp" == file.Name.Substring(0, file.Name.LastIndexOf('.')))
                 *          {
                 *              file.Delete();
                 *          }
                 *      }
                 *  }
                 *  catch (Exception ex)
                 *  {
                 *      return new Result(false, ex.ToString());
                 *  }
                 *
                 *
                 *  filepath = de[1];//删除聚类图层
                 *  try
                 *  {
                 *      //    File.Delete(filepath);
                 *      string fileName = System.IO.Path.GetFileName(filepath);
                 *      string[] a = fileName.Split('.');
                 *      string name = a[0];
                 *      string b = "\\" + name + ".shp";
                 *      filepath = filepath.Replace(b, "");
                 *      DirectoryInfo Folder = new DirectoryInfo(filepath);
                 *      foreach (FileInfo file in Folder.GetFiles())
                 *      {
                 *          if (name == file.Name.Substring(0, file.Name.LastIndexOf('.')) || name + ".shp" == file.Name.Substring(0, file.Name.LastIndexOf('.')))
                 *          {
                 *              file.Delete();
                 *          }
                 *      }
                 *      name = name + "_label";
                 *      foreach (FileInfo file in Folder.GetFiles())
                 *      {
                 *          if (name == file.Name.Substring(0, file.Name.LastIndexOf('.')) || name + ".shp" == file.Name.Substring(0, file.Name.LastIndexOf('.')))
                 *          {
                 *              file.Delete();
                 *          }
                 *      }
                 *  }
                 *  catch (Exception ex)
                 *  {
                 *      return new Result(false, ex.ToString());
                 *  }*/
                try//更新加速场景表,前提条件表
                {
                    IbatisHelper.ExecuteDelete("UpdatetbDependTableDuetoBuilding_overlay", null);
                    IbatisHelper.ExecuteDelete("deleteAdjcoefficient", null);
                    IbatisHelper.ExecuteUpdate("UpdatetbAccelerateGridSceneDuetoBuilding_overlay", null);
                }
                catch (Exception ex)
                { return(new Result(false, ex.ToString())); }
            }



            try
            {
                GisClient.Result res = GisClient.ServiceApi.getGisLayerService().overlaybuilding();
                if (res.Ok)
                {
                    //更新tbDependTabled的Building_overlay
                    IbatisHelper.ExecuteUpdate("UpdatetbDependTableBuilding_overlay", null);
                    return(new Result(true, res.Msg));
                }
                else
                {
                    return(new Result(false, res.Msg));
                }
            }
            catch (Exception e)
            {
                return(new Result(false, "远程调用失败" + e));
            }
            finally
            {
                ServiceApi.CloseConn();
            }
        }
Esempio n. 12
0
        ///// <summary>
        ///// 直射校正系数
        ///// </summary>
        //public double directCoefficient { get; set; }

        ///// <summary>
        ///// 反射校正系数
        ///// </summary>
        //public double reflectCoefficient { get; set; }

        ///// <summary>
        ///// 绕射校正系数
        ///// </summary>
        //public double diffractCoefficient { get; set; }

        ///// <summary>
        ///// 菲涅尔绕射校正系数
        ///// </summary>
        //public double FCoefficient { get; set; }


        #endregion
        /// <summary>
        /// 计算射线
        /// </summary>
        /// <returns></returns>
        public Result RecordRayLoc(bool load = false)
        {
            threadNum = 1;
            Hashtable ht = new Hashtable();

            ht["fromName"] = virsource;
            //读取selectPoint 表信息
            DataTable tb = IbatisHelper.ExecuteQueryForDataTable("GetSelectedPoint", ht);

            if (tb.Rows.Count < 2)
            {
                return(new Result(false, "该干扰源未完成选点操作,请重新选取干扰源"));
            }
            //清除表中tbRayLoc当前cellname对应的selectpoint对应的CI的数据

            IbatisHelper.ExecuteDelete("deletetbRayLoc", ht);
            DateTime t1, t2;

            t1 = DateTime.Now;
            loadInfo.loadCountAdd(tb.Rows.Count);
            for (int i = 0; i < tb.Rows.Count; i++)
            {
                CellInfo cellInfo = new CellInfo();
                cellInfo.SourcePoint   = new Geometric.Point();
                cellInfo.SourcePoint.X = Convert.ToDouble(tb.Rows[i]["x"]);
                cellInfo.SourcePoint.Y = Convert.ToDouble(tb.Rows[i]["y"]);
                //海拔抹平为13
                cellInfo.SourcePoint.Z = 13;
                cellInfo.SourceName    = Convert.ToString(tb.Rows[i]["CI"]);
                cellInfo.CI            = Convert.ToInt32(tb.Rows[i]["CI"]);
                cellInfo.Inclination   = 0;

                cellInfo.EIRP                  = 53;
                cellInfo.Inclination           = 7;
                cellInfo.diffracteCoefficient  = (float)1;
                cellInfo.reflectCoefficient    = (float)1;
                cellInfo.directCoefficient     = (float)0.3;
                cellInfo.diffracteCoefficient2 = (float)1;
                cellInfo.Azimuth               = Convert.ToDouble(tb.Rows[i]["Azimuth"]);
                double fromAngle = cellInfo.Azimuth - this.incrementAngle;
                double toAngle   = cellInfo.Azimuth + this.incrementAngle;
                double dis       = Convert.ToDouble(tb.Rows[i]["Distance"]);
                Result res       = new Result();
                Debug.WriteLine(i + "     " + tb.Rows[i]["CI"] + "      fromAngle " + fromAngle + "   toAngle" + toAngle);
                //if (way == 0)
                //{
                //    res = parallelComputing(cellInfo, fromAngle, toAngle);
                //}
                //else
                //{
                //    res = parallelComputing(cellInfo, fromAngle, toAngle,dis);
                //}
                if (load)
                {
                    res = parallelComputing(cellInfo, fromAngle, toAngle, dis, LoadInfo.UserId.Value, LoadInfo.taskName.Value);
                }
                else
                {
                    res = parallelComputing(cellInfo, fromAngle, toAngle, dis, -1, "default");
                }
                if (res.ok == false)
                {
                    IbatisHelper.ExecuteDelete("deletetbRayLoc", ht);
                    return(res);
                }
                loadInfo.loadHashAdd(1);
            }
            t2 = DateTime.Now;
            Debug.WriteLine("计算时长:" + (t2 - t1));

            return(new Result(true, "完成" + tb.Rows.Count + "个点的反向射线跟踪计算"));
        }
        public Result GetPointsAutoReal()
        {
            Init();
            AddToVirsource();
            Hashtable ht = new Hashtable();

            ht["InfName"] = this.virname;
            ht["RSRP"]    = this.RSRPCons;
            DataTable dtinfo = IbatisHelper.ExecuteQueryForDataTable("GettbUINTF", ht);//获取大于RSRP的BtsName对应的路测信息

            if (dtinfo.Rows.Count < 2 * this.pointNum)
            {
                return(new Result(false, "路测数据不够"));
            }
            Debug.WriteLine("进入距离约束阶段》》》");
            double    curdis   = this.DisCons;
            double    currsrp  = this.RSRPCons;
            DataTable firstRet = ComputePointByD(dtinfo, this.pointNum, curdis);
            int       itera    = 1000;

            while (true)
            {
                if ((firstRet != null && firstRet.Rows.Count >= this.pointNum && firstRet.Rows.Count < 2 * this.pointNum) || itera-- == 0)
                {
                    Debug.WriteLine("DisCons:" + curdis);
                    break;
                }
                else if (firstRet == null || firstRet.Rows.Count < this.pointNum)
                {
                    if (curdis > this.DisCons)
                    {
                        curdis -= 5;
                        firstRet.Clear();
                        firstRet = ComputePointByD(dtinfo, this.pointNum, curdis);
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    if (curdis > 300)//若是距离很大时,依然有很多备选路测点,则提高RSRP阈值
                    {
                        dtinfo.Clear();
                        currsrp   += 1;
                        curdis     = 300;
                        ht["RSRP"] = currsrp;
                        dtinfo     = IbatisHelper.ExecuteQueryForDataTable("GettbUINTF", ht);
                        firstRet.Clear();
                        firstRet = ComputePointByD(dtinfo, this.pointNum, curdis);
                    }
                    else
                    {
                        firstRet.Clear();
                        curdis  += 10;
                        firstRet = ComputePointByD(dtinfo, this.pointNum, curdis);
                    }
                }
            }
            if (firstRet != null && firstRet.Rows.Count >= this.pointNum)
            {
                if (CompleteAzimuth(firstRet))
                {
                    double minD = double.MaxValue, maxD = double.MinValue, avgD = 0, areax = 0, areay = 0;
                    if (TestDis(tb, ref minD, ref maxD, ref avgD, ref areax, ref areay))
                    {
                        Debug.WriteLine("干扰源的距离平均:" + avgD + "  与干扰源的最远距离" + maxD + "  与干扰源的最近距离" + minD + "  包围盒长" + areax + "  包围盒宽" + areay);
                    }
                    Hashtable ht1 = new Hashtable();
                    ht1["fromName"] = this.virname;
                    IbatisHelper.ExecuteDelete("deletetbRayLoc", ht1);
                    WriteDataToBase(100);
                    return(new Result {
                        ok = true, msg = "成功写入数据库", code = "1"
                    });;
                }
                else
                {
                    Debug.WriteLine("选点失败");
                    return(new Result(false, "选点失败"));
                }
            }
            else
            {
                Debug.WriteLine("无满足距离约束的足够数量的点》》》" + firstRet == null ? 0 : firstRet.Rows.Count);
                return(new Result(false, "无满足距离约束的足够数量的点"));
            }
        }
        public Result GetPointsByDis()
        {
            Init();
            AddToVirsource();
            Hashtable ht = new Hashtable();

            ht["BtsName"] = this.virname;
            ht["RSRP"]    = this.RSRPCons;
            DataTable dtinfo = IbatisHelper.ExecuteQueryForDataTable("GetDTSet", ht);//获取大于RSRP的BtsName对应的路测信息

            if (dtinfo.Rows.Count < 2 * this.pointNum)
            {
                return(new Result(false, "路测数据不够"));
            }
            Debug.WriteLine("进入距离约束阶段》》》");
            DataTable firstRet = ComputePointByD(dtinfo, this.pointNum, this.DisCons);
            int       itera    = 50;

            while (true)
            {
                if ((firstRet != null && firstRet.Rows.Count >= this.pointNum && firstRet.Rows.Count <= 2 * this.pointNum) || itera-- == 0 || this.DisCons > 300)
                {
                    Debug.WriteLine("DisCons:" + this.DisCons);
                    break;
                }
                else if (firstRet == null || firstRet.Rows.Count < this.pointNum)
                {
                    firstRet.Clear();
                    this.DisCons -= 10;
                    firstRet      = ComputePointByD(dtinfo, this.pointNum, this.DisCons);
                }
                else
                {
                    firstRet.Clear();
                    this.DisCons += 10;
                    firstRet      = ComputePointByD(dtinfo, this.pointNum, this.DisCons);
                }
            }
            if (firstRet != null && firstRet.Rows.Count >= this.pointNum)
            {
                if (CompleteAzimuth(firstRet))
                {
                    double minD = double.MaxValue, maxD = double.MinValue, avgD = 0, areax = 0, areay = 0;
                    if (TestDis(tb, ref minD, ref maxD, ref avgD, ref areax, ref areay))
                    {
                        Debug.WriteLine("干扰源的距离平均:" + avgD + "  与干扰源的最远距离" + maxD + "  与干扰源的最近距离" + minD + "  包围盒长" + areax + "  包围盒宽" + areay);
                    }
                    Hashtable ht1 = new Hashtable();
                    ht1["fromName"] = this.virname;
                    IbatisHelper.ExecuteDelete("deletetbRayLoc", ht1);
                    WriteDataToBase(100);
                    return(new Result {
                        ok = true, msg = "成功写入数据库", code = "1"
                    });;
                }
                else
                {
                    Debug.WriteLine("写入失败》》》");
                    return(new Result(false, "写入失败"));
                }
            }
            else
            {
                firstRet.Clear();
                this.DisCons -= 10;
                firstRet      = ComputePointByD(dtinfo, this.pointNum, this.DisCons);
                if (firstRet == null || firstRet.Rows.Count < this.pointNum)
                {
                    Debug.WriteLine("无满足距离约束的足够数量的点》》》" + firstRet.Rows.Count);
                    return(new Result(false, "无满足距离约束的足够数量的点》》》"));
                }
                else
                {
                    if (CompleteAzimuth(firstRet) && tb.Rows.Count == this.pointNum)
                    {
                        double minD = double.MaxValue, maxD = double.MinValue, avgD = 0, areax = 0, areay = 0;
                        if (TestDis(tb, ref minD, ref maxD, ref avgD, ref areax, ref areay))
                        {
                            Debug.WriteLine("干扰源的距离平均:" + avgD + "  与干扰源的最远距离" + maxD + "  与干扰源的最近距离" + minD + "  包围盒长" + areax + "  包围盒宽" + areay);
                        }
                        Hashtable ht1 = new Hashtable();
                        ht1["fromName"] = this.virname;
                        IbatisHelper.ExecuteDelete("deletetbRayLoc", ht1);
                        WriteDataToBase(100);
                        return(new Result {
                            ok = true, msg = "成功写入数据库", code = "1"
                        });;
                    }
                    else
                    {
                        Debug.WriteLine("写入失败》》》");
                        return(new Result(false, "写入失败"));
                    }
                }
            }
        }
        /// <summary>
        /// 如果数据库表 tbAdjCoefficient 中有校正系数时,则界面中的校正系数仅仅被传入,而不会在计算场强中用到
        /// </summary>
        /// <returns></returns>
        public Result calc(bool loadInfo = false)
        {
            int    eNodeB = 0, CI = 0;
            string cellType = "";

            Result rt = validateCell(ref eNodeB, ref CI, ref cellType);

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

            CellInfo cellInfo = new CellInfo(this.cellName, eNodeB, CI, this.directCoeff, this.reflectCoeff, this.diffractCoeff, this.diffractCoeff2);

            double fromAngle = cellInfo.Azimuth - this.incrementAngle;
            double toAngle   = cellInfo.Azimuth + this.incrementAngle;

            ////指定最大覆盖半径
            //int maxCoverageRadius = 15000;
            //this.distance = Math.Min(this.distance, maxCoverageRadius);

            // 删除旧的接收功率数据
            Hashtable ht = new Hashtable();

            ht["CI"]     = CI;
            ht["eNodeB"] = eNodeB;
            GridCover gc = GridCover.getInstance();

            gc.deleteBuildingCover(ht);
            gc.deleteGroundCover(ht);

            // 计算方案
            int  threadCnt = 0, batchNum = 0, flag = 0;
            bool ok = howCalc(fromAngle, toAngle, ref threadCnt, ref batchNum, ref flag);

            this.threadNum = 2; threadCnt = 2;

            // 不需要分批计算
            if (ok)
            {
                List <ProcessArgs> paList = new List <ProcessArgs>();
                bool reRay       = false; // 是否需要进行二次投射,即读取前一批覆盖计算中出界的射线,并对其进行射线跟踪
                bool recordReRay = false; // 是否需要记录当前批的出界射线

                if (loadInfo)
                {
                    return(parallelComputing(ref cellInfo, fromAngle, toAngle, eNodeB, CI, ref paList, reRay, recordReRay, false, false, LoadInfo.UserId.Value, LoadInfo.taskName.Value));
                }
                else
                {
                    return(parallelComputing(ref cellInfo, fromAngle, toAngle, eNodeB, CI, ref paList, reRay, recordReRay, false, false, -1, "default"));
                }
                // 小区覆盖计算
            }
            // 需要分批计算
            else
            {
                IbatisHelper.ExecuteDelete("deleteSpecifiedReRay", ht);

                // 建议计算方案:线程数:threadCnt, 批数 batchNum
                if (flag == 2)
                {
                    this.threadNum = threadCnt;
                    //double delta = (toAngle - fromAngle + 360) % 360 / batchNum;

                    double delta = (toAngle - fromAngle) / batchNum;

                    double startAngle = fromAngle;

                    for (int currBatch = 1; currBatch <= batchNum; currBatch++)
                    {
                        //var batchTaskName = taskName + batchNum;

                        fromAngle = (startAngle + (currBatch - 1) * delta + 360) % 360;
                        toAngle   = (fromAngle + delta + 360) % 360;

                        List <ProcessArgs> paList = new List <ProcessArgs>();

                        bool reRay = false; // 是否需要进行二次投射,即读取前一批覆盖计算中出界的射线,并对其进行射线跟踪
                        if (currBatch > 1)  // 当前不是第一批,就需要进行二次投射
                        {
                            reRay = true;
                        }

                        bool recordReRay = false;  // 是否需要记录当前批的出界射线
                        if (currBatch < batchNum)  // 前批不是最后一批,则需记录当前批的出界射线,供下批二次投射
                        {
                            recordReRay = true;
                        }

                        // 小区覆盖计算
                        Result result = parallelComputing(ref cellInfo, fromAngle, toAngle, eNodeB, CI, ref paList, reRay, recordReRay, false, false, LoadInfo.UserId.Value, LoadInfo.taskName.Value);
                        if (!result.ok)
                        {
                            return(result);
                        }

                        // 分批计算的最后一批,需要对相同小区、相同栅格的功率进行合并
                        if (currBatch == batchNum)
                        {
                            mergePwr1(cellInfo.EIRP, "getPwrGround", false, eNodeB, CI);
                            mergePwr1(cellInfo.EIRP, "getPwrBuilding", true, eNodeB, CI);
                        }
                    }
                    return(new Result(true));
                }
                // 建议计算方案:线程数:threadCnt
                else
                {
                    this.threadNum = threadCnt;
                    List <ProcessArgs> paList = new List <ProcessArgs>();
                    bool reRay       = false; // 是否需要进行二次投射,即读取前一批覆盖计算中出界的射线,并对其进行射线跟踪
                    bool recordReRay = false; // 是否需要记录当前批的出界射线

                    return(parallelComputing(ref cellInfo, fromAngle, toAngle, eNodeB, CI, ref paList, reRay, recordReRay, false, false, LoadInfo.UserId.Value, LoadInfo.taskName.Value));
                }
            }
        }
Esempio n. 16
0
        // 虚拟路测场强填写
        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);
        }
Esempio n. 17
0
        public Result AdjCoefficient()
        {
            int cnt = 0;
            //初始化进度信息
            LoadInfo loadInfo = new LoadInfo();

            loadInfo.count = 1;
            loadInfo.loadCreate();

            DataTable dt11 = DB.IbatisHelper.ExecuteQueryForDataTable("GetClusterShpState", null);  // Ibatis 数据访问,判断用户是否做了图层生成

            if (dt11.Rows[0][0].ToString() == "0")
            {
                return(new Result(false, "用户未进行图层生成"));
            }

            DataTable dt23 = DB.IbatisHelper.ExecuteQueryForDataTable("GetAdjcoefficienttoDBState", null); // Ibatis 数据访问,判断用户是否做了矫正系数,做了则删除它

            if (dt23.Rows[0][0].ToString() == "1")                                                         //做了矫正系数
            {
                try                                                                                        //更新矫正系数表,前提条件表
                {
                    IbatisHelper.ExecuteDelete("deleteAdjcoefficient", null);
                    IbatisHelper.ExecuteUpdate("UpdatetbDependTableDuetoAdjcoefficienttoDB", null);
                }
                catch (Exception ex)
                { return(new Result(false, ex.ToString())); }
            }

            string xmlpath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "coefficient.xml";//xml文件位置
            //读xml文件获取参数
            XDocument document = XDocument.Load(xmlpath);
            XElement  root = document.Root;
            XElement  ele = root.Element("parameter");
            double    DirectCoefficient_Scene0, ReflectCoefficientA_Scene0, ReflectCoefficientB_Scene0, ReflectCoefficientC_Scene0, DiffracteCoefficientA_Scene0, DiffracteCoefficientB_Scene0, DiffracteCoefficientC_Scene0;
            double    DirectCoefficient_Scene1, ReflectCoefficientA_Scene1, ReflectCoefficientB_Scene1, ReflectCoefficientC_Scene1, DiffracteCoefficientA_Scene1, DiffracteCoefficientB_Scene1, DiffracteCoefficientC_Scene1;
            double    DirectCoefficient_Scene2, ReflectCoefficientA_Scene2, ReflectCoefficientB_Scene2, ReflectCoefficientC_Scene2, DiffracteCoefficientA_Scene2, DiffracteCoefficientB_Scene2, DiffracteCoefficientC_Scene2;
            double    DirectCoefficient_Scene3, ReflectCoefficientA_Scene3, ReflectCoefficientB_Scene3, ReflectCoefficientC_Scene3, DiffracteCoefficientA_Scene3, DiffracteCoefficientB_Scene3, DiffracteCoefficientC_Scene3;
            //scene0
            XElement para = ele.Element("DirectCoefficient_Scene0");

            DirectCoefficient_Scene0 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("ReflectCoefficientA_Scene0");
            ReflectCoefficientA_Scene0 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("ReflectCoefficientB_Scene0");
            ReflectCoefficientB_Scene0 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("ReflectCoefficientC_Scene0");
            ReflectCoefficientC_Scene0 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("DiffracteCoefficientA_Scene0");
            DiffracteCoefficientA_Scene0 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("DiffracteCoefficientB_Scene0");
            DiffracteCoefficientB_Scene0 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("DiffracteCoefficientC_Scene0");
            DiffracteCoefficientC_Scene0 = Convert.ToDouble(para.Value.ToString());
            //scene1
            para = ele.Element("DirectCoefficient_Scene1");
            DirectCoefficient_Scene1 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("ReflectCoefficientA_Scene1");
            ReflectCoefficientA_Scene1 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("ReflectCoefficientB_Scene1");
            ReflectCoefficientB_Scene1 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("ReflectCoefficientC_Scene1");
            ReflectCoefficientC_Scene1 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("DiffracteCoefficientA_Scene1");
            DiffracteCoefficientA_Scene1 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("DiffracteCoefficientB_Scene1");
            DiffracteCoefficientB_Scene1 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("DiffracteCoefficientC_Scene1");
            DiffracteCoefficientC_Scene1 = Convert.ToDouble(para.Value.ToString());
            //scene2
            para = ele.Element("DirectCoefficient_Scene2");
            DirectCoefficient_Scene2 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("ReflectCoefficientA_Scene2");
            ReflectCoefficientA_Scene2 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("ReflectCoefficientB_Scene2");
            ReflectCoefficientB_Scene2 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("ReflectCoefficientC_Scene2");
            ReflectCoefficientC_Scene2 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("DiffracteCoefficientA_Scene2");
            DiffracteCoefficientA_Scene2 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("DiffracteCoefficientB_Scene2");
            DiffracteCoefficientB_Scene2 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("DiffracteCoefficientC_Scene2");
            DiffracteCoefficientC_Scene2 = Convert.ToDouble(para.Value.ToString());
            //scene3
            para = ele.Element("DirectCoefficient_Scene3");
            DirectCoefficient_Scene3 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("ReflectCoefficientA_Scene3");
            ReflectCoefficientA_Scene3 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("ReflectCoefficientB_Scene3");
            ReflectCoefficientB_Scene3 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("ReflectCoefficientC_Scene3");
            ReflectCoefficientC_Scene3 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("DiffracteCoefficientA_Scene3");
            DiffracteCoefficientA_Scene3 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("DiffracteCoefficientB_Scene3");
            DiffracteCoefficientB_Scene3 = Convert.ToDouble(para.Value.ToString());
            para = ele.Element("DiffracteCoefficientC_Scene3");
            DiffracteCoefficientC_Scene3 = Convert.ToDouble(para.Value.ToString());


            DataTable dt = new DataTable();//入库

            dt.Columns.Add("scene", Type.GetType("System.Byte"));
            dt.Columns.Add("DirectCoefficient", Type.GetType("System.Double"));
            dt.Columns.Add("ReflectCoefficientA", Type.GetType("System.Double"));
            dt.Columns.Add("ReflectCoefficientB", Type.GetType("System.Double"));
            dt.Columns.Add("ReflectCoefficientC", Type.GetType("System.Double"));
            dt.Columns.Add("DiffracteCoefficientA", Type.GetType("System.Double"));
            dt.Columns.Add("DiffracteCoefficientB", Type.GetType("System.Double"));
            dt.Columns.Add("DiffracteCoefficientC", Type.GetType("System.Double"));

            dt.Rows.Add(new object[] { "0", DirectCoefficient_Scene0.ToString(), ReflectCoefficientA_Scene0.ToString(), ReflectCoefficientB_Scene0.ToString(), ReflectCoefficientC_Scene0.ToString(), DiffracteCoefficientA_Scene0.ToString(), DiffracteCoefficientB_Scene0.ToString(), DiffracteCoefficientC_Scene0.ToString() });
            dt.Rows.Add(new object[] { "1", DirectCoefficient_Scene1.ToString(), ReflectCoefficientA_Scene1.ToString(), ReflectCoefficientB_Scene1.ToString(), ReflectCoefficientC_Scene1.ToString(), DiffracteCoefficientA_Scene1.ToString(), DiffracteCoefficientB_Scene1.ToString(), DiffracteCoefficientC_Scene1.ToString() });
            dt.Rows.Add(new object[] { "2", DirectCoefficient_Scene2.ToString(), ReflectCoefficientA_Scene2.ToString(), ReflectCoefficientB_Scene2.ToString(), ReflectCoefficientC_Scene2.ToString(), DiffracteCoefficientA_Scene2.ToString(), DiffracteCoefficientB_Scene2.ToString(), DiffracteCoefficientC_Scene2.ToString() });
            dt.Rows.Add(new object[] { "3", DirectCoefficient_Scene3.ToString(), ReflectCoefficientA_Scene3.ToString(), ReflectCoefficientB_Scene3.ToString(), ReflectCoefficientC_Scene3.ToString(), DiffracteCoefficientA_Scene3.ToString(), DiffracteCoefficientB_Scene3.ToString(), DiffracteCoefficientC_Scene3.ToString() });

            try
            {
                using (SqlBulkCopy bcp = new SqlBulkCopy(DataUtil.ConnectionString))
                {
                    bcp.BatchSize            = dt.Rows.Count;
                    bcp.BulkCopyTimeout      = 1000;
                    bcp.DestinationTableName = "tbAdjtest";
                    bcp.WriteToServer(dt);
                    bcp.Close();
                }
                IbatisHelper.ExecuteDelete("UpdatetbDependTableAdjcoefficienttoDB", null);
                cnt++;
                loadInfo.cnt = cnt;
                loadInfo.loadUpdate();
                return(new Result(true, "成功"));
            }
            catch (Exception e)
            { return(new Result(false, "失败")); }
        }
        public void SelectDT(string InfName, DataTable dt)
        {
            //筛选信号值前k个的点
            //Hashtable ht = new Hashtable();
            //ht["InfName"] = InfName;
            //DataTable dt = IbatisHelper.ExecuteQueryForDataTable("queryDTRange",ht);
            //double minX = Convert.ToDouble(dt.Rows[0]["minX"]);
            //double maxX = Convert.ToDouble(dt.Rows[0]["maxX"]);
            //double minY = Convert.ToDouble(dt.Rows[0]["minY"]);
            //double maxY = Convert.ToDouble(dt.Rows[0]["maxY"]);
            //int sRec = (int)((maxX - minX) * (maxY - minY));

            //ht["k"] = k;
            //dt = IbatisHelper.ExecuteQueryForDataTable("queryTopKDT", ht);

            //定义候选点数据结构
            DataTable canGrid = new DataTable();

            canGrid.Columns.Add("fromName");
            canGrid.Columns.Add("CI");
            canGrid.Columns.Add("x");
            canGrid.Columns.Add("y");
            canGrid.Columns.Add("ReceivePW");
            canGrid.Columns.Add("Azimuth");
            canGrid.Columns.Add("Distance");
            //用于记录路测点已经覆盖过的栅格
            HashSet <string> vis = new HashSet <string>();
            List <Point>     ps  = new List <Point>();

            double grade = 0.001;//选点等级,每隔0.1%减少一定候选栅格

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int sigma = (int)Math.Floor((double)i / dt.Rows.Count / grade) + 1;
                sigma = 1;
                Point  p      = new Point(Convert.ToDouble(dt.Rows[i]["x"]), Convert.ToDouble(dt.Rows[i]["y"]), 0);
                Grid3D grid3d = new Grid3D();
                if (!GridHelper.getInstance().PointXYZGrid(p, ref grid3d, canGridL * sigma, canGridH * sigma))
                {
                    continue;
                }
                string key = grid3d.gxid + "_" + grid3d.gyid;
                if (vis.Contains(key))
                {
                    //该栅格已经存在候选路测点,则跳过
                    continue;
                }

                //选点距离约束,至少间隔50m,防止边界邻点出现
                double thDis = 50;
                bool   near  = false;
                foreach (var gs in ps)
                {
                    double ddis = distanceXY(p.X, p.Y, gs.X, gs.Y);
                    if (ddis < thDis)
                    {
                        near = true;
                        break;
                    }
                }

                if (near)
                {
                    continue;
                }
                vis.Add(key);
                ps.Add(p);
                DataRow thisrow = canGrid.NewRow();
                thisrow["fromName"]  = InfName;
                thisrow["x"]         = dt.Rows[i]["x"];
                thisrow["y"]         = dt.Rows[i]["y"];
                thisrow["ReceivePW"] = Math.Pow(10, (Convert.ToDouble(dt.Rows[i]["RSRP"]) / 10 - 3));
                thisrow["CI"]        = dt.Rows[i]["ID"];
                canGrid.Rows.Add(thisrow);
            }
            //计算路测点起始参数
            ComputeInitParams(canGrid);
            //入库
            Hashtable ht1 = new Hashtable();

            ht1["fromName"] = InfName;
            IbatisHelper.ExecuteDelete("deletetbRayLoc", ht1);
            IbatisHelper.ExecuteDelete("deletbSelectedPoint", ht1);
            WriteDataToBase(canGrid, 100, "tbSelectedPoints");
            Task.Run(() =>
            {
                TarjGen(InfName);
            });
        }
Esempio n. 19
0
 public void deleteBuildingCover(Hashtable ht)
 {
     IbatisHelper.ExecuteDelete("deleteSpecifiedCelltbBuildingGrid3Ds", ht);
 }
Esempio n. 20
0
        public Result makeFishnet()
        {
            DataTable dt1 = DB.IbatisHelper.ExecuteQueryForDataTable("GetGridRangeState", null);  // Ibatis 数据访问,判断用户是否提供了网格范围

            if (dt1.Rows[0][0].ToString() == "0")
            {
                return(new Result(false, "用户未提供区域范围"));
            }
            //    else
            //    { return new Result(true, "用户提供区域范围"); }



            DataTable dt2 = DB.IbatisHelper.ExecuteQueryForDataTable("GetFishnetShpState", null); // Ibatis 数据访问,判断用户是否做了渔网图层,做了则删除它

            if (dt2.Rows[0][0].ToString() == "1")                                                 //存在渔网图层
            {
                /*
                 * string[] de = new string[5];//聚类图层,建筑物叠加图层,水面叠加图层,草地叠加图层,渔网图层及label图层
                 * DataTable dt3 = DB.IbatisHelper.ExecuteQueryForDataTable("GetGrassOverlayPosition", null);  // Ibatis 数据访问,得到草地叠加图层文件位置
                 * de[0] = dt3.Rows[0][0].ToString();
                 *
                 * DataTable dt4 = DB.IbatisHelper.ExecuteQueryForDataTable("GetBuildingOverlayPosition", null);  // Ibatis 数据访问,得到建筑物叠加图层文件位置
                 * de[1] = dt4.Rows[0][0].ToString();
                 *
                 * DataTable dt5 = DB.IbatisHelper.ExecuteQueryForDataTable("GetWaterOverlayPosition", null);  // Ibatis 数据访问,得到水面叠加图层文件位置
                 * de[2] = dt5.Rows[0][0].ToString();
                 *
                 * DataTable dt6 = DB.IbatisHelper.ExecuteQueryForDataTable("GetClusterPosition", null);  // Ibatis 数据访问,得到聚类图层文件位置
                 * de[3] = dt6.Rows[0][0].ToString();
                 *
                 * DataTable dt7 = DB.IbatisHelper.ExecuteQueryForDataTable("GetFishnetPosition", null);  // Ibatis 数据访问,得到渔网图层文件位置
                 * de[4] = dt7.Rows[0][0].ToString();
                 *
                 * string filepath;
                 * for(int i=0;i<3;i++)//删除建筑物叠加图层,水面叠加图层,草地叠加图层
                 * {
                 *  filepath = de[i];
                 *  try
                 *  {
                 *      //    File.Delete(filepath);
                 *      string fileName = System.IO.Path.GetFileName(filepath);
                 *      string[] a = fileName.Split('.');
                 *      string name = a[0];
                 *      string b = "\\" + name + ".shp";
                 *      filepath = filepath.Replace(b, "");
                 *      DirectoryInfo Folder = new DirectoryInfo(filepath);
                 *      foreach (FileInfo file in Folder.GetFiles())
                 *      {
                 *          if (name == file.Name.Substring(0, file.Name.LastIndexOf('.')) || name+".shp"== file.Name.Substring(0, file.Name.LastIndexOf('.')))
                 *          {
                 *              file.Delete();
                 *          }
                 *      }
                 *  }
                 *  catch (Exception ex)
                 *  {
                 *      return new Result(false, ex.ToString());
                 *  }
                 * }
                 * for (int i=3;i<5;i++)
                 * {
                 *  filepath = de[i];//删除聚类图层,渔网图层及label图层
                 *  try
                 *  {
                 *      //    File.Delete(filepath);
                 *      string fileName = System.IO.Path.GetFileName(filepath);
                 *      string[] a = fileName.Split('.');
                 *      string name = a[0];
                 *      string b = "\\" + name + ".shp";
                 *      filepath = filepath.Replace(b, "");
                 *      DirectoryInfo Folder = new DirectoryInfo(filepath);
                 *      foreach (FileInfo file in Folder.GetFiles())
                 *      {
                 *          if (name == file.Name.Substring(0, file.Name.LastIndexOf('.')) || name + ".shp" == file.Name.Substring(0, file.Name.LastIndexOf('.')))
                 *          {
                 *              file.Delete();
                 *          }
                 *      }
                 *      name = name + "_label";
                 *      foreach (FileInfo file in Folder.GetFiles())
                 *      {
                 *          if (name == file.Name.Substring(0, file.Name.LastIndexOf('.')) || name + ".shp" == file.Name.Substring(0, file.Name.LastIndexOf('.')))
                 *          {
                 *              file.Delete();
                 *          }
                 *      }
                 *  }
                 *  catch (Exception ex)
                 *  {
                 *      return new Result(false, ex.ToString());
                 *  }
                 * }*/
                try//删除加速场景表,重置前提条件表
                {
                    IbatisHelper.ExecuteDelete("DeleteFishnet", null);
                    IbatisHelper.ExecuteDelete("deleteAdjcoefficient", null);
                    IbatisHelper.ExecuteUpdate("UpdatetbDependTableDuetoFishnet", null);
                }
                catch (Exception ex)
                { return(new Result(false, ex.ToString())); }
            }

            try
            {
                GisClient.Result res = GisClient.ServiceApi.getGisLayerService().makeFishnet();
                if (res.Ok)
                {
                    //更新tbDependTabled的FishnetShp
                    IbatisHelper.ExecuteUpdate("UpdatetbDependTableFishnetShp", null);
                    return(new Result(true, res.Msg));
                }
                else
                {
                    return(new Result(false, res.Msg));
                }
            }
            catch (Exception e)
            {
                return(new Result(false, "远程调用失败" + e));
            }
            finally
            {
                ServiceApi.CloseConn();
            }
        }
        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));
        }
Esempio n. 22
0
        static bool first = true;  // 第一次压缩干扰源区域

        // 基于启发式规则压缩干扰区域
        public Result rules()
        {
            System.Text.StringBuilder msg = new System.Text.StringBuilder();
            if (first) // 第一次压缩干扰源区域
            {
                initRange();
                msg.Append(string.Format("初始干扰区域范围:{0}m * {1}m\n", Math.Round(rightBound - leftBound, 0), Math.Round(upBound - downBound, 0)));
            }

            Hashtable ht = new Hashtable();

            ht["RoadID1"] = 0;
            ht["RoadID2"] = 6;

            if (!readData("getDT", ht))
            {
                return(new Result(false, "路测数据为空"));
            }
            // 读取路测
            strongWeakPt();     // 强弱相间点、强点用到
            strongWeakPt2();    // 射线跟踪用到

            DateTime t0 = DateTime.Now;

            #region 强点
            strongLoc();
            #endregion

            DateTime t1 = DateTime.Now;

            #region 单调性
            if (!first)  // 只利用新区域内的路测
            {
                ht["RoadID1"] = 7;
                ht["RoadID2"] = 10;
                if (!readData("getDT", ht))
                {
                    return(new Result(false, "路测数据为空"));
                }
            }
            monotoneLoc();
            #endregion

            DateTime t2 = DateTime.Now;

            #region 强弱
            if (!first)  // 只利用新区域内的路测
            {
                strongWeakPt();
            }

            strongWeakLoc();
            #endregion

            DateTime t3 = DateTime.Now;

            first = false;   // 准备第二次压缩

            #region 压缩后的区域
            double left = double.MaxValue, down = double.MaxValue, right = 0, up = 0;
            newBound(ref StrongResult, ref left, ref down, ref right, ref up);
            newBound(ref MonotoneResult, ref left, ref down, ref right, ref up);
            newBound(ref StrongWeakResult, ref left, ref down, ref right, ref up);

            if (left > leftBound)
            {
                leftBound = left;
            }
            if (right < rightBound)
            {
                rightBound = right;
            }
            if (down > downBound)
            {
                downBound = down;
            }
            if (up < upBound)
            {
                upBound = up;
            }

            msg.Append(string.Format("新的干扰区域范围:{0}m * {1}m\n", Math.Round(rightBound - leftBound, 0),
                                     Math.Round(upBound - downBound, 0)));
            msg.Append(string.Format("\n路测单调性定位所用时间:{0} s\n", (t1 - t0).TotalMilliseconds / 1000));
            msg.Append("路测单调性干扰源定位结果:\n");
            addResult(ref msg, ref MonotoneResult);

            msg.Append(string.Format("\n\n路测相邻强弱信号点对定位所用时间:{0} s\n", (t2 - t1).TotalMilliseconds / 1000));
            msg.Append("路测相邻强弱信号点对定位结果:\n");
            addResult(ref msg, ref StrongWeakResult);

            msg.Append(string.Format("\n\n路测强信号点定位所用时间:{0} s\n", (t3 - t2).TotalMilliseconds / 1000));
            msg.Append("路测强信号点定位结果:\n");
            addResult(ref msg, ref StrongResult);

            MonotoneResult.Clear();
            StrongWeakResult.Clear();
            StrongResult.Clear();

            IbatisHelper.ExecuteDelete("DeleteInfArea", null);

            // 写入数据库
            System.Data.DataTable dtable = new System.Data.DataTable();
            dtable.Columns.Add("leftBound");
            dtable.Columns.Add("downBound");
            dtable.Columns.Add("rightBound");
            dtable.Columns.Add("upBound");
            System.Data.DataRow thisrow = dtable.NewRow();
            thisrow["leftBound"]  = Math.Round(leftBound, 3);
            thisrow["downBound"]  = Math.Round(downBound, 3);
            thisrow["rightBound"] = Math.Round(rightBound, 3);
            thisrow["upBound"]    = Math.Round(upBound, 3);
            dtable.Rows.Add(thisrow);
            using (SqlBulkCopy bcp = new SqlBulkCopy(DataUtil.ConnectionString))
            {
                bcp.BatchSize            = dtable.Rows.Count;
                bcp.BulkCopyTimeout      = 1000;
                bcp.DestinationTableName = "tbInfArea";
                bcp.WriteToServer(dtable);
                bcp.Close();
            }
            dtable.Clear();
            #endregion
            return(new Result(true, msg.ToString()));
        }
Esempio n. 23
0
        public Result part()
        {
            int cnt = 0;
            //初始化进度信息
            LoadInfo loadInfo = new LoadInfo();

            loadInfo.count = 3;
            loadInfo.loadCreate();

            DataTable dt11 = DB.IbatisHelper.ExecuteQueryForDataTable("GetBuilding_overlayState", null);  // Ibatis 数据访问,判断用户是否做了叠加分析

            if (dt11.Rows[0][0].ToString() == "0")
            {
                return(new Result(false, "用户未进行建筑物叠加分析"));
            }
            DataTable dt12 = DB.IbatisHelper.ExecuteQueryForDataTable("GetWater_overlayState", null);  // Ibatis 数据访问,判断用户是否做了叠加分析

            if (dt12.Rows[0][0].ToString() == "0")
            {
                return(new Result(false, "用户未进行水面叠加分析"));
            }
            DataTable dt13 = DB.IbatisHelper.ExecuteQueryForDataTable("GetGrass_overlayState", null);  // Ibatis 数据访问,判断用户是否做了叠加分析

            if (dt13.Rows[0][0].ToString() == "0")
            {
                return(new Result(false, "用户未进行草地叠加分析"));
            }

            DataTable dt23 = DB.IbatisHelper.ExecuteQueryForDataTable("GetClustertoDBState", null); // Ibatis 数据访问,判断用户是否做了聚类分析,做了则删除它

            if (dt23.Rows[0][0].ToString() == "1")                                                  //做了聚类分析
            {
                try                                                                                 //更新加速场景表,前提条件表
                {
                    IbatisHelper.ExecuteDelete("UpdatetbDependTableDuetoClustertoDB", null);
                    IbatisHelper.ExecuteDelete("deleteAdjcoefficient", null);
                    IbatisHelper.ExecuteUpdate("UpdatetbAccelerateGridSceneDuetoClustertoDB", null);
                }
                catch (Exception ex)
                { return(new Result(false, ex.ToString())); }
            }

            try
            {
                string xmlpath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "cluster.xml";//xml文件位置
                //读xml文件获取参数
                XDocument document = XDocument.Load(xmlpath);
                XElement  root     = document.Root;
                XElement  ele      = root.Element("parameter");
                XElement  para     = ele.Element("range");
                int       range    = Convert.ToInt32(para.Value.ToString());               //每次栅格扩展的个数,为了避免扩张时出现空隙,range为奇数
                para = ele.Element("threshold");
                double threshold = Convert.ToDouble(para.Value.ToString());                //簇的密度阈值
                para = ele.Element("area");
                int area = Convert.ToInt32(para.Value.ToString());                         //簇最小的栅格数量
                para = ele.Element("building_threshold");
                double building_threshold = Convert.ToDouble(para.Value.ToString());       //建筑物栅格密度阈值
                para = ele.Element("buildingseed_threshold");
                double buildingseed_threshold = Convert.ToDouble(para.Value.ToString());   //建筑物扩展种子栅格密度阈值
                para = ele.Element("buildingheight_threshold");
                double buildingheight_threshold = Convert.ToDouble(para.Value.ToString()); //建筑物栅格向外扩展高度阈值
                para = ele.Element("water_threshold");
                double water_threshold = Convert.ToDouble(para.Value.ToString());          //水面栅格密度阈值
                para = ele.Element("waterseed_threshold");
                double waterseed_threshold = Convert.ToDouble(para.Value.ToString());      //水面扩展种子栅格密度阈值
                para = ele.Element("grass_threshold");
                double grass_threshold = Convert.ToDouble(para.Value.ToString());          //草地栅格密度阈值
                para = ele.Element("grassseed_threshold");
                double grassseed_threshold = Convert.ToDouble(para.Value.ToString());      //草地扩展种子栅格密度阈值

                DataTable dt1;
                try
                {
                    dt1 = DB.IbatisHelper.ExecuteQueryForDataTable("GetFishnetRange", null);  // Ibatis 数据访问,得到目标区域范围
                }
                catch (Exception ex11)
                {
                    return(new Result(false, "11111" + ex11.ToString()));
                }

                string minx_text     = dt1.Rows[0][0].ToString(),
                       miny_text     = dt1.Rows[0][1].ToString(),
                       maxx_text     = dt1.Rows[0][2].ToString(),
                       maxy_text     = dt1.Rows[0][3].ToString(),
                       gridsize_text = dt1.Rows[0][4].ToString();
                double minx          = double.Parse(minx_text);//最大最小大地坐标
                double miny          = double.Parse(miny_text);
                double maxx          = double.Parse(maxx_text);
                double maxy          = double.Parse(maxy_text);
                double cellsize      = double.Parse(gridsize_text);//栅格边长


                int ilength = (int)((maxy - miny) / cellsize), jlength = (int)((maxx - minx) / cellsize);
                int xmax = ilength - 1, ymax = jlength - 1;  //xmax是i的上界,ymax是j的上界

                short[,] a   = new short[ilength, jlength];  //目标区域矩阵
                short[,] b   = new short[ilength, jlength];  //结果数据
                short[,] tmp = new short[ilength, jlength];  //临时存放矩阵
                int[,] c     = new int[ilength, jlength];    //序号矩阵
                int[,] bseed = new int[900000, 2];           //建筑物种子
                int[,] wseed = new int[900000, 2];           //水面种子
                int[,] gseed = new int[900000, 2];           //草地种子
                int           k           = range / 2;       //栅格范围
                int[]         sernum      = new int[100000]; //序号的有效性,0可用,1不可用,从1开始
                HashSet <int> meetcluster = new HashSet <int>();
                int[]         x           = new int[4] {
                    0, 0, 1, -1
                };                                   //x的增量,用于小面积去除
                int[] y = new int[4] {
                    1, -1, 0, 0
                };                                   //y的增量,用于小面积去除

                int    i, j, num, seednum = 0, seednum1 = 0, seednum2 = 0;
                double ratio;
                for (i = 0; i <= xmax; i++)
                {
                    for (j = 0; j <= ymax; j++)
                    {
                        a[i, j] = 0; b[i, j] = 0; tmp[i, j] = 0; c[i, j] = 0;
                    }
                }
                for (i = 0; i < 100000; i++)
                {
                    sernum[i] = 0;
                }

                int       pre, next;                                                                //a[pre,next]
                DataTable dt2 = DB.IbatisHelper.ExecuteQueryForDataTable("GetBuildingRatio", null); // Ibatis 数据访问,找出建筑物栅格放入数组a
                for (i = 0; i < dt2.Rows.Count; i++)
                {
                    pre   = Convert.ToInt32(dt2.Rows[i][1].ToString());
                    next  = Convert.ToInt32(dt2.Rows[i][0].ToString());
                    ratio = Convert.ToDouble(dt2.Rows[i][2].ToString());
                    if (ratio > building_threshold)//建筑物栅格密度阈值
                    {
                        a[pre, next] = 1;
                    }
                    if (seednum == 0 && ratio > buildingseed_threshold)//建筑扩展种子栅格密度阈值
                    {
                        bseed[seednum, 0] = pre; bseed[seednum, 1] = next; seednum++;
                    }
                    if (ratio > buildingseed_threshold && seednum < 900000 && seednum != 0)//控制数量
                    {
                        if (!(pre >= bseed[seednum - 1, 0] - 5 && pre <= bseed[seednum - 1, 0] + 5 &&
                              next >= bseed[seednum - 1, 1] - 5 && next <= bseed[seednum - 1, 1] + 5))
                        {
                            bseed[seednum, 0] = pre; bseed[seednum, 1] = next; seednum++;
                        }
                    }
                }

                Hashtable ht = new Hashtable();//建筑物扩展
                ht["height"]  = buildingheight_threshold;
                ht["minGXID"] = minx;
                ht["maxGXID"] = maxx;
                ht["minGYID"] = miny;
                ht["maxGYID"] = maxy;
                DataTable dt3 = DB.IbatisHelper.ExecuteQueryForDataTable("GetBuildingHeight", ht);  // Ibatis 数据访问

                string           s;
                int              error = 0;
                HashSet <string> h     = new HashSet <string>();
                Queue <string>   q     = new Queue <string>();
                for (i = 0; i < dt3.Rows.Count; i++)
                {
                    next = Convert.ToInt32((Convert.ToDouble(dt3.Rows[i][1].ToString()) - minx) / cellsize);
                    pre  = Convert.ToInt32((Convert.ToDouble(dt3.Rows[i][2].ToString()) - miny) / cellsize);
                    s    = pre.ToString() + "," + next.ToString();
                    q.Enqueue(s);
                    int sem = 1;
                    while (q.Count != 0)
                    {
                        s = q.Dequeue(); sem--;
                        string[] sArray = Regex.Split(s, ",", RegexOptions.IgnoreCase);
                        pre  = Convert.ToInt32(sArray[0].ToString());
                        next = Convert.ToInt32(sArray[1].ToString());
                        if (!h.Contains(s) && isedge1(pre, next, xmax, ymax, a) && a[pre, next] == 1)
                        {
                            h.Add(s);
                        }
                        if (a[pre, next] == 1)//上下8个点,x上界是j的上界ymax
                        {
                            s = (pre - 1).ToString() + "," + (next + 1).ToString();
                            if (pre - 1 >= 0 && next + 1 <= ymax && a[pre - 1, next + 1] == 1 && isedge1(pre - 1, next + 1, xmax, ymax, a) && !h.Contains(s))//不越界+是建筑物+是边界点+不在hashset中
                            {
                                q.Enqueue(s); sem++;
                            }
                            s = (pre).ToString() + "," + (next + 1).ToString();
                            if (next + 1 <= ymax && a[pre, next + 1] == 1 && isedge1(pre, next + 1, xmax, ymax, a) && !h.Contains(s))
                            {
                                q.Enqueue(s); sem++;
                            }
                            s = (pre + 1).ToString() + "," + (next + 1).ToString();
                            if (pre + 1 <= xmax && next + 1 <= ymax && a[pre + 1, next + 1] == 1 && isedge1(pre + 1, next + 1, xmax, ymax, a) && !h.Contains(s))
                            {
                                q.Enqueue(s); sem++;
                            }
                            s = (pre + 1).ToString() + "," + (next).ToString();
                            if (pre + 1 <= xmax && a[pre + 1, next] == 1 && isedge1(pre + 1, next, xmax, ymax, a) && !h.Contains(s))
                            {
                                q.Enqueue(s); sem++;
                            }
                            s = (pre + 1).ToString() + "," + (next - 1).ToString();
                            if (pre + 1 <= xmax && next - 1 >= 0 && a[pre + 1, next - 1] == 1 && isedge1(pre + 1, next - 1, xmax, ymax, a) && !h.Contains(s))
                            {
                                q.Enqueue(s); sem++;
                            }
                            s = (pre).ToString() + "," + (next - 1).ToString();
                            if (next - 1 >= 0 && a[pre, next - 1] == 1 && isedge1(pre, next - 1, xmax, ymax, a) && !h.Contains(s))
                            {
                                q.Enqueue(s); sem++;
                            }
                            s = (pre - 1).ToString() + "," + (next - 1).ToString();
                            if (pre - 1 >= 0 && next - 1 >= 0 && a[pre - 1, next - 1] == 1 && isedge1(pre - 1, next - 1, xmax, ymax, a) && !h.Contains(s))
                            {
                                q.Enqueue(s); sem++;
                            }
                            s = (pre - 1).ToString() + "," + (next).ToString();
                            if (pre - 1 >= 0 && a[pre - 1, next] == 1 && isedge1(pre - 1, next, xmax, ymax, a) && !h.Contains(s))
                            {
                                q.Enqueue(s); sem++;
                            }
                        }
                        else
                        {
                            error++;
                        }
                        if (q.Count > 100)
                        {
                            q.Clear(); break;
                        }
                    }
                    foreach (var n in h)
                    {
                        string[] sArray = Regex.Split(n, ",", RegexOptions.IgnoreCase);
                        pre  = Convert.ToInt32(sArray[0].ToString());
                        next = Convert.ToInt32(sArray[1].ToString());
                        for (int i1 = Math.Max(0, pre - 1); i1 <= Math.Min(xmax, pre + 1); i1++)
                        {
                            for (int j1 = Math.Max(0, next - 1); j1 <= Math.Min(ymax, next + 1); j1++)
                            {
                                a[i1, j1] = 1;
                            }
                        }
                    }
                    h.Clear();
                }

                DataTable dt4 = DB.IbatisHelper.ExecuteQueryForDataTable("GetWaterRatio", null);  // Ibatis 数据访问,找出水面栅格放入数组a
                for (i = 0; i < dt4.Rows.Count; i++)
                {
                    pre   = Convert.ToInt32(dt4.Rows[i][1].ToString());
                    next  = Convert.ToInt32(dt4.Rows[i][0].ToString());
                    ratio = Convert.ToDouble(dt4.Rows[i][2].ToString());
                    if (ratio > water_threshold)//水面栅格密度阈值
                    {
                        a[pre, next] = 2;
                    }
                    if (ratio > waterseed_threshold && seednum1 < 900000)//水面扩展种子栅格密度阈值,且
                    {
                        wseed[seednum1, 0] = pre; wseed[seednum1, 1] = next; seednum1++;
                    }
                }

                DataTable dt5 = DB.IbatisHelper.ExecuteQueryForDataTable("GetGrassRatio", null);  // Ibatis 数据访问,找出草地栅格放入数组a
                for (i = 0; i < dt5.Rows.Count; i++)
                {
                    pre   = Convert.ToInt32(dt5.Rows[i][1].ToString());
                    next  = Convert.ToInt32(dt5.Rows[i][0].ToString());
                    ratio = Convert.ToDouble(dt5.Rows[i][2].ToString());
                    if (ratio > grass_threshold)//草地栅格密度阈值
                    {
                        a[pre, next] = 3;
                    }
                    if (ratio > grassseed_threshold && seednum2 < 900000)//草地扩展种子栅格密度阈值
                    {
                        gseed[seednum2, 0] = pre; gseed[seednum2, 1] = next; seednum2++;
                    }
                }

                cnt++;
                loadInfo.cnt = cnt;
                loadInfo.loadUpdate();

                //3种地物的聚类
                for (i = 0; i < seednum; i++)
                {
                    meetcluster.Clear();
                    vic(bseed[i, 0], bseed[i, 1], xmax, ymax, ref a, ref b, ref tmp, ref sernum, ref meetcluster, k, area, ref c, ilength, jlength, threshold);
                }

                for (i = 0; i < seednum1; i++)
                {
                    meetcluster.Clear();
                    vic(wseed[i, 0], wseed[i, 1], xmax, ymax, ref a, ref b, ref tmp, ref sernum, ref meetcluster, k, area, ref c, ilength, jlength, threshold);
                }
                for (i = 0; i < seednum2; i++)
                {
                    meetcluster.Clear();
                    vic(gseed[i, 0], gseed[i, 1], xmax, ymax, ref a, ref b, ref tmp, ref sernum, ref meetcluster, k, area, ref c, ilength, jlength, threshold);
                }

                cnt++;
                loadInfo.cnt = cnt;
                loadInfo.loadUpdate();

                int jjj = 0;          //已经标记序号的格子数
                meetcluster.Clear();  //已经分配的簇号
                int jj1 = 0, jj2 = 0; //jj1:聚类为空地的格子数,jj2:最大簇号
                for (i = 0; i <= xmax; i++)
                {
                    for (j = 0; j <= ymax; j++)
                    {
                        if (c[i, j] != 0)
                        {
                            jjj++;
                        }
                        if (tmp[i, j] != 0)
                        {
                            jj1++;
                        }
                        if (c[i, j] > jj2)
                        {
                            jj2 = c[i, j];
                        }
                        if (c[i, j] != 0 && !meetcluster.Contains(c[i, j]))
                        {
                            meetcluster.Add(c[i, j]);
                        }
                    }
                }
                int nextclunum = jj2 + 1;

                short[,] vis  = new short[ilength, jlength]; //标记是否访问过
                short[,] vis1 = new short[ilength, jlength];
                int   gnum = 0;                              //空地个数
                short firstmeetscene = 0;
                int   firstmeetid = 0, firstmeetsem = 0;
                for (i = 0; i <= xmax; i++)
                {
                    for (j = 0; j <= ymax; j++)
                    {
                        vis[i, j] = 0; vis1[i, j] = 0;
                    }
                }
                for (i = 0; i <= xmax; i++)
                {
                    for (j = 0; j <= ymax; j++)
                    {
                        if (c[i, j] == 0 && tmp[i, j] == 0)
                        {
                            firstmeetsem = 0;
                            s            = ""; gnum = 1;
                            int            count = 0;
                            int            i1, j1;
                            Queue <string> q1 = new Queue <string>();
                            s = i.ToString() + "," + j.ToString();
                            q1.Enqueue(s); count++;
                            vis1[i, j] = 1;
                            while (q1.Count != 0)
                            {
                                s = q1.Dequeue(); count--;
                                string[] sArray = Regex.Split(s, ",", RegexOptions.IgnoreCase);
                                i1 = Convert.ToInt32(sArray[0].ToString());
                                j1 = Convert.ToInt32(sArray[1].ToString());
                                //    c[i1, j1] = nextclunum;
                                int newx, newy;
                                for (int i11 = 0; i11 < 4; i11++) //该位置的相邻的4个元素
                                {
                                    newx = i1 + x[i11];
                                    newy = j1 + y[i11];
                                    if (newx < 0 || newx > xmax || newy < 0 || newy > ymax)
                                    {
                                        continue;                                                         //越界的坐标,直接跳过
                                    }
                                    if (firstmeetsem == 0 && vis1[newx, newy] == 0 && c[newx, newy] != 0) //碰到的第一个簇
                                    {
                                        firstmeetscene = tmp[newx, newy];
                                        firstmeetid    = c[newx, newy];
                                        firstmeetsem   = 1;
                                    }
                                    if (vis1[newx, newy] == 0 && c[newx, newy] == 0) //没有被访问且该元素值为1
                                    {
                                        s = newx.ToString() + "," + newy.ToString();
                                        q1.Enqueue(s); count++;
                                        vis1[newx, newy] = 1; gnum++;
                                    }
                                }
                                if (gnum >= area)
                                {
                                    break;
                                }
                            }
                            if (gnum >= area)
                            {
                                s = "";
                                int            gcount = 0;
                                int            gi1, gj1;
                                Queue <string> gq1 = new Queue <string>();
                                s = i.ToString() + "," + j.ToString();
                                gq1.Enqueue(s); gcount++;
                                vis[i, j] = 1;
                                while (gq1.Count != 0)
                                {
                                    s = gq1.Dequeue(); gcount--;
                                    string[] sArray = Regex.Split(s, ",", RegexOptions.IgnoreCase);
                                    gi1         = Convert.ToInt32(sArray[0].ToString());
                                    gj1         = Convert.ToInt32(sArray[1].ToString());
                                    c[gi1, gj1] = nextclunum;
                                    int newx, newy;
                                    for (int i11 = 0; i11 < 4; i11++) //该位置的相邻的4个元素
                                    {
                                        newx = gi1 + x[i11];
                                        newy = gj1 + y[i11];
                                        if (newx < 0 || newx > xmax || newy < 0 || newy > ymax)
                                        {
                                            continue;                                   //越界的坐标,直接跳过
                                        }
                                        if (vis[newx, newy] == 0 && c[newx, newy] == 0) //没有被访问且该元素值为1
                                        {
                                            s = newx.ToString() + "," + newy.ToString();
                                            gq1.Enqueue(s); gcount++;
                                            vis[newx, newy] = 1;
                                        }
                                    }
                                }
                                nextclunum++;
                            }
                            else
                            {
                                s = "";
                                int            pcount = 0;
                                int            pi1, pj1;
                                Queue <string> pq1 = new Queue <string>();
                                s = i.ToString() + "," + j.ToString();
                                pq1.Enqueue(s); pcount++;
                                vis[i, j] = 1;
                                while (pq1.Count != 0)
                                {
                                    s = pq1.Dequeue(); pcount--;
                                    string[] sArray = Regex.Split(s, ",", RegexOptions.IgnoreCase);
                                    pi1           = Convert.ToInt32(sArray[0].ToString());
                                    pj1           = Convert.ToInt32(sArray[1].ToString());
                                    c[pi1, pj1]   = firstmeetid;
                                    tmp[pi1, pj1] = firstmeetscene;
                                    int newx, newy;
                                    for (int i11 = 0; i11 < 4; i11++) //该位置的相邻的4个元素
                                    {
                                        newx = pi1 + x[i11];
                                        newy = pj1 + y[i11];
                                        if (newx < 0 || newx > xmax || newy < 0 || newy > ymax)
                                        {
                                            continue;                                   //越界的坐标,直接跳过
                                        }
                                        if (vis[newx, newy] == 0 && c[newx, newy] == 0) //没有被访问且该元素值为1
                                        {
                                            s = newx.ToString() + "," + newy.ToString();
                                            pq1.Enqueue(s); pcount++;
                                            vis[newx, newy] = 1;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                //制作字典
                int rownumber = xmax + 1, columnnumber = ymax + 1;
                Dictionary <int, int> myDictionary = new Dictionary <int, int>();
                for (i = 0; i < rownumber; i++)
                {
                    for (j = 0; j < columnnumber; j++)
                    {
                        int gridID = i * columnnumber + j;
                        myDictionary.Add(gridID, tmp[i, j]);
                    }
                }

                try//批量更新
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add("x", Type.GetType("System.Int32"));
                    dt.Columns.Add("y", Type.GetType("System.Int32"));
                    dt.Columns.Add("scene", Type.GetType("System.Byte"));
                    dt.Columns.Add("clusterid", Type.GetType("System.Int32"));
                    foreach (var item in myDictionary.Keys)
                    {
                        dt.Rows.Add(new object[] { (item % (ymax + 1)).ToString(), (item / (ymax + 1)).ToString(), myDictionary[item].ToString(), c[item / columnnumber, item % columnnumber].ToString() });
                        if (dt.Rows.Count > 100000)
                        {
                            using (SqlBulkCopy bcp = new SqlBulkCopy(DataUtil.ConnectionString))
                            {
                                bcp.BatchSize            = dt.Rows.Count;
                                bcp.BulkCopyTimeout      = 1000;
                                bcp.DestinationTableName = "tbAccelerateGridSceneTmpCluster";
                                bcp.WriteToServer(dt);
                                bcp.Close();
                            }
                            dt.Clear();
                            IbatisHelper.ExecuteUpdate("UpdatetbAccelerateGridClusterByTmp", null);
                            IbatisHelper.ExecuteDelete("DeletetbAccelerateGridSceneTmpCluster", null);
                        }
                    }
                    using (SqlBulkCopy bcp = new SqlBulkCopy(DataUtil.ConnectionString))
                    {
                        bcp.BatchSize            = dt.Rows.Count;
                        bcp.BulkCopyTimeout      = 1000;
                        bcp.DestinationTableName = "tbAccelerateGridSceneTmpCluster";
                        bcp.WriteToServer(dt);
                        bcp.Close();
                    }
                    dt.Clear();
                    IbatisHelper.ExecuteUpdate("UpdatetbAccelerateGridClusterByTmp", null);
                    IbatisHelper.ExecuteDelete("DeletetbAccelerateGridSceneTmpCluster", null);
                }
                catch (Exception ex2)
                {
                    return(new Result(false, ex2.ToString()));
                }


                //更新tbDependTabled的ClustertoDB
                IbatisHelper.ExecuteUpdate("UpdatetbDependTableClustertoDB", null);
                cnt++;
                loadInfo.cnt = cnt;
                loadInfo.loadUpdate();
                return(new Result(true, "场景划分完成"));
            }
            catch (Exception ex)
            {
                return(new Result(false, ex.ToString()));
            }
        }
Esempio n. 24
0
        private bool GetTotalintoTmp(DataTable dtInfo)
        {
            try
            {
                IbatisHelper.ExecuteDelete("deletetbtmpDTData", null);
                int ucount = 0;
                foreach (DataRow dtrow in dtInfo.Rows)
                {
                    int    id  = int.Parse(dtrow["ID"].ToString());
                    double lon = double.Parse(dtrow["Lon"].ToString());
                    double lat = double.Parse(dtrow["Lat"].ToString());
                    int    pci = int.Parse(dtrow["PCI"].ToString());

                    if (cellmap.ContainsKey(pci))
                    {
                        List <UseCell> tmp      = new List <UseCell>(cellmap[pci]);
                        double         dis      = double.MaxValue;
                        int            minindex = 0;
                        for (int i = 0; i < tmp.Count; i++)
                        {
                            //Debug.WriteLine("tmp"+i+"   :" + tmp[i].x + "," + tmp[i].y);
                            double curdis = CJWDHelper.distance(lon, lat, tmp[i].lon, tmp[i].lat) * 1000;
                            if (curdis < dis)
                            {
                                dis      = curdis;
                                minindex = i;
                            }
                            if (dis < 0.5)
                            {
                                Debug.WriteLine("pt.x");
                            }
                        }
                        //找到对应的小区信息,添加到dtable中
                        Point pt = new Point(lon, lat, 0);
                        pt = PointConvertByProj.Instance.GetProjectPoint(pt);
                        DataRow dr = dtable.NewRow();
                        dr["ID"]         = id;
                        dr["x"]          = pt.X;
                        dr["y"]          = pt.Y;
                        dr["eNodeBID"]   = tmp[minindex].eNodeB;
                        dr["CellID"]     = tmp[minindex].cellID;
                        dr["SCell_Dist"] = dis;
                        dtable.Rows.Add(dr);
                        if (dtable.Rows.Count > 5000)
                        {
                            writeFinalResultToDB(dtable, "tbtmpDTData");
                        }
                    }
                    else
                    {
                        ucount++;
                        continue;
                    }
                }
                Debug.WriteLine(ucount + "条无效数据");
                writeFinalResultToDB(dtable, "tbtmpDTData");
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.StackTrace);
                return(false);
            }
            return(true);
        }
Esempio n. 25
0
        public Result ComputeInfRSRP()
        {
            loadInfo.loadCountAdd(3);
            DTHandlerModel dt = new DTHandlerModel();

            dt.UpdateDTDataForLoc();
            loadInfo.loadHashAdd(1);
            #region 计算路测数据RSRP入库
            //去除无效数据
            IbatisHelper.ExecuteDelete("deleteNouseDTNoInf");
            IbatisHelper.ExecuteDelete("deleteNouseDTInf");
            DataTable dtnoinf = IbatisHelper.ExecuteQueryForDataTable("getDTNoInf", null);
            DataTable dtinf   = IbatisHelper.ExecuteQueryForDataTable("getDTInf", null);
            if (dtinf.Rows.Count < 1 || dtnoinf.Rows.Count < 1)
            {
                return(new Result(false, "无路测数据"));
            }
            Hashtable htinf = new Hashtable();
            htinf["InfName"] = this.infname;
            IbatisHelper.ExecuteDelete("deleteUINTF", htinf);//删除当前表里该干扰源对应的数据

            bool[] flag = new bool[dtinf.Rows.Count];
            for (int i = 0; i < dtnoinf.Rows.Count; i++)
            {
                double lon     = Convert.ToDouble(dtnoinf.Rows[i]["Lon"].ToString());
                double lat     = Convert.ToDouble(dtnoinf.Rows[i]["Lat"].ToString());
                double RSRP1   = Convert.ToDouble(dtnoinf.Rows[i]["RSRP"].ToString());
                double SINR1   = Convert.ToDouble(dtnoinf.Rows[i]["SINR"].ToString());
                int    CInoinf = Convert.ToInt32(dtnoinf.Rows[i]["CI"].ToString());
                int    ID      = Convert.ToInt32(dtnoinf.Rows[i]["ID"].ToString());

                for (int j = 0; j < dtinf.Rows.Count; j++)
                {
                    int    CIinf = Convert.ToInt32(dtinf.Rows[j]["CI"].ToString());
                    double lon1  = Convert.ToDouble(dtinf.Rows[j]["Lon"].ToString());
                    double lat1  = Convert.ToDouble(dtinf.Rows[j]["Lat"].ToString());
                    if (flag[j] || CInoinf != CIinf)
                    {
                        if (CJWDHelper.distance(lon, lat, lon1, lat1) * 1000 < 1)//若距离太近,则该点不要
                        {
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        double RSRP2 = Convert.ToDouble(dtinf.Rows[j]["RSRP"].ToString());
                        double SINR2 = Convert.ToDouble(dtinf.Rows[j]["SINR"].ToString());
                        if (CJWDHelper.distance(lon, lat, lon1, lat1) * 1000 <= 9)
                        {
                            double tmp = (Math.Pow(10, RSRP2 / 10) / Math.Pow(10, SINR2 / 10))
                                         - (Math.Pow(10, RSRP1 / 10) / Math.Pow(10, SINR1 / 10));
                            if (tmp <= 0)
                            {
                                continue;
                            }
                            double  UINTF  = 10 * Math.Log10(tmp);
                            DataRow newRow = reset.NewRow();
                            newRow["ID"] = ID;
                            Point pt = new Point(lon, lat, 0);
                            pt                = PointConvertByProj.Instance.GetProjectPoint(pt);
                            newRow["x"]       = pt.X;
                            newRow["y"]       = pt.Y;
                            newRow["Lon"]     = lon;
                            newRow["Lat"]     = lat;
                            newRow["RSRP"]    = UINTF;
                            newRow["InfName"] = this.infname;
                            newRow["DtType"]  = "路测";
                            reset.Rows.Add(newRow);
                            flag[j] = true;
                            break;
                        }
                    }
                }
                if (reset.Rows.Count == 5000)
                {
                    DTHandlerModel.writeFinalResultToDB(reset, "tbUINTF");
                }
            }
            dtinf.Clear();
            dtnoinf.Clear();
            loadInfo.loadHashAdd(1);
            #endregion

            #region 计算终端数据入库
            IbatisHelper.ExecuteDelete("deleteNouseTerminalMI", null);
            Hashtable ht = new Hashtable();
            ht["isInf"] = 0;
            //增加终端部分的RSRP处理
            DataTable ternoinf = IbatisHelper.ExecuteQueryForDataTable("getTerminalMI", ht);
            ht["isInf"] = 1;
            DataTable terinf = IbatisHelper.ExecuteQueryForDataTable("getTerminalMI", ht);
            bool[]    Tflag  = new bool[ternoinf.Rows.Count];
            for (int i = 0; i < ternoinf.Rows.Count; i++)
            {
                double lon   = Convert.ToDouble(ternoinf.Rows[i]["Lon"].ToString());
                double lat   = Convert.ToDouble(ternoinf.Rows[i]["Lat"].ToString());
                double RSRP1 = Convert.ToDouble(ternoinf.Rows[i]["RSRP"].ToString());
                double SINR1 = Convert.ToDouble(ternoinf.Rows[i]["SINR"].ToString());
                long   IMSI  = Convert.ToInt64(ternoinf.Rows[i]["IMSI"].ToString());

                for (int j = 0; j < terinf.Rows.Count; j++)
                {
                    long   IMSIinf = Convert.ToInt64(terinf.Rows[j]["IMSI"].ToString());
                    double lon1    = Convert.ToDouble(terinf.Rows[j]["Lon"].ToString());
                    double lat1    = Convert.ToDouble(terinf.Rows[j]["Lat"].ToString());
                    if (Tflag[j] || IMSI != IMSIinf)
                    {
                        if (CJWDHelper.distance(lon, lat, lon1, lat1) * 1000 < 1)//若距离太近,则该点不要
                        {
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        double RSRP2 = Convert.ToDouble(terinf.Rows[j]["RSRP"].ToString());
                        double SINR2 = Convert.ToDouble(terinf.Rows[j]["SINR"].ToString());
                        if (CJWDHelper.distance(lon, lat, lon1, lat1) * 1000 <= 9)
                        {
                            double tmp = (Math.Pow(10, RSRP2 / 10) / Math.Pow(10, SINR2 / 10))
                                         - (Math.Pow(10, RSRP1 / 10) / Math.Pow(10, SINR1 / 10));
                            if (tmp <= 0)
                            {
                                continue;
                            }
                            double  UINTF  = 10 * Math.Log10(tmp);
                            DataRow newRow = reset.NewRow();
                            newRow["ID"] = i;
                            Point pt = new Point(lon, lat, 0);
                            pt                = PointConvertByProj.Instance.GetProjectPoint(pt);
                            newRow["x"]       = pt.X;
                            newRow["y"]       = pt.Y;
                            newRow["Lon"]     = lon;
                            newRow["Lat"]     = lat;
                            newRow["RSRP"]    = UINTF;
                            newRow["InfName"] = this.infname;
                            newRow["DtType"]  = "终端";
                            reset.Rows.Add(newRow);
                            Tflag[j] = true;
                            break;
                        }
                    }
                }
                if (reset.Rows.Count == 5000)
                {
                    DTHandlerModel.writeFinalResultToDB(reset, "tbUINTF");
                }
            }


            if (reset.Rows.Count > 0)
            {
                DTHandlerModel.writeFinalResultToDB(reset, "tbUINTF");
            }
            loadInfo.loadHashAdd(1);
            #endregion
            return(new Result(true, "成功"));
        }
Esempio n. 26
0
 public void deleteGroundCover(Hashtable ht)
 {
     IbatisHelper.ExecuteDelete("deleteSpecifiedCelltbGrids", ht);
 }