当前位置: 首页>>代码示例>>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;未经允许,请勿转载。