コード例 #1
0
        public void AnalyzeFindTravelTimePattersInOneDay_Simulated()
        {
            XmlTravelTimeDB db = new XmlTravelTimeDB();
            db.Load(new MemoryStream(TestData.simulated_traffic_db_day));

            OSMDB map = new OSMDB();
            map.Nodes.Add(new OSMNode(1, 1, 1));
            map.Nodes.Add(new OSMNode(2, 1.1, 1.1));

            TTAnalyzer analyzer = new TTAnalyzer(map);
            Model target = analyzer.Analyze(db.TravelTimes, db.TravelTimesSegments.First());
        }
コード例 #2
0
        static void Main(string[] args)
        {
            string dbPath     = "";
            string mapPath    = "";
            string trackPath  = "";
            string outputPath = ".";
            bool   addTracks  = false;
            bool   showHelp   = false;
            bool   analyze    = false;

            OptionSet parameters = new OptionSet()
            {
                { "db=", "path to the travel times database", v => dbPath = v },
                { "add", "adds specified tracks to the DB", v => addTracks = v != null },
                { "track=", "path to the matched GPS track to process or to the directory to process", v => trackPath = v },
                { "map=", "path to the routable map", v => mapPath = v },
                { "a|analyze", v => analyze = v != null },
                { "o|output=", "path to the output directory", v => outputPath = v },
                { "h|?|help", v => showHelp = v != null },
            };

            try {
                parameters.Parse(args);
            }
            catch (OptionException e) {
                Console.Write("Analyzer: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `analyzer --help' for more information.");
                return;
            }

            if (showHelp || string.IsNullOrEmpty(dbPath) || string.IsNullOrEmpty(outputPath))
            {
                ShowHelp(parameters);
                return;
            }

            Console.Write("Loading travel times database ...");
            XmlTravelTimeDB db = new XmlTravelTimeDB();

            if (File.Exists(dbPath))
            {
                db.Load(dbPath);
            }
            Console.WriteLine("\t\t\tDone.");

            if (addTracks)
            {
                if (File.Exists(trackPath))
                {
                    AddTrackToDB(db, trackPath);
                }
                else if (Directory.Exists(trackPath))
                {
                    var files = Directory.GetFiles(trackPath, "*.osm");
                    Console.WriteLine("Found {0} GPX file(s).", files.Length);

                    foreach (var file in files)
                    {
                        AddTrackToDB(db, file);
                    }
                }

                Console.Write("Saving travel times database ...");
                db.Save(dbPath);
                Console.WriteLine("\t\t\tDone.");
            }

            if (analyze)
            {
                Console.Write("Loading routable map ...");
                OSMDB map = new OSMDB();
                map.Load(mapPath);

                Console.WriteLine("\t\t\t\tDone.");

                IModelsRepository modelsRepository = new XmlModelsRepository(outputPath);

                TTAnalyzer analyzer = new TTAnalyzer(map);
                foreach (var segment in db.TravelTimesSegments)
                {
                    Model m = analyzer.Analyze(db.GetTravelTimes(segment), segment);
                    if (m != null)
                    {
                        modelsRepository.AddModel(m);
                    }
                }

                Console.Write("Saving models ...");
                modelsRepository.Commit();
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: guifa/traveltimeanalysis
        static void Main(string[] args)
        {
            string dbPath = "";
            string mapPath = "";
            string trackPath = "";
            string outputPath = ".";
            bool addTracks = false;
            bool showHelp = false;
            bool analyze = false;

            OptionSet parameters = new OptionSet() {
                { "db=", "path to the travel times database",																									v => dbPath = v},
                { "add", "adds specified tracks to the DB",																										v => addTracks = v != null},
                { "track=",	"path to the matched GPS track to process or to the directory to process",				v => trackPath = v},
                { "map=", "path to the routable map",																													v => mapPath = v},
                { "a|analyze",																																								v => analyze = v != null},
                { "o|output=", "path to the output directory",																								v => outputPath = v},
                { "h|?|help",																																									v => showHelp = v != null},
            };

            try {
                parameters.Parse(args);
            }
            catch (OptionException e) {
                Console.Write("Analyzer: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `analyzer --help' for more information.");
                return;
            }

            if (showHelp || string.IsNullOrEmpty(dbPath) || string.IsNullOrEmpty(outputPath)) {
                ShowHelp(parameters);
                return;
            }

            Console.Write("Loading travel times database ...");
            XmlTravelTimeDB db = new XmlTravelTimeDB();
            if (File.Exists(dbPath)) {
                db.Load(dbPath);
            }
            Console.WriteLine("\t\t\tDone.");

            if (addTracks) {
                if (File.Exists(trackPath)) {
                    AddTrackToDB(db, trackPath);
                }
                else if (Directory.Exists(trackPath)) {
                    var files = Directory.GetFiles(trackPath, "*.osm");
                    Console.WriteLine("Found {0} GPX file(s).", files.Length);

                    foreach (var file in files) {
                        AddTrackToDB(db, file);
                    }
                }

                Console.Write("Saving travel times database ...");
                db.Save(dbPath);
                Console.WriteLine("\t\t\tDone.");
            }

            if (analyze) {
                Console.Write("Loading routable map ...");
                OSMDB map = new OSMDB();
                map.Load(mapPath);

                Console.WriteLine("\t\t\t\tDone.");

                IModelsRepository modelsRepository = new XmlModelsRepository(outputPath);

                TTAnalyzer analyzer = new TTAnalyzer(map);
                foreach (var segment in db.TravelTimesSegments) {
                    Model m = analyzer.Analyze(db.GetTravelTimes(segment), segment);
                    if (m != null) {
                        modelsRepository.AddModel(m);
                    }
                }

                Console.Write("Saving models ...");
                modelsRepository.Commit();
            }
        }