Exemplo n.º 1
0
        /// <summary>
        /// Tests preprocessing data from a PBF file.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pbfFile"></param>
        public static void TestPreprocessing(string name, string pbfFile)
        {
            FileInfo testFile = new FileInfo(string.Format(@".\TestFiles\{0}", pbfFile));
            Stream stream = testFile.OpenRead();
            var progress = new OsmStreamFilterProgress();
            progress.RegisterSource(new PBFOsmStreamSource(stream));

            var performanceInfo = new PerformanceInfoConsumer("LivePreProcessor", 20000);
            performanceInfo.Start();
            performanceInfo.Report("Pulling from {0}...", testFile.Name);

            var tagsIndex = new TagsTableCollectionIndex(); // creates a tagged index.

            // read from the OSM-stream.
            // var memoryGraph = new MemoryMappedGraph<LiveEdge>(1000000, @"c:\temp\");
            var memoryData = new DynamicGraphRouterDataSource<LiveEdge>(tagsIndex);
            var targetData = new LiveGraphOsmStreamTarget(memoryData, new OsmRoutingInterpreter(), tagsIndex);
            targetData.RegisterSource(progress);
            targetData.Pull();

            stream.Dispose();

            performanceInfo.Stop();
            // make sure the router is still here after GC to note the memory difference.
            OsmSharp.Logging.Log.TraceEvent("LivePreProcessor", Logging.TraceEventType.Information, memoryData.ToString());
            memoryData = null;

            GC.Collect();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Tests preprocessing data from a PBF file.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pbfFile"></param>
        public static void TestPreprocessing(string name, string pbfFile)
        {
            FileInfo testFile = new FileInfo(string.Format(@".\TestFiles\{0}", pbfFile));
            Stream   stream   = testFile.OpenRead();
            var      progress = new OsmStreamFilterProgress();

            progress.RegisterSource(new PBFOsmStreamSource(stream));

            var performanceInfo = new PerformanceInfoConsumer("LivePreProcessor", 20000);

            performanceInfo.Start();
            performanceInfo.Report("Pulling from {0}...", testFile.Name);

            var tagsIndex = new TagsTableCollectionIndex(); // creates a tagged index.

            // read from the OSM-stream.
            var memoryGraph = new MemoryMappedFileDynamicGraph <LiveEdge>(1000000, @"c:\temp\");
            var memoryData  = new DynamicGraphRouterDataSource <LiveEdge>(memoryGraph, tagsIndex);
            var targetData  = new LiveGraphOsmStreamTarget(memoryData, new OsmRoutingInterpreter(), tagsIndex);

            targetData.RegisterSource(progress);
            targetData.Pull();

            stream.Dispose();

            performanceInfo.Stop();
            // make sure the router is still here after GC to note the memory difference.
            OsmSharp.Logging.Log.TraceEvent("LivePreProcessor", Logging.TraceEventType.Information, memoryData.ToString());
            memoryData = null;

            GC.Collect();
        }