當前位置: 首頁>>代碼示例>>C#>>正文


C# Streams.XmlOsmStreamSource類代碼示例

本文整理匯總了C#中OsmSharp.Osm.Xml.Streams.XmlOsmStreamSource的典型用法代碼示例。如果您正苦於以下問題:C# XmlOsmStreamSource類的具體用法?C# XmlOsmStreamSource怎麽用?C# XmlOsmStreamSource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XmlOsmStreamSource類屬於OsmSharp.Osm.Xml.Streams命名空間,在下文中一共展示了XmlOsmStreamSource類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BuildRouter

        /// <summary>
        /// Returns a new router.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="embeddedName"></param>
        /// <param name="contract"></param>
        /// <returns></returns>
        public override Router BuildRouter(IOsmRoutingInterpreter interpreter, string embeddedName, bool contract)
        {
            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 CHEdgeGraphOsmStreamTarget(
                    data, interpreter, tagsIndex, Vehicle.Car);
                var dataProcessorSource = new XmlOsmStreamSource(
                    Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format(
                    "OsmSharp.Test.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());
                preProcessor.Start();

                _data[embeddedName] = data;
            }
            return Router.CreateCHFrom(data, new CHRouter(), interpreter);
        }
開發者ID:jboneng,項目名稱:OsmSharp,代碼行數:40,代碼來源:CHSparseComparisonTests.cs

示例2: BuildRouter

        /// <summary>
        /// Returns a new router.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="embeddedName"></param>
        /// <returns></returns>
        public override Router BuildRouter(IOsmRoutingInterpreter interpreter, string embeddedName)
        {
            if (_data == null)
            {
                _data = new Dictionary<string, RouterDataSource<CHEdgeData>>();
            }
            RouterDataSource<CHEdgeData> data = null;
            if (!_data.TryGetValue(embeddedName, out data))
            {
                var tagsIndex = new TagsIndex();

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

                _data[embeddedName] = data;
            }
            return Router.CreateCHFrom(data, new CHRouter(), interpreter);
        }
開發者ID:ryfx,項目名稱:OsmSharp,代碼行數:33,代碼來源:CHEdgeDifferenceComparisonTests.cs

示例3: RoutingRegressionTest1

        public void RoutingRegressionTest1()
        {
            var interpreter = new OsmRoutingInterpreter();
            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("OsmSharp.Test.Unittests.test_routing_regression1.osm"));
            var sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            var basicRouter = new Dykstra();
            var router = Router.CreateLiveFrom(memoryData, basicRouter, interpreter);

            // resolve the three points in question.
            var point35 = new GeoCoordinate(51.01257, 4.000753);
            var point35resolved = router.Resolve(Vehicle.Car, point35);
            var point45 = new GeoCoordinate(51.01315, 3.999588);
            var point45resolved = router.Resolve(Vehicle.Car, point45);

            // route between 35 and 45.
            var routebefore = router.Calculate(Vehicle.Car, point35resolved, point45resolved);

            // route between 35 and 45.
            var routeafter = router.Calculate(Vehicle.Car, point35resolved, point45resolved);
            Assert.AreEqual(routebefore.TotalDistance, routeafter.TotalDistance);
        }
開發者ID:OpenMaps,項目名稱:OsmSharp,代碼行數:31,代碼來源:RoutingRegressionTests.cs

示例4: BuildRouter

        /// <summary>
        /// Returns a new router.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="embeddedName"></param>
        /// <param name="contract"></param>
        /// <returns></returns>
        public override Router BuildRouter(IOsmRoutingInterpreter interpreter, string embeddedName, bool contract)
        {
            if (_data == null)
            {
                _data = new Dictionary<string, DynamicGraphRouterDataSource<LiveEdge>>();
            }
            DynamicGraphRouterDataSource<LiveEdge> data = null;
            if (!_data.TryGetValue(embeddedName, out data))
            {
                var tagsIndex = new TagsTableCollectionIndex();

                // do the data processing.
                data = new DynamicGraphRouterDataSource<LiveEdge>(tagsIndex);
                var targetData = new LiveGraphOsmStreamTarget(
                    data, interpreter, tagsIndex, new Vehicle[] { Vehicle.Car }, false);
                var dataProcessorSource = new XmlOsmStreamSource(
                    Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format(
                    "OsmSharp.Test.Unittests.{0}", embeddedName)));
                var sorter = new OsmStreamFilterSort();
                sorter.RegisterSource(dataProcessorSource);
                targetData.RegisterSource(sorter);
                targetData.Pull();

                _data[embeddedName] = data;
            }
            return Router.CreateLiveFrom(data, new Dykstra(), interpreter);
        }
開發者ID:OpenMaps,項目名稱:OsmSharp,代碼行數:34,代碼來源:LiveEdgeRoutingComparisonTests.cs

示例5: GetHighways

 public async Task<List<CompleteWay>> GetHighways(LatLng northEast, LatLng southWest)
 {
     var boundsString = string.Join(",", southWest.lat, southWest.lng, northEast.lat, northEast.lng);
     var address = $"{OVERPASS_INTERPRETER_ADDRESS}?data=(way[\"highway\"]({boundsString});>;);out;";
     using (var client = new HttpClient())
     {
         var response = await client.GetAsync(address);
         var source = new XmlOsmStreamSource(await response.Content.ReadAsStreamAsync());
         var completeSource = new OsmSimpleCompleteStreamSource(source);
         return completeSource.OfType<CompleteWay>().ToList();
     }
 }
開發者ID:IsraelHikingMap,項目名稱:Site,代碼行數:12,代碼來源:OverpassGateway.cs

示例6: FixtureSetUp

        public void FixtureSetUp()
        {
            // Arrange
            const string connectionString = @"Server=TestDataWindows\SQLEXPRESS;Database=osmsharp;User Id=osmsharp;Password=osmsharp;";

            var sqlConnection = new SqlConnection(connectionString);
            sqlConnection.Open();

            var source = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Data.Test.Unittests.SQLServer.Data.ukraine1.osm"));
            //var source = new PBFDataProcessorSource(new FileInfo("C:\\great-britain-latest.osm.pbf").OpenRead());

            // Act
            _testTarget = new SQLServerDDLChecksStreamTarget(connectionString);
            _testTarget.RegisterSource(source);
            _testTarget.Pull();
        }
開發者ID:UnifyKit,項目名稱:OsmSharp,代碼行數:17,代碼來源:SQLServerDDLChecks.cs

示例7: BuildRouter

        /// <summary>
        /// Returns a new router.
        /// </summary>
        /// <returns></returns>
        public override Router BuildRouter(IOsmRoutingInterpreter interpreter, string embeddedName)
        {
            var tagsIndex = new TagsIndex();

            // do the data processing.
            var data = new RouterDataSource<Edge>(new Graph<Edge>(), tagsIndex);
            var targetData = new GraphOsmStreamTarget(
                data, interpreter, tagsIndex, new Vehicle[] { Vehicle.Car }, false);
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format(
                "OsmSharp.Routing.Test.data.{0}", embeddedName)));
            var sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            return Router.CreateFrom(data, new Dykstra(), interpreter);
        }
開發者ID:cmberryau,項目名稱:routing,代碼行數:22,代碼來源:RoutingComparisonTests.cs

示例8: CreateRouter

        /// <summary>
        /// Creates a router.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="manifestResourceName"></param>
        /// <returns></returns>
        protected override Router CreateRouter(IOsmRoutingInterpreter interpreter, string manifestResourceName)
        {
            TagsIndex tagsIndex = new TagsIndex();

            // do the data processing.
            var memoryData =
                new RouterDataSource<Edge>(new Graph<Edge>(), tagsIndex);
            var targetData = new GraphOsmStreamTarget(
                memoryData, interpreter, tagsIndex, null, false);
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(manifestResourceName));
            var sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(dataProcessorSource);
            targetData.RegisterSource(sorter);
            targetData.Pull();

            IRoutingAlgorithm<Edge> basicRouter = new Dykstra();
            return Router.CreateFrom(memoryData, basicRouter, interpreter);
        }
開發者ID:cmberryau,項目名稱:routing,代碼行數:25,代碼來源:InstructionRegressionTestsDykstraLive.cs

示例9: CreateRouter

        /// <summary>
        /// Creates a router.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="manifestResourceName"></param>
        /// <returns></returns>
        protected override Router CreateRouter(IOsmRoutingInterpreter interpreter, string manifestResourceName)
        {
            SimpleTagsIndex tagsIndex = new SimpleTagsIndex();

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

            IBasicRouter<LiveEdge> basicRouter = new DykstraRoutingLive(memoryData.TagsIndex);
            return Router.CreateLiveFrom(memoryData, basicRouter, interpreter);
        }
開發者ID:robert-hickey,項目名稱:OsmSharp,代碼行數:25,代碼來源:InstructionRegressionTestsDykstraLive.cs

示例10: BuildDykstraDataSource

        /// <summary>
        /// Builds a raw data source.
        /// </summary>
        /// <returns></returns>
        public DynamicGraphRouterDataSource<LiveEdge> BuildDykstraDataSource(
            IOsmRoutingInterpreter interpreter, string embeddedName)
        {
            var tagsIndex = new SimpleTagsIndex();

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

            return data;
        }
開發者ID:robert-hickey,項目名稱:OsmSharp,代碼行數:23,代碼來源:RoutingComparisonTests.cs

示例11: Main

        static void Main(string[] args)
        {
            // query to find all bicyle stations within the city of Antwerp.
            var query = "node(51.18881185379808,4.370841979980469,51.244939510768184,4.454612731933594)[\"amenity\"=\"bicycle_rental\"];out;";

            // create and execute the webrequest.
            var request = WebRequest.Create(
                "http://overpass.osm.rambler.ru/cgi/interpreter?data=" + query);
            request.Method = "GET";
            var requestStream = request.GetResponse().GetResponseStream(); // get the data.

            // use an XML data processor source.
            var source = new XmlOsmStreamSource(requestStream);

            // pull the data from the stream and deserialize XML.
            var osmEntities = new List<OsmGeo>(source);
            var outputCsv = new List<string[]>();
            for(int idx = 0; idx < osmEntities.Count; idx++)
            {
                var node = osmEntities[idx] as Node;
                var refId = string.Empty;
                var name = string.Empty;
                if (node != null &&
                    node.Tags.TryGetValue("ref", out refId) &&
                    node.Tags.TryGetValue("name", out name))
                {
                    var latitude = node.Coordinate.Latitude;
                    var longitude = node.Coordinate.Longitude;

                    outputCsv.Add(new string[] { latitude.ToInvariantString(), longitude.ToInvariantString(), refId, name });
                }
                if (!node.Tags.TryGetValue("ref", out refId))
                {
                    Console.WriteLine("Node {0} has no ref.", node.Id.Value);
                }
                if (!node.Tags.TryGetValue("name", out name))
                {
                    Console.WriteLine("Node {0} has no name.", node.Id.Value);
                }
            }
            OsmSharp.IO.DelimitedFiles.DelimitedFileHandler.WriteDelimitedFile(null, outputCsv.ToArray(),
                new StreamWriter(new FileInfo("bicylestations.csv").OpenWrite()), OsmSharp.IO.DelimitedFiles.DelimiterType.DotCommaSeperated);
        }
開發者ID:nagyistoce,項目名稱:OsmSharp-samples,代碼行數:43,代碼來源:Program.cs

示例12: XmlDataProcessorSourceReset

        public void XmlDataProcessorSourceReset()
        {
            // generate the source.
            var source = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(
                    "OsmSharp.Test.Unittests.api.osm"));

            // pull the data out.
            var target = new OsmStreamTargetEmpty();
            target.RegisterSource(source);
            target.Pull();

            // reset the source.
            if (source.CanReset)
            {
                source.Reset();

                // pull the data again.
                target.Pull();
            }
        }
開發者ID:robert-hickey,項目名稱:OsmSharp,代碼行數:21,代碼來源:XmlDataProcessorSourceTests.cs

示例13: RoutingRegressionTest1

        public void RoutingRegressionTest1()
        {
            OsmRoutingInterpreter interpreter = new OsmRoutingInterpreter();

            SimpleTagsIndex tags_index = new SimpleTagsIndex();

            // do the data processing.
            DynamicGraphRouterDataSource<LiveEdge> memory_data =
                new DynamicGraphRouterDataSource<LiveEdge>(tags_index);
            LiveGraphOsmStreamTarget target_data = new LiveGraphOsmStreamTarget(
                memory_data, interpreter, memory_data.TagsIndex);
            XmlOsmStreamSource data_processor_source = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.Test.Unittests.test_routing_regression1.osm"));
            OsmStreamFilterSort sorter = new OsmStreamFilterSort();
            sorter.RegisterSource(data_processor_source);
            target_data.RegisterSource(sorter);
            target_data.Pull();

            IBasicRouter<LiveEdge> basic_router = new DykstraRoutingLive(memory_data.TagsIndex);
            Router router = Router.CreateLiveFrom(memory_data, basic_router, interpreter);

            // resolve the three points in question.
            GeoCoordinate point35 = new GeoCoordinate(51.01257, 4.000753);
            RouterPoint point35resolved = router.Resolve(Vehicle.Car, point35);
            //            GeoCoordinate point40 = new GeoCoordinate(51.01250, 4.000013);
            //            RouterPoint point40resolved = router.Resolve(Vehicle.Car, point40);
            GeoCoordinate point45 = new GeoCoordinate(51.01315, 3.999588);
            RouterPoint point45resolved = router.Resolve(Vehicle.Car, point45);

            // route between 35 and 45.
            Route routebefore = router.Calculate(Vehicle.Car, point35resolved, point45resolved);

            //            GeoCoordinate point129 = new GeoCoordinate(51.01239, 3.999573);
            //            RouterPoint point129resolved = router.Resolve(Vehicle.Car, point129);

            // route between 35 and 45.
            Route routeafter = router.Calculate(Vehicle.Car, point35resolved, point45resolved);
            Assert.AreEqual(routebefore.TotalDistance, routeafter.TotalDistance);
        }
開發者ID:robert-hickey,項目名稱:OsmSharp,代碼行數:39,代碼來源:RoutingRegressionTests.cs

示例14: CreateRouter

        /// <summary>
        /// Creates a router.
        /// </summary>
        /// <param name="interpreter"></param>
        /// <param name="manifestResourceName"></param>
        /// <returns></returns>
        protected override Router CreateRouter(IOsmRoutingInterpreter interpreter, string manifestResourceName)
        {
            TagsIndex tagsIndex = new TagsIndex();

            // do the data processing.
            var data = new RouterDataSource<CHEdgeData>(new DirectedGraph<CHEdgeData>(), tagsIndex);
            var targetData = new CHEdgeGraphOsmStreamTarget(
                data, interpreter, tagsIndex, Vehicle.Car);
            var dataProcessorSource = new XmlOsmStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(manifestResourceName));
            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(data,
                new EdgeDifferenceContractedSearchSpace(data, witnessCalculator), witnessCalculator);
            preProcessor.Start();

            return Router.CreateCHFrom(data, new CHRouter(), interpreter);
        }
開發者ID:cmberryau,項目名稱:routing,代碼行數:29,代碼來源:InstructionRegressionTestsCH.cs

示例15: GetHighwaysAroundATrace

        public async Task<List<CompleteWay>> GetHighwaysAroundATrace(IEnumerable<Coordinate> coordinates)
        {
            var overpassQueryPostfix = @"way[highway](bn)-> .w;
                                        node(w.w)-> .n;
                                        (node._.n; way.w);
                                        out qt; ";
            var overpassQueryNodes = "";
            foreach (var coordinate in coordinates)
            {
                // lat, lng
                overpassQueryNodes += $"(._; node(around: 300, {coordinate.Y}, {coordinate.X}););\n";
            }

            using (var client = new HttpClient())
            {
                var response = await client.PostAsync(OVERPASS_INTERPRETER_ADDRESS, new StringContent(overpassQueryNodes + overpassQueryPostfix));
                Trace.WriteLine(await response.Content.ReadAsStringAsync());
                var source = new XmlOsmStreamSource(await response.Content.ReadAsStreamAsync());
                var cache = new OsmDataCacheMemory();
                var completeSource = new OsmSimpleCompleteStreamSource(source, cache);
                var list = completeSource.OfType<CompleteWay>().ToList();
                return list;
            }
        }
開發者ID:IsraelHikingMap,項目名稱:Site,代碼行數:24,代碼來源:OverpassGateway.cs


注:本文中的OsmSharp.Osm.Xml.Streams.XmlOsmStreamSource類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。