Exemple #1
0
        static void ProcessGPXFile(string path, STMatching processor, PathReconstructer reconstructor, string outputPath, int samplingPeriod, bool filterOutput)
        {
            GPXUtils.Filters.FrequencyFilter filter = new GPXUtils.Filters.FrequencyFilter();

            Console.Write("Loading {0} ...", Path.GetFileName(path));
            GPXDocument gpx = new GPXDocument();

            gpx.Load(path);

            Console.WriteLine("[{0} track(s); {1} segment(s)]", gpx.Tracks.Count, gpx.Tracks.Sum(track => track.Segments.Count));
            for (int trackIndex = 0; trackIndex < gpx.Tracks.Count; trackIndex++)
            {
                for (int segmentIndex = 0; segmentIndex < gpx.Tracks[trackIndex].Segments.Count; segmentIndex++)
                {
                    string name = string.IsNullOrEmpty(gpx.Tracks[trackIndex].Name) ? "t" + trackIndex.ToString() : gpx.Tracks[trackIndex].Name.Replace('\\', '-').Replace(":", "");
                    name += "_s" + segmentIndex.ToString();
                    Console.Write("\t" + name + " ");

                    try {
                        GPXTrackSegment toProcess = gpx.Tracks[trackIndex].Segments[segmentIndex];
                        if (samplingPeriod > 0)
                        {
                            toProcess = filter.Filter(new TimeSpan(0, 0, samplingPeriod), toProcess);
                        }

                        var result = processor.Match(toProcess);
                        Console.Write(".");

                        var reconstructedPath = reconstructor.Reconstruct(result);
                        Console.Write(".");

                        if (filterOutput)
                        {
                            reconstructor.FilterUturns(reconstructedPath, 100);
                        }
                        var pathOsm = reconstructor.SaveToOSM(reconstructedPath);

                        pathOsm.Save(Path.Combine(outputPath, Path.GetFileNameWithoutExtension(path) + "_" + name + ".osm"));
                        Console.WriteLine(".");
                    }
                    catch (Exception e) {
                        Console.WriteLine("Error: " + e.Message);
                    }
                }
            }
        }
Exemple #2
0
        static void ProcessGPXFile(string path, STMatching processor, PathReconstructer reconstructor, string outputPath, int samplingPeriod, bool filterOutput)
        {
            GPXUtils.Filters.FrequencyFilter filter = new GPXUtils.Filters.FrequencyFilter();

            Console.Write("Loading {0} ...", Path.GetFileName(path));
            GPXDocument gpx = new GPXDocument();
            gpx.Load(path);

            Console.WriteLine("[{0} track(s); {1} segment(s)]", gpx.Tracks.Count, gpx.Tracks.Sum(track => track.Segments.Count));
            for (int trackIndex = 0; trackIndex < gpx.Tracks.Count; trackIndex++) {
                for (int segmentIndex = 0; segmentIndex < gpx.Tracks[trackIndex].Segments.Count; segmentIndex++) {
                    string name = string.IsNullOrEmpty(gpx.Tracks[trackIndex].Name) ? "t" + trackIndex.ToString() : gpx.Tracks[trackIndex].Name.Replace('\\', '-').Replace(":","");
                    name += "_s" + segmentIndex.ToString();
                    Console.Write("\t" + name + " ");

                    try {
                        GPXTrackSegment toProcess = gpx.Tracks[trackIndex].Segments[segmentIndex];
                        if (samplingPeriod > 0)
                            toProcess = filter.Filter(new TimeSpan(0, 0, samplingPeriod), toProcess);

                        var result = processor.Match(toProcess);
                        Console.Write(".");

                        var reconstructedPath = reconstructor.Reconstruct(result);
                        Console.Write(".");

                        if (filterOutput) {
                            reconstructor.FilterUturns(reconstructedPath, 100);
                        }
                        var pathOsm = reconstructor.SaveToOSM(reconstructedPath);

                        pathOsm.Save(Path.Combine(outputPath, Path.GetFileNameWithoutExtension(path) + "_" + name + ".osm"));
                        Console.WriteLine(".");
                    }
                    catch (Exception e) {
                        Console.WriteLine("Error: " + e.Message);
                    }
                }
            }
        }
Exemple #3
0
        static void ProcessGPXFile(string path, TMM processor, PathReconstructer reconstructor, string outputPath, int samplingPeriod,
                                   bool filterOutput, List <Bucket> buckets)
        {
            GPXUtils.Filters.FrequencyFilter filter = new GPXUtils.Filters.FrequencyFilter();

            Console.Write("Loading {0} ...", Path.GetFileName(path));
            GPXDocument gpx = new GPXDocument();

            gpx.Load(path);

            Console.WriteLine("[{0} track(s); {1} segment(s)]", gpx.Tracks.Count, gpx.Tracks.Sum(track => track.Segments.Count));
            for (int trackIndex = 0; trackIndex < gpx.Tracks.Count; trackIndex++)
            {
                Console.WriteLine(gpx.Tracks[trackIndex].Name);

                for (int segmentIndex = 0; segmentIndex < gpx.Tracks[trackIndex].Segments.Count; segmentIndex++)
                {
                    string name = string.IsNullOrEmpty(gpx.Tracks[trackIndex].Name) ? "t" + trackIndex.ToString() : gpx.Tracks[trackIndex].Name.Replace('\\', '-').Replace(":", "");
                    name += "_s" + segmentIndex.ToString();
                    Console.Write("\t" + name + " ");

                    try
                    {
                        GPXTrackSegment toProcess = gpx.Tracks[trackIndex].Segments[segmentIndex];

                        if (samplingPeriod > 0)
                        {
                            toProcess = filter.Filter(new TimeSpan(0, 0, samplingPeriod), toProcess);
                        }

                        if (toProcess.NodesCount > 1)
                        {
                            var result = processor.Match(toProcess);
                            Console.Write(".");

                            var reconstructedPath = reconstructor.Reconstruct(result);

                            Console.Write(".");

                            if (filterOutput)
                            {
                                reconstructor.FilterUturns(reconstructedPath, 100);
                            }

                            Console.WriteLine(".");

                            var trackId = gpx.Tracks[trackIndex].Name.Replace("trk_", "");
                            buckets = GetUpdatedBuckets(toProcess, reconstructedPath, buckets, trackId);
                        }
                        else
                        {
                            throw new Exception(string.Format("Track segment discarded because number of nodes is less than 2."));
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error: " + e.Message);
                    }
                }
            }
        }