public void Wdt()
        {
            Hashtable ht     = new Hashtable();
            DataTable dtable = new DataTable();

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

            for (int vir = 50369; vir <= 50458; vir++)
            {
                dtable.Clear();
                ht["eNodeB"] = vir;
                DataTable dt      = DB.IbatisHelper.ExecuteQueryForDataTable("qureyMockDT", ht);
                int       initOff = 5000;
                int       uid     = (int)UIDHelper.GenUIdByRedis("DT", dt.Rows.Count) + initOff;

                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"] = "v1" + "_" + vir;
                    thisrow["DtType"]  = "mock";
                    dtable.Rows.Add(thisrow);
                }
                DataUtil.BCPDataTableImport(dtable, "tbUINTF");
            }
        }
        double constraint_low_bound   = 0.02;   // 策略3的控制参数

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

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

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

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

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

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

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

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

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


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

            BuildingGrid3D.getAllBuildingIDRange(out minBid, out maxBid);

            DataTable dt = new DataTable();

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

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

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

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


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

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

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

            return(new Result(true));
        }
        /// <summary>
        /// 对统计栅格按照训练特征进行统计并入库
        /// </summary>
        /// <param name="togrid"></param>
        /// <param name="inf_name"></param>
        public void Tarj2GridFeature(Dictionary <string, List <GridInfo> > togrid, string inf_name)
        {
            System.Data.DataTable tb = new System.Data.DataTable();
            tb.Columns.Add("GXID");
            tb.Columns.Add("GYID");
            tb.Columns.Add("GZID");
            tb.Columns.Add("InfName");         //此版本数据对应的干扰源名称

            tb.Columns.Add("DtRatio");         //路测点占比
            tb.Columns.Add("Recp");            //信号接收强度
            tb.Columns.Add("RecVar");          //信号接收总方差
            tb.Columns.Add("Dis");             //距离干扰源的距离的平方
            tb.Columns.Add("DireVar");         //信号接收直射方差
            tb.Columns.Add("RefVar");          //信号接收反射方差
            tb.Columns.Add("DifVar");          //信号接收绕射方差
            tb.Columns.Add("BuildRatio600");   //600m栅格建筑物面积占比
            tb.Columns.Add("BuildRatio300");   //300m栅格建筑物面积占比
            tb.Columns.Add("Scene");           //场景

            tb.Columns.Add("UniDireRatio");    //直射占比(不同路测点发出的)
            tb.Columns.Add("UniNotDireRatio"); //非直射占比(不同路测点发出的)

            tb.Columns.Add("DireRatio");       //直射占比(不区分路测点)
            tb.Columns.Add("RefRatio");        //反射占比(不区分路测点)
            tb.Columns.Add("DifRatio");        //绕射占比(不区分路测点)


            string[] tmp1 = inf_name.Split('_');
            //获取干扰源的位置
            int       id = int.Parse(tmp1[tmp1.Length - 1]);
            Hashtable ht = new Hashtable();

            ht["id"] = id;
            int       dtSum   = (int)IbatisHelper.ExecuteQueryForObject("countDt", inf_name);
            DataTable dt      = IbatisHelper.ExecuteQueryForDataTable("queryCellPosById", ht);
            double    x       = double.Parse(dt.Rows[0]["x"].ToString());
            double    y       = double.Parse(dt.Rows[0]["y"].ToString());
            double    h       = double.Parse(dt.Rows[0]["h"].ToString());
            Grid3D    tarGrid = new Grid3D();

            GridHelper.getInstance().PointXYZToAccGrid(new Point(x, y, h), ref tarGrid);

            foreach (var item in togrid)
            {
                System.Data.DataRow thisrow = tb.NewRow();
                thisrow["InfName"] = inf_name;
                string[] strs = item.Key.Split(',');

                int gxId = int.Parse(strs[0]);
                int gyId = int.Parse(strs[1]);
                int gzId = int.Parse(strs[2]);

                thisrow["GXID"] = gxId;
                thisrow["GYID"] = gyId;
                thisrow["GZID"] = gzId;

                //获取建筑物面积占比  len==600
                Point  cen    = GridHelper.getInstance().Grid2CenterXY(new Grid3D(gxId, gyId, 0), 30);
                Grid3D brGrid = new Grid3D();
                GridHelper.getInstance().PointXYZGrid(cen, ref brGrid, 600, 0);
                string keyPos     = String.Format("{0}_{1}", brGrid.gxid, brGrid.gyid);
                var    tmp        = RedisHelper.get(prefix, keyPos);
                double buildRatio = Convert.ToDouble(tmp);
                thisrow["BuildRatio600"] = buildRatio;

                //获取建筑物面积占比  len==300
                cen = GridHelper.getInstance().Grid2CenterXY(new Grid3D(gxId, gyId, 0), 30);
                GridHelper.getInstance().PointXYZGrid(cen, ref brGrid, 300, 0);
                keyPos     = String.Format("{0}_{1}", brGrid.gxid, brGrid.gyid);
                tmp        = RedisHelper.get(prefix + "_" + 300, keyPos);
                buildRatio = Convert.ToDouble(tmp);
                thisrow["BuildRatio300"] = buildRatio;


                //获取场景
                ht["gxid"] = gxId;
                ht["gyid"] = gyId;
                int scene = Convert.ToInt16(IbatisHelper.ExecuteQueryForObject("getScene", ht));
                thisrow["Scene"] = scene;

                int dx = int.Parse(strs[0]) - tarGrid.gxid;
                int dy = int.Parse(strs[1]) - tarGrid.gyid;
                int dz = int.Parse(strs[2]) - tarGrid.gzid;
                thisrow["Dis"] = Math.Pow(dx, 2) + Math.Pow(dy, 2) + Math.Pow(dz, 2);

                //某一个栅格的统计信息
                Dictionary <string, List <GridInfo> > dic = new Dictionary <string, List <GridInfo> >();

                HashSet <string> uniDirectRay    = new HashSet <string>();
                HashSet <string> uniNotDirectRay = new HashSet <string>();

                double directNum   = 0;
                double reflectNUm  = 0;
                double difractNum  = 0;
                double recp        = int.MinValue;
                double recpVar     = 0;
                double directVar   = 0;
                double reflectVar  = 0;
                double diffractVar = 0;

                List <double> recpLs       = new List <double>();
                List <double> directRecp   = new List <double>();
                List <double> reflectRecp  = new List <double>();
                List <double> diffractRecp = new List <double>();

                foreach (GridInfo gr in item.Value)
                {
                    //只统计不同路测点的直射数目
                    if (gr.rayType == 0)
                    {
                        directNum++;
                        uniDirectRay.Add(gr.cellid);
                    }
                    if (gr.rayType == 1 || gr.rayType == 2)
                    {
                        reflectNUm++;
                        uniNotDirectRay.Add(gr.cellid);
                    }
                    if (gr.rayType == 3 || gr.rayType == 4)
                    {
                        difractNum++;
                        uniNotDirectRay.Add(gr.cellid);
                    }
                    if (!dic.ContainsKey(gr.cellid))
                    {
                        dic[gr.cellid] = new List <GridInfo>();
                    }
                    dic[gr.cellid].Add(gr);
                }

                thisrow["DireRatio"] = directNum / item.Value.Count;
                thisrow["RefRatio"]  = reflectNUm / item.Value.Count;
                thisrow["DifRatio"]  = difractNum / item.Value.Count;

                thisrow["UniDireRatio"]    = (double)uniDirectRay.Count / (double)(uniDirectRay.Count + uniNotDirectRay.Count);
                thisrow["UniNotDireRatio"] = (double)uniNotDirectRay.Count / (double)(uniDirectRay.Count + uniNotDirectRay.Count);

                //thisrow["reflect_num"] = reflectNUm;
                //thisrow["difract_num"] = difractNum;
                //thisrow["rp_num"] = dic.Keys.Count;

                thisrow["DtRatio"] = (double)dic.Keys.Count / (double)dtSum;

                double distinctdirectNum = 0;
                double distinctRefNum    = 0;
                double distinctDiffraNum = 0;

                foreach (var grs in dic)
                {
                    grs.Value.Sort((ox, oy) =>
                    {
                        if (ox is null)
                        {
                            throw new ArgumentNullException(nameof(ox));
                        }
                        if (oy is null)
                        {
                            throw new ArgumentNullException(nameof(oy));
                        }
                        if (double.IsNaN(ox.recP) || double.IsNaN(oy.recP))
                        {
                            throw new ArgumentException(nameof(ox) + " can't contain NaNs.");
                        }
                        int p1      = ox.rayType - oy.rayType;
                        int p2      = ox.raylevel - oy.raylevel;
                        double temp = oy.recP - ox.recP;
                        int p3      = 0;
                        if (temp < 0)
                        {
                            p3 = -1;
                        }
                        if (temp > 0)
                        {
                            p3 = 1;
                        }
                        return(p1 != 0 ? p1 : (p2 != 0 ? p2 : p3));
                    });

                    double recpTemp = grs.Value[0].recP;
                    recpLs.Add(recpTemp);
                    recpVar += recpTemp;

                    recp = Math.Max(recpTemp, recp);
                    int type = grs.Value[0].rayType;
                    if (type == 0)
                    {
                        distinctdirectNum++;
                        directVar += recpTemp;
                        directRecp.Add(recpTemp);
                    }
                    if (type == 1 || type == 2)
                    {
                        distinctRefNum++;
                        reflectVar += recpTemp;
                        reflectRecp.Add(recpTemp);
                    }
                    if (type == 3 || type == 4)
                    {
                        distinctDiffraNum++;
                        diffractVar += recpTemp;
                        diffractRecp.Add(recpTemp);
                    }
                }
                double aveRecp         = recpVar / dic.Keys.Count;
                double aveDirectRecp   = distinctdirectNum == 0 ? 0 : directVar / distinctdirectNum;
                double aveReflectRecp  = distinctRefNum == 0 ? 0 : reflectVar / distinctRefNum;
                double aveDiffractRecp = distinctDiffraNum == 0 ? 0 : diffractVar / distinctDiffraNum;

                recpVar     = 0;
                reflectVar  = 0;
                diffractVar = 0;
                foreach (var rtRecp in recpLs)
                {
                    recpVar += Math.Pow(rtRecp - aveRecp, 2);
                }
                foreach (var rtRecp in directRecp)
                {
                    directVar += Math.Pow(rtRecp - aveDirectRecp, 2);
                }
                foreach (var rtRecp in reflectRecp)
                {
                    reflectVar += Math.Pow(rtRecp - aveReflectRecp, 2);
                }
                foreach (var rtRecp in diffractRecp)
                {
                    diffractVar += Math.Pow(rtRecp - aveDiffractRecp, 2);
                }
                //优先使用直射线的平均信号强度,若没有则使用所以射线的平均信号强度
                thisrow["Recp"]    = aveDirectRecp == 0? aveRecp: aveDirectRecp;
                thisrow["RecVar"]  = recpVar;
                thisrow["DireVar"] = directVar;
                thisrow["RefVar"]  = reflectVar;
                thisrow["DifVar"]  = diffractVar;
                tb.Rows.Add(thisrow);
            }
            string desTbName = "tbGridFeature";

            //WriteDataToBase(tb, 100, desTbName);
            DataUtil.BCPDataTableImport(tb, desTbName);
        }
        public Result BuildAreaRadio([FromBody] AreaSplitRange dataRange)
        {
            brGridGap = (int)dataRange.tarGridL;
            Point pMin = new Point();

            pMin.X = dataRange.minLongitude;
            pMin.Y = dataRange.minLatitude;
            pMin.Z = 0;
            LTE.Utils.PointConvertByProj.Instance.GetProjectPoint(pMin);

            Point pMax = new Point();

            pMax.X = dataRange.maxLongitude;
            pMax.Y = dataRange.maxLatitude;
            pMax.Z = 0;
            LTE.Utils.PointConvertByProj.Instance.GetProjectPoint(pMax);

            Grid3D minGrid = new Grid3D();
            Grid3D maxGrid = new Grid3D();

            GridHelper.getInstance().PointXYZGrid(pMin, ref minGrid, (int)dataRange.tarGridL, 0);
            GridHelper.getInstance().PointXYZGrid(pMax, ref maxGrid, (int)dataRange.tarGridL, 0);

            DataTable dtable = new DataTable();

            dtable.Columns.Add("gmxId");
            dtable.Columns.Add("gmyId");
            dtable.Columns.Add("buildRatio");
            dtable.Columns.Add("gridSize");

            for (int xId = minGrid.gxid; xId < maxGrid.gxid; xId++)
            {
                for (int yId = minGrid.gyid; yId < maxGrid.gyid; yId++)
                {
                    var       len = (int)dataRange.tarGridL;
                    Point     cen = GridHelper.getInstance().Grid2CenterXY(new Grid3D(xId, yId, 0), len);
                    Hashtable ht  = new Hashtable();
                    ht["minX"] = cen.X - dataRange.tarGridL / 2;
                    ht["maxX"] = cen.X + dataRange.tarGridL / 2;
                    ht["minY"] = cen.Y - dataRange.tarGridL / 2;
                    ht["maxY"] = cen.Y + dataRange.tarGridL / 2;
                    DataTable dt = IbatisHelper.ExecuteQueryForDataTable("queryBuildingVertex", ht);

                    Dictionary <int, List <Point> > dics = new Dictionary <int, List <Point> >();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        var    row = dt.Rows[i];
                        int    id  = (int)row["BuildingID"];
                        double vx  = double.Parse(row["VertexX"].ToString());
                        double vy  = double.Parse(row["VertexY"].ToString());
                        if (!dics.ContainsKey(id))
                        {
                            List <Point> points = new List <Point>();
                            points.Add(new Point(vx, vy, 0));
                            dics.Add(id, points);
                        }
                        dics[id].Add(new Point(vx, vy, 0));
                    }
                    double area = 0;
                    foreach (var key in dics.Keys)
                    {
                        area += CalculateArea(dics[key]);
                    }

                    string keyPos = String.Format("{0}_{1}", xId, yId);

                    double buildRatio = area / (dataRange.tarGridL * dataRange.tarGridL);
                    RedisHelper.putDouble(prefix + "_" + len, keyPos, buildRatio);

                    DataRow thisrow = dtable.NewRow();
                    thisrow["gmxId"]      = xId;
                    thisrow["gmyId"]      = yId;
                    thisrow["buildRatio"] = buildRatio;
                    thisrow["gridSize"]   = len;
                    dtable.Rows.Add(thisrow);
                }
            }

            DataUtil.BCPDataTableImport(dtable, "tbMockGrid");
            GisClient.ServiceApi.gisApi.Value = new GisClient.ServiceApi();
            GisClient.Result res = GisClient.ServiceApi.getGisLayerService().
                                   refreshMockGridLayer(minGrid.gxid, minGrid.gyid, maxGrid.gxid, maxGrid.gyid);

            return(new Result(true, "仿真区域建筑物面积占比计算成功"));
        }
Exemplo n.º 5
0
 public void writeBuildingCover(Hashtable ht)
 {
     //IbatisHelper.ExecuteDelete("deleteSpecifiedCelltbBuildingGrid3Ds", ht);
     DataUtil.BCPDataTableImport(this.buildingCover, "tbBuildingGridPathloss");
     this.buildingCover.Clear();
 }
Exemplo n.º 6
0
 public void wirteGroundCover(Hashtable ht)
 {
     //IbatisHelper.ExecuteDelete("deleteSpecifiedCelltbGrids", ht);
     DataUtil.BCPDataTableImport(this.groundCover, "tbGridPathloss");
     this.groundCover.Clear();
 }