Esempio n. 1
0
        /// <summary>
        /// Creates a new instance of the pathfinder
        /// </summary>
        /// <param name="graph">RoadGraph object that represents roads network</param>
        public AstarPathfinder(RoadGraph graph)
        {
            _graph = graph;

            _open  = new PartialPathList();
            _close = new Dictionary <Node, PartialPath>();
            _temporaryConnections = new List <Connection>();
        }
Esempio n. 2
0
 /// <summary>
 /// Creates a new instance of the PathReconstructer
 /// </summary>
 /// <param name="graph">The RoadGraph object with the road network that will be used in the reconstruction process</param>
 public PathReconstructer(RoadGraph graph)
 {
     _pathfinder = new AstarPathfinder(graph);
 }
Esempio n. 3
0
 /// <summary>
 /// Create a new instance of the STMatching class
 /// </summary>
 /// <param name="graph">The RoadGraph object that represents road network</param>
 public TMM(RoadGraph graph)
 {
     _graph       = graph;
     _pathfinder  = new AstarPathfinder(_graph);
     _trackCutout = new List <ConnectionGeometry>();
 }
Esempio n. 4
0
        static void Main(string[] args)
        {
            DateTime span = DateTime.Now;

            string osmPath        = "";
            string gpxPath        = "";
            string xmlPath        = "";
            string outputPath     = ".";
            int    samplingPeriod = 0;
            bool   showHelp       = false;
            bool   filter         = false;

            OptionSet parameters = new OptionSet()
            {
                { "osm=", "path to the routable map file", v => osmPath = v },
                { "gpx=", "path to the GPX file to process or to the directory to process", v => gpxPath = v },
                { "xml=", "path to the XML file with the time buckets", v => xmlPath = v },
                { "o|output=", "path to the output directory", v => outputPath = v },
                { "p|period=", "sampling period of the GPX file", v => samplingPeriod = int.Parse(v) },
                { "f|filter", "enables output post processing", v => filter = v != null },
                { "h|?|help", v => showHelp = v != null },
            };

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


            if (showHelp || string.IsNullOrEmpty(osmPath) || string.IsNullOrEmpty(gpxPath) || string.IsNullOrEmpty(xmlPath) || string.IsNullOrEmpty(outputPath))
            {
                ShowHelp(parameters);
                return;
            }


            if (outputPath[outputPath.Length - 1] == '"')
            {
                outputPath = outputPath.Substring(0, outputPath.Length - 1);
            }


            Console.Write("Loading OSM file ...");
            OSMDB map = new OSMDB();

            map.Load(osmPath);
            Console.WriteLine("\t\t\tDone.");

            Console.Write("Building routable road graph ...");
            RoadGraph graph = new RoadGraph();

            graph.Build(map);
            Console.WriteLine("\tDone.");

            TMM processor = new TMM(graph)
            {
                _db = map
            };
            PathReconstructer reconstructor = new PathReconstructer(graph)
            {
                _db = map
            };

            XMLDocument xml = new XMLDocument();

            xml.Load(xmlPath);
            var buckets = xml.Buckets;

            // Process single file
            if (File.Exists(gpxPath))
            {
                List <GPXTrack> result = new List <GPXTrack>();
                result.AddRange(getAllGpxTrackList(gpxPath));

                ProcessGPXFile(gpxPath, processor, reconstructor, outputPath, samplingPeriod, filter, buckets);
                GenerateOsmFiles(buckets, reconstructor, map, result);
                GenerateGpxFiles(buckets, gpxPath, 0);
            }
            // Process all GPX in directory
            else if (Directory.Exists(gpxPath))
            {
                var             files  = Directory.GetFiles(gpxPath, "*.gpx");
                List <GPXTrack> result = new List <GPXTrack>();

                Console.WriteLine("Found {0} GPX file(s).", files.Length);

                for (int i = 0; i < files.Length; i++)
                {
                    ProcessGPXFile(files[i], processor, reconstructor, outputPath, samplingPeriod, filter, buckets);
                    GenerateGpxFiles(buckets, gpxPath, i);
                    result.AddRange(getAllGpxTrackList(files[i]));

                    Console.WriteLine("NEW FILE BEING PROCESSED");
                }

                GenerateOsmFiles(buckets, reconstructor, map, result);
            }
            else
            {
                Console.WriteLine("No GPX files found");
            }

            Console.WriteLine("\tDone.");
            Console.WriteLine("\tSpan=" + (DateTime.Now - span));
        }