Beispiel #1
0
        private void loadTrajectory_obsolete()
        {
            using (StreamReader sr = new StreamReader(TBConst.trajectoryPath_obsolete + this.map_name + ".txt"))
            {
                int tot_point = 0;
                while (true)
                {
                    if (sr.EndOfStream)
                        break;
                    Trajectory traj = new Trajectory();
                    string comment = sr.ReadLine(); //replay_id 19 user_id 1686
                    string line = sr.ReadLine(); // 9.8 93.15 9.9 93.0 10.05 92.8 .......
                    string[] sp = line.Split(' ');
                    //for (int i = 0; i < sp.Length; i += 2)
                    {
                        int i = 0;
                        double x = Convert.ToDouble(sp[i]);
                        double y = Convert.ToDouble(sp[i + 1]);
                        x = (x + 105) / 21 + 1;
                        y = (y + 105) / 21 + 1;
                        traj.add_point(new Point(x, y));

                    }
                    traj.comment = comment;
                    traj = pruneTrajectory(traj, 0.05);
                    addToHeapmap_obsolete(traj);
                    traj.reversed = false;
                    trajs.Add(traj);
                    Trajectory rev = new Trajectory();
                    foreach (Point p in traj)
                    {
                        rev.add_point(p);
                    }
                    rev.Reverse();
                    rev.reversed = true;
                    trajs.Add(rev);
                    tot_point += traj.Count * 2;
                }

            }
        }
Beispiel #2
0
 /// <summary>
 /// remove the nodes in trajectory in order to for sure 
 /// that the distance between any nodes are larger than threshold
 /// </summary>
 /// <param name="t"></param>
 /// <param name="threshhold"></param>
 /// <returns></returns>
 private Trajectory pruneTrajectory(Trajectory t, double threshhold = 0.1)
 {
     Trajectory xo = new Trajectory();
     foreach (Point p in t)
     {
         if (xo.Count == 0)
         {
             xo.add_point(p);
             continue;
         }
         double mindis = 1e10;
         foreach (Point x in xo)
         {
             mindis = Math.Min(mindis, TBMath.distance(x, p));
         }
         if (mindis > threshhold)
             xo.add_point(p);
     }
     return xo;
 }
Beispiel #3
0
        private Trajectory backtrace(Point source, Point target)
        {
            int endx = d2i(target.x);
            int endy = d2i(target.y);

            int fx = 0, fy = 0;
            for (int step = 0; ; step++)
            {
                for (int i = -step; i <= step; i++)
                    for (int j = -step; j <= step; j++)
                    {
                        if (endx + i < 0) return new Trajectory();
                        if (endy + j < 0) return new Trajectory();

                        if (endx + i >= WIDTH) return new Trajectory();
                        if (endy + j >= WIDTH) return new Trajectory();

                        if (visit[endx + i, endy + j])
                        {
                            fx = endx + i;
                            fy = endy + j;
                            goto brk;
                        }
                    }
            }
            brk:
            Trajectory t = new Trajectory();
            while (true)
            {
                if (fx == d2i(source.x) && fy == d2i(source.y))
                    break;
                t.add_point(new Point(i2d(fx), i2d(fy)));
                Tuple<int, int> pre = prev[fx, fy];
                fx = pre.Item1;
                fy = pre.Item2;
            }
            Trajectory rt = new Trajectory();
            for (int i = t.Count - 1; i >= 0; i--)
            {
                rt.add_point(t[i]);
            }
            return rt;
        }