예제 #1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            MM mm = new MM(provider.graph);

            foreach (String trjFile in trjFiles)
            {
                Trajectory trj      = new Trajectory(trjFile);
                Trajectory newTrj   = mm.match(trj);
                String     fileName = Path.Combine(outputDir, Path.GetFileName(trjFile));
                newTrj.Save(fileName);
            }
            String notice = String.Format("Open directory to find the output file(s) in {0}?", outputDir);

            if (MessageBox.Show(notice, "Mission Complete", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                Process.Start(outputDir);
            }
        }
예제 #2
0
        private void miOpenTrj_Click(object sender, EventArgs e)
        {
            //OpenFileDialog f = new OpenFileDialog();
            OpenFileDialog f = new OpenFileDialog();

            //f.InitialDirectory = Directory.GetCurrentDirectory();
            f.FileName = shpFileName;
            f.Filter   = "Trajectory Files (*.trj;*.txt)|*.trj;*.txt|All Files (*.*)|*.*";
            if (f.ShowDialog() == DialogResult.OK)
            {
                // outputFileDir = f.SelectedPath + "\\";
                //MessageBox.Show(f.SelectedPath);
                //Trajectory trj = new Trajectory(f.FileName, 1, graph);
                Trajectory trj       = new Trajectory(f.FileName, 1);
                var        transform = new Wgs2MgsTransform();
                drawTrj(trj);
                trj = transform.Transform(trj);
                drawTrj(trj);
                MM mm = new MM(graph);
                //var newTrj = mm.match(trj);
                trj = mm.match(trj);
                drawPath(trj.Path.Edges);
            }
        }
예제 #3
0
        public static Dictionary <string, Trajectory> mergeBeijingTrjDir(string dir, string targetDir)
        {
            string[] files = Directory.GetFiles(dir, "109_*");
            var      dict  = new Dictionary <string, List <string> >();
            var      trjs  = new Dictionary <string, Trajectory>();

            if (!Directory.Exists(targetDir))
            {
                Directory.CreateDirectory(targetDir);
            }
            foreach (var fileName in files)
            {
                Console.WriteLine("Processing {0}", fileName);
                string outFileName = Path.Combine(targetDir, Path.GetFileName(fileName));
                mergeBeijingTrj(fileName, dict);
            }
            string trjDir = Path.Combine(Constants.DATA_DIR, "beijingTrjPart", "trj");
            // do mapmatching
            var graph = MapLoader.Load("Beijing_trust_oneside_no_dev");
            var mm    = new MM(graph);
            int count = 0;

            foreach (var p in dict)
            {
                //Console.WriteLine("Device:{0}, Count:{1}", p.Key, p.Value.Count);
                //File.WriteAllLines(Path.Combine(trjDir, p.Key + ".trj"), p.Value.Distinct().OrderBy(a => a).ToArray());
                var trj = listToTrajectory(p.Value.Distinct(new FirstCommaFieldComparer()).OrderBy(a => a).ToArray());
                trjs[p.Key] = mm.match(trj);
                ++count;
                //if (count % 10 == 0)
                {
                    Console.WriteLine("File:{0}, Percentage:{1}%", p.Key, count * 100.0 / dict.Count);
                }
            }
            return(trjs);
        }