Ejemplo n.º 1
0
        private void writeResToDb()
        {
            //Console.WriteLine(string.Format("merge outcome..., init num : {0}", this.GridStrengths.Count));
            //Console.ReadKey();
            DateTime d1, d2;

            d1 = DateTime.Now;
            CalcGridStrength calc = new CalcGridStrength(this.cellInfo, null);

            this.GridStrengths = calc.MergeMultipleTaskStrength(this.MultiTasksGridStrengths);
            d2 = DateTime.Now;
            Console.WriteLine(string.Format("merge done. now num : {0}, using time: {1}ms", this.GridStrengths.Count, (d2 - d1).TotalMilliseconds));

            // 2017.6.14
            Console.WriteLine();
            Console.WriteLine("射线所能达到的最远地面距离: {0} m,该点功率:{1} dbm", calc.maxDistGround, calc.dbm);
            Console.WriteLine("小区平面坐标:({0}, {1})", calc.cellInfo.SourcePoint.X, calc.cellInfo.SourcePoint.Y);
            Console.WriteLine("射线所能达到的最远地面坐标:({0}, {1})", calc.gx, calc.gy);
            Console.WriteLine("覆盖栅格总数: {0}", this.GridStrengths.Count);
            Console.WriteLine();

            //Console.WriteLine("connection = " + DB.DataUtil.ConnectionString);

            Console.WriteLine("writing to database ...");

            GridCover gc = GridCover.getInstance();

            gc.convertToDt(this.GridStrengths);
            this.GridStrengths.Clear();
            Hashtable ht = new Hashtable();

            ht["eNodeB"] = this.cellInfo.eNodeB;
            ht["CI"]     = this.cellInfo.CI;
            //gc.deleteGroundCover(ht);
            gc.wirteGroundCover(ht);
            gc.clearGround();
            //if (this.computeIndoor)
            {
                //gc.deleteBuildingCover(ht);
                gc.writeBuildingCover(ht);
                gc.clearBuilding();
            }
            Console.WriteLine("地面栅格总数: {0}", gc.ng);
            Console.WriteLine("立体栅格总数: {0}", gc.nb);
            end = DateTime.Now;
            string info = string.Format("总运行时间:{0}毫秒\n", (end - start).TotalMilliseconds);

            Console.WriteLine(info);
            Console.WriteLine("write done");

            RedisMq.Pub("cover2db_finish", this.cellInfo.eNodeB);

            //this.GridStrengths.Clear();
            //Console.ReadKey(); // 2019.04.12
            this.cs.free();
            this.Close();  // 2019.04.12
                           //this.procDoneNum = 0;
        }
Ejemplo n.º 2
0
        private void filterLoc(ref List <StrongWeakPt> Pt)
        {
            // 寻找符合条件的强点
            Pt.Sort(new StrongPtCmp());
            List <List <int> > id = new List <List <int> >();

            double dis   = 300;
            int    numPt = Math.Min(25, Math.Max(0, Pt.Count() - 3));
            bool   ok    = false;

            while (id.Count < numPt && dis >= 0)
            {
                for (int i = 0; i < Pt.Count; i++)
                {
                    double x1 = Pt[i].strong.X;
                    double y1 = Pt[i].strong.Y;

                    for (int j = i + 1; j < Pt.Count; j++)
                    {
                        double x2 = Pt[j].strong.X;
                        double y2 = Pt[j].strong.Y;

                        if (Math.Abs(x1 - x2) > dis && Math.Abs(y1 - y2) > dis)
                        {
                            for (int k = j + 1; k < Pt.Count; k++)
                            {
                                double x3 = Pt[k].strong.X;
                                double y3 = Pt[k].strong.Y;

                                if (Math.Abs(x3 - x2) > dis && Math.Abs(y3 - y2) > dis && Math.Abs(x1 - x3) > dis && Math.Abs(y1 - y3) > dis)
                                {
                                    List <int> tmpId = new List <int>();
                                    tmpId.Add(i);
                                    tmpId.Add(j);
                                    tmpId.Add(k);
                                    id.Add(tmpId);
                                    if (id.Count >= numPt)
                                    {
                                        ok = true;
                                        break;
                                    }
                                }
                            }
                        }
                        if (ok)
                        {
                            break;
                        }
                    }
                    if (ok)
                    {
                        break;
                    }
                }
                dis -= 50;
            }

            // 评估
            List <Score>     score = new List <Score>();
            CalcGridStrength cgs   = new CalcGridStrength(null, null);

            // 实际的
            List <double> dif1 = new List <double>();

            for (int i = 0; i < id.Count; i++)
            {
                List <int> j = id[i];
                dif1.Add((Pt[j[0]].strongPower - Pt[j[1]].strongPower) / (Pt[j[0]].strongPower - Pt[j[2]].strongPower));
            }

            // 计算的
            score.Add(new Score(0, 0, 0, double.MaxValue));
            for (double x = leftBound; x < rightBound; x += 10)
            {
                for (double y = downBound; y < upBound; y += 10)
                {
                    for (double h = 3; h < 100; h += 10)
                    {
                        double diff = 0;
                        for (int i = 0; i < id.Count; i++)
                        {
                            List <int> j    = id[i];
                            double     p1   = cgs.calcDirectRayStrength(x, y, h, Pt[j[0]].strong.X, Pt[j[0]].strong.Y, 0, 50, 1800);
                            double     p2   = cgs.calcDirectRayStrength(x, y, h, Pt[j[1]].strong.X, Pt[j[1]].strong.Y, 0, 50, 1800);
                            double     p3   = cgs.calcDirectRayStrength(x, y, h, Pt[j[2]].strong.X, Pt[j[2]].strong.Y, 0, 50, 1800);
                            double     dif2 = (p1 - p2) / (p1 - p3);
                            if (Math.Abs(p1 - p3) < 0.0001)
                            {
                                continue;
                            }
                            diff += Math.Pow(dif2 - dif1[i], 2);
                        }
                        score.Add(new Score(x, y, h, diff));
                    }
                }
            }

            score.Sort(new ScoreCmp());

            for (int i = 0; i < score.Count && i < 3; i++)
            {
                RayResult.Add(new Pt3D(score[i].x, score[i].y, score[i].z));

                int gx = 0, gy = 0, gz = 0;
                GridHelper.getInstance().XYZToAccGrid(score[i].x, score[i].y, score[i].z, ref gx, ref gy, ref gz);

                FinalResult.Add(new Pt3D(score[i].x, score[i].y, score[i].z));
            }
        }