Exemple #1
0
        /// <summary>
        /// Builds the data.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="embeddedString"></param>
        /// <returns></returns>
        public override IBasicRouterDataSource <CHEdgeData> BuildData(IRoutingInterpreter interpreter,
                                                                      string embeddedString)
        {
            string key = string.Format("CHEdgeDifference.Routing.IBasicRouterDataSource<CHEdgeData>.OSM.{0}",
                                       embeddedString);
            var data = StaticDictionary.Get <IBasicRouterDataSource <CHEdgeData> >(
                key);

            if (data == null)
            {
                var tagsIndex = new SimpleTagsIndex();

                // do the data processing.
                var memoryData = new DynamicGraphRouterDataSource <CHEdgeData>(tagsIndex);
                var targetData = new CHEdgeGraphOsmStreamWriter(
                    memoryData, interpreter, memoryData.TagsIndex, Vehicle.Car);
                var dataProcessorSource = new XmlOsmStreamSource(
                    Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedString));
                var sorter = new OsmStreamFilterSort();
                sorter.RegisterSource(dataProcessorSource);
                targetData.RegisterSource(sorter);
                targetData.Pull();

                // do the pre-processing part.
                var witnessCalculator = new DykstraWitnessCalculator(memoryData);
                var preProcessor      = new CHPreProcessor(memoryData,
                                                           new EdgeDifference(memoryData, witnessCalculator), witnessCalculator);
                preProcessor.Start();

                data = memoryData;
                StaticDictionary.Add <IBasicRouterDataSource <CHEdgeData> >(key, data);
            }
            return(data);
        }
Exemple #2
0
        /// <summary>
        /// Returns a new router.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="embeddedName"></param>
        /// <returns></returns>
        public override Router BuildRouter(IRoutingInterpreter interpreter, string embeddedName)
        {
            if (_data == null)
            {
                _data = new Dictionary <string, DynamicGraphRouterDataSource <CHEdgeData> >();
            }
            DynamicGraphRouterDataSource <CHEdgeData> data = null;

            if (!_data.TryGetValue(embeddedName, out data))
            {
                var tagsIndex = new SimpleTagsIndex();

                // do the data processing.
                data =
                    new DynamicGraphRouterDataSource <CHEdgeData>(tagsIndex);
                var targetData = new CHEdgeGraphOsmStreamWriter(
                    data, interpreter, data.TagsIndex, Vehicle.Car);
                var dataProcessorSource = new XmlOsmStreamSource(
                    Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format(
                                                                                  "OsmSharp.UnitTests.{0}", embeddedName)));
                var sorter = new OsmStreamFilterSort();
                sorter.RegisterSource(dataProcessorSource);
                targetData.RegisterSource(sorter);
                targetData.Pull();

                // do the pre-processing part.
                var preProcessor = new CHPreProcessor(data,
                                                      new SparseOrdering(data), new DykstraWitnessCalculator(data));
                preProcessor.Start();

                _data[embeddedName] = data;
            }
            return(Router.CreateCHFrom(data, new CHRouter(
                                           data), interpreter));
        }
        /// <summary>
        /// Executes the CH contractions while verifying each step.
        /// </summary>
        /// <param name="stream"></param>
        public void DoTestCHSparseVerifiedContraction(Stream stream)
        {
            _interpreter = new OsmRoutingInterpreter();

            var tagsIndex = new SimpleTagsIndex();

            // do the data processing.
            _data = new DynamicGraphRouterDataSource <CHEdgeData>(tagsIndex);
            var targetData = new CHEdgeGraphOsmStreamWriter(
                _data, _interpreter, _data.TagsIndex, Vehicle.Car);
            var dataProcessorSource = new XmlOsmStreamSource(stream);
            var sorter = new OsmStreamFilterSort();

            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            // do the pre-processing part.
            //INodeWitnessCalculator witness_calculator = new CHRouterWitnessCalculator(_data);
            INodeWitnessCalculator witnessCalculator = new DykstraWitnessCalculator(_data);
            var preProcessor = new CHPreProcessor(_data,
                                                  new EdgeDifferenceContractedSearchSpace(_data, witnessCalculator), witnessCalculator);

            preProcessor.OnBeforeContractionEvent += new CHPreProcessor.VertexDelegate(pre_processor_OnBeforeContractionEvent);
            preProcessor.OnAfterContractionEvent  += new CHPreProcessor.VertexDelegate(pre_processor_OnAfterContractionEvent);
            preProcessor.Start();
        }
Exemple #4
0
        /// <summary>
        /// Builds the data.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="embeddedString"></param>
        /// <returns></returns>
        public override IBasicRouterDataSource <CHEdgeData> BuildData(IRoutingInterpreter interpreter,
                                                                      string embeddedString)
        {
            var tagsIndex = new SimpleTagsIndex();

            // do the data processing.
            var memoryData = new DynamicGraphRouterDataSource <CHEdgeData>(tagsIndex);
            var targetData = new CHEdgeGraphOsmStreamWriter(
                memoryData, interpreter, memoryData.TagsIndex, Vehicle.Car);
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedString));
            var sorter = new OsmStreamFilterSort();

            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            // do the pre-processing part.
            var preProcessor = new CHPreProcessor(memoryData,
                                                  new SparseOrdering(memoryData), new DykstraWitnessCalculator(memoryData));

            preProcessor.Start();

            return(memoryData);
        }
Exemple #5
0
        /// <summary>
        /// Builds an in-memory data source from an xml data stream.
        /// </summary>
        /// <param name="stream"></param>
        /// <returns></returns>
        private DynamicGraphRouterDataSource <CHEdgeData> BuildData(Stream stream)
        {
            var interpreter = new OsmRoutingInterpreter();
            var tagsIndex   = new SimpleTagsIndex();

            // do the data processing.
            var data       = new DynamicGraphRouterDataSource <CHEdgeData>(tagsIndex);
            var targetData = new CHEdgeGraphOsmStreamWriter(
                data, interpreter, data.TagsIndex, Vehicle.Car);
            var dataProcessorSource = new XmlOsmStreamSource(stream);
            var sorter = new OsmStreamFilterSort();

            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            return(data);
        }
Exemple #6
0
        /// <summary>
        /// Builds the data source.
        /// </summary>
        /// <returns></returns>
        private DynamicGraphRouterDataSource <CHEdgeData> BuildData(IRoutingInterpreter interpreter)
        {
            DynamicGraphRouterDataSource <CHEdgeData> data = null;

            if (data == null)
            {
                var tagsIndex = new SimpleTagsIndex();

                // do the data processing.
                data = new DynamicGraphRouterDataSource <CHEdgeData>(tagsIndex);
                var targetData = new CHEdgeGraphOsmStreamWriter(
                    data, interpreter, data.TagsIndex, Vehicle.Car);
                var dataProcessorSource = new XmlOsmStreamSource(
                    Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.UnitTests.test_network.osm"));
                var sorter = new OsmStreamFilterSort();
                sorter.RegisterSource(dataProcessorSource);
                targetData.RegisterSource(sorter);
                targetData.Pull();
            }
            return(data);
        }