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

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

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

                data = memoryData;
                StaticDictionary.Add <IRoutingAlgorithmData <CHEdgeData> >(key, data);
            }
            return(data);
        }
示例#2
0
        /// <summary>
        /// Builds data source.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="embeddedString"></param>
        /// <returns></returns>
        public override IBasicRouterDataSource <LiveEdge> BuildData(IOsmRoutingInterpreter interpreter,
                                                                    string embeddedString)
        {
            string key = string.Format("Dykstra.Routing.IBasicRouterDataSource<SimpleWeighedEdge>.OSM.{0}",
                                       embeddedString);
            var data = StaticDictionary.Get <IBasicRouterDataSource <LiveEdge> >(
                key);

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

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

                data = memoryData;
                StaticDictionary.Add <IBasicRouterDataSource <LiveEdge> >(key,
                                                                          data);
            }
            return(data);
        }
        /// <summary>
        /// Builds the data.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="embeddedString"></param>
        /// <returns></returns>
        public override IBasicRouterDataSource <CHEdgeData> BuildData(IOsmRoutingInterpreter 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 TagsTableCollectionIndex();

                // do the data processing.
                var memoryData = new DynamicGraphRouterDataSource <CHEdgeData>(tagsIndex);
                var targetData = new CHEdgeGraphOsmStreamTarget(
                    memoryData, interpreter, 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();
                var preProcessor      = new CHPreProcessor(memoryData,
                                                           new EdgeDifference(memoryData, witnessCalculator), witnessCalculator);
                preProcessor.Start();

                data = memoryData;
                StaticDictionary.Add <IBasicRouterDataSource <CHEdgeData> >(key, data);
            }
            return(data);
        }