当前位置: 首页>>代码示例>>C#>>正文


C# Interpreter.OsmRoutingInterpreter类代码示例

本文整理汇总了C#中OsmSharp.Routing.Osm.Interpreter.OsmRoutingInterpreter的典型用法代码示例。如果您正苦于以下问题:C# OsmRoutingInterpreter类的具体用法?C# OsmRoutingInterpreter怎么用?C# OsmRoutingInterpreter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OsmRoutingInterpreter类属于OsmSharp.Routing.Osm.Interpreter命名空间,在下文中一共展示了OsmRoutingInterpreter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestCHDepthFirstEnumerator

        public void TestCHDepthFirstEnumerator()
        {
            const string embeddedString = "OsmSharp.Test.Unittests.test_network_real1.osm";

            // creates a new interpreter.
            var interpreter = new OsmRoutingInterpreter();

            // do the data processing.
            var original = CHEdgeGraphOsmStreamTarget.Preprocess(new XmlOsmStreamSource(
                                                                   Assembly.GetExecutingAssembly()
                                                                           .GetManifestResourceStream(embeddedString)),
                                                               interpreter,
                                                               Vehicle.Car);
            // add the downward edges.
            original.AddDownwardEdges();

            // enumerate using depth-first search.
            CHDepthFirstEnumerator enumerator =
                new CHDepthFirstEnumerator(original);
            HashSet<uint> vertices = new HashSet<uint>(
                enumerator.Select(x => x.VertexId));
            for (uint vertexId = 1; vertexId < original.VertexCount + 1; vertexId++)
            {
                Assert.IsTrue(vertices.Contains(vertexId));
            }
        }
开发者ID:robert-hickey,项目名称:OsmSharp,代码行数:26,代码来源:CHDepthFirstEnumeratorTests.cs

示例2: 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

示例3: InstructionGenerationAFewTurns

        public void InstructionGenerationAFewTurns()
        {
            // create new interpreter.
            var interpreter = new OsmRoutingInterpreter();

            // create the language generator.
            var languageGenerator = new LanguageTestGenerator();

            // calculate the route.
            OsmSharpRoute route = this.Calculate(
                new GeoCoordinate(51.089900970459, 3.44386267662048),
                new GeoCoordinate(51.0862655639648, 3.44465517997742));

            // generate the instructions.
            var instructionGenerator = new InstructionGenerator();
            List<Instruction> instructions =
                instructionGenerator.Generate(route, interpreter, languageGenerator);

            // test the results in the language generator.
            Assert.AreEqual(6, instructions.Count);
            Assert.AreEqual("GeneratePoi:1", instructions[0].Text);
            Assert.AreEqual("GenerateDirectTurn:0_Right_0", instructions[1].Text);
            Assert.AreEqual("GenerateDirectTurn:0_Left_0", instructions[2].Text);
            Assert.AreEqual("GenerateDirectTurn:0_Left_0", instructions[3].Text);
            Assert.AreEqual("GenerateDirectTurn:0_Right_0", instructions[4].Text);
            Assert.AreEqual("GeneratePoi:1", instructions[5].Text);
        }
开发者ID:jorik041,项目名称:osmsharp,代码行数:27,代码来源:InstructionsGenerationTests.cs

示例4: RoutingSerializationV2CHRoutingComparisonTest

        public void RoutingSerializationV2CHRoutingComparisonTest()
        {
            const string embeddedString = "OsmSharp.Test.Unittests.test_network_real1.osm";

            // creates a new interpreter.
            var interpreter = new OsmRoutingInterpreter();

            // do the data processing.
            var original = CHEdgeGraphOsmStreamTarget.Preprocess(new XmlOsmStreamSource(
                                                                   Assembly.GetExecutingAssembly()
                                                                           .GetManifestResourceStream(embeddedString)),
                                                               interpreter,
                                                               Vehicle.Car);

            // create serializer.
            var routingSerializer = new OsmSharp.Routing.CH.Serialization.Sorted.CHEdgeDataDataSourceSerializer();

            // serialize/deserialize.
            TagsCollectionBase metaData = new TagsCollection();
            metaData.Add("some_key", "some_value");
            byte[] byteArray;
            using (var stream = new MemoryStream())
            {
                try
                {
                    routingSerializer.Serialize(stream, original, metaData);
                    byteArray = stream.ToArray();
                }
                catch (Exception)
                {
                    if (Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }
                    throw;
                }
            }

            IBasicRouterDataSource<CHEdgeData> deserializedVersion =
                routingSerializer.Deserialize(new MemoryStream(byteArray), out metaData);
            Assert.AreEqual(original.TagsIndex.Get(0), deserializedVersion.TagsIndex.Get(0));

            // create reference router.
            original = CHEdgeGraphOsmStreamTarget.Preprocess(new XmlOsmStreamSource(
                                                                   Assembly.GetExecutingAssembly()
                                                                           .GetManifestResourceStream(embeddedString)),
                                                               interpreter,
                                                               Vehicle.Car);
            var basicRouterOriginal = new CHRouter();
            Router referenceRouter = Router.CreateCHFrom(
                original, basicRouterOriginal, interpreter);

            // try to do some routing on the deserialized version.
            var basicRouter = new CHRouter();
            Router router = Router.CreateCHFrom(
                deserializedVersion, basicRouter, interpreter);

            //this.TestCompareAll(original, referenceRouter, router);
        }
开发者ID:kochizufan,项目名称:OsmSharp,代码行数:59,代码来源:RoutingSerializationComparisonTests.cs

示例5: CHEdgeGraphFileStreamTarget

        /// <summary>
        /// 
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="vehicle"></param>
        public CHEdgeGraphFileStreamTarget(Stream stream, Vehicle vehicle)
        {
            _graphStream = stream;

            var tagsIndex = new TagsTableCollectionIndex();
            var interpreter = new OsmRoutingInterpreter();
            _graph = new DynamicGraphRouterDataSource<CHEdgeData>(tagsIndex);
            _graphTarget = new CHEdgeGraphOsmStreamTarget(
                _graph, interpreter, tagsIndex, vehicle);
        }
开发者ID:nubix-biz,项目名称:OsmSharp,代码行数:15,代码来源:CHEdgeGraphFileStreamTarget.cs

示例6: TestSerializedRouting

        /// <summary>
        /// Tests routing from a serialized routing file.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="stream"></param>
        /// <param name="testCount"></param>
        public static void TestSerializedRouting(string name, Stream stream, int testCount)
        {
            var vehicle = Vehicle.Car;

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

            // read from the OSM-stream.
            var reader = new OsmSharp.Osm.PBF.Streams.PBFOsmStreamSource(stream);
            var interpreter = new OsmRoutingInterpreter();
            var data = new DynamicGraphRouterDataSource<LiveEdge>(tagsIndex);
            data.DropVertexIndex();
            var targetData = new LiveGraphOsmStreamTarget(data, interpreter, tagsIndex);
            targetData.RegisterSource(reader);
            targetData.Pull();
            data.RebuildVertexIndex();

            // creates the live edge router.
            var router = new Dykstra();

            var performanceInfo = new PerformanceInfoConsumer("LiveRouting");
            performanceInfo.Start();
            performanceInfo.Report("Routing {0} routes...", testCount);

            var successCount = 0;
            var totalCount = testCount;
            var latestProgress = -1.0f;
            while (testCount > 0)
            {
                var from = (uint)OsmSharp.Math.Random.StaticRandomGenerator.Get().Generate(data.VertexCount - 1) + 1;
                var to = (uint)OsmSharp.Math.Random.StaticRandomGenerator.Get().Generate(data.VertexCount - 1) + 1;

                var route = router.Calculate(data, interpreter, vehicle, from, to);

                if (route != null)
                {
                    successCount++;
                }
                testCount--;

                // report progress.
                var progress = (float)System.Math.Round(((double)(totalCount - testCount) / (double)totalCount) * 100);
                if (progress != latestProgress)
                {
                    OsmSharp.Logging.Log.TraceEvent("LiveRouting", TraceEventType.Information,
                        "Routing... {0}%", progress);
                    latestProgress = progress;
                }
            }
            performanceInfo.Stop();

            OsmSharp.Logging.Log.TraceEvent("LiveRouting", OsmSharp.Logging.TraceEventType.Information,
                string.Format("{0}/{1} routes successfull!", successCount, totalCount));
        }
开发者ID:OpenMaps,项目名称:OsmSharp,代码行数:59,代码来源:LiveRoutingTest.cs

示例7: Engine

        private Engine()
        {
            if (string.IsNullOrWhiteSpace(PbfDataFilePath))
            {
                throw new NullReferenceException("PbfDataFilePath must be set.");
            }

            if (!File.Exists(PbfDataFilePath))
            {
                throw new NullReferenceException("PbfDataFilePath '" + PbfDataFilePath + "' does not exist.");
            }

            // keeps a memory-efficient version of the osm-tags.
            var tagsIndex = new OsmTagsIndex();

            // creates a routing interpreter. (used to translate osm-tags into a routable network)
            var interpreter = new OsmRoutingInterpreter();

            // create a routing datasource, keeps all processed osm routing data.
            var osmData = new MemoryRouterDataSource<SimpleWeighedEdge>(tagsIndex);

            // load data into this routing datasource.
            Stream osmPbfData = new FileInfo(PbfDataFilePath).OpenRead(); // for example moscow!
            using (osmPbfData)
            {
                var targetData = new
                   SimpleWeighedDataGraphProcessingTarget(
                                osmData, interpreter, osmData.TagsIndex, VehicleEnum.Car);

                // replace this with PBFdataProcessSource when having downloaded a PBF file.
                var dataProcessorSource = new
                  PBFDataProcessorSource(osmPbfData);

                // pre-process the data.
                var stopwatch = new Stopwatch();
                stopwatch.Start();

                var sorter = new DataProcessorFilterSort();
                sorter.RegisterSource(dataProcessorSource);
                targetData.RegisterSource(sorter);
                targetData.Pull();

                stopwatch.Stop();
            }

            // create the router object: there all routing functions are available.
            router = new Router<SimpleWeighedEdge>(
                osmData, interpreter, new DykstraRoutingLive(osmData.TagsIndex));
        }
开发者ID:kwilson,项目名称:OsmSharpTests,代码行数:49,代码来源:Engine.cs

示例8: CalculateTSP

        /// <summary>
        /// Calculates the TSP.
        /// </summary>
        /// <param name="dataStream"></param>
        /// <param name="csvStream"></param>
        /// <param name="pbf"></param>
        /// <param name="vehicleEnum"></param>
        /// <returns></returns>
        private Route CalculateTSP(Stream dataStream, Stream csvStream, bool pbf, Vehicle vehicleEnum)
        {
            // create the router.
            OsmRoutingInterpreter interpreter = new OsmRoutingInterpreter();
            Router router = Router.CreateLiveFrom(
                new XmlOsmStreamSource(dataStream), interpreter);

            // read the source files.
            const int latitudeIdx = 2;
            const int longitudeIdx = 3;
            string[][] pointStrings = DelimitedFileHandler.ReadDelimitedFileFromStream(
                csvStream,
                DelimiterType.DotCommaSeperated);
            var points = new List<RouterPoint>();
            int cnt = 10;
            foreach (string[] line in pointStrings)
            {
                if (points.Count >= cnt)
                {
                    break;
                }
                var latitudeString = (string)line[latitudeIdx];
                var longitudeString = (string)line[longitudeIdx];

                //string route_ud = (string)line[1];

                double longitude = 0;
                double latitude = 0;
                if (double.TryParse(longitudeString, System.Globalization.NumberStyles.Any,
                    System.Globalization.CultureInfo.InvariantCulture, out longitude) &&
                   double.TryParse(latitudeString, System.Globalization.NumberStyles.Any,
                    System.Globalization.CultureInfo.InvariantCulture, out latitude))
                {
                    var point = new GeoCoordinate(latitude, longitude);

                    RouterPoint resolved = router.Resolve(Vehicle.Car, point);
                    if (resolved != null && router.CheckConnectivity(Vehicle.Car, resolved, 100))
                    {
                        points.Add(resolved);
                    }
                }
            }

            var tspSolver = new RouterTSPWrapper<RouterTSP>(
                new RouterTSPAEXGenetic(), router, interpreter);
            return tspSolver.CalculateTSP(vehicleEnum, points.ToArray());
        }
开发者ID:robert-hickey,项目名称:OsmSharp,代码行数:55,代码来源:TSPWrapperTest.cs

示例9: TestSerialization

        /// <summary>
        /// Tests preprocessing data from a PBF file.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pbfFile"></param>
        public static void TestSerialization(string name, string pbfFile)
        {
            var testFile = new FileInfo(string.Format(@".\TestFiles\{0}", pbfFile));
            var stream = testFile.OpenRead();
            var source = new OsmSharp.Osm.Streams.Filters.OsmStreamFilterProgress();
            source.RegisterSource(new PBFOsmStreamSource(stream));

            var testOutputFile = new FileInfo(@"test.pedestrian.routing");
            testOutputFile.Delete();
            Stream writeStream = testOutputFile.OpenWrite();

            var tagsIndex = new TagsTableCollectionIndex();
            var interpreter = new OsmRoutingInterpreter();
            var graph = new DynamicGraphRouterDataSource<CHEdgeData>(tagsIndex);

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

            var data = CHEdgeGraphOsmStreamTarget.Preprocess(
                source, new OsmRoutingInterpreter(), Vehicle.Car);

            var metaData = new TagsCollection();
            metaData.Add("some_key", "some_value");
            var routingSerializer = new CHEdgeFlatfileSerializer();
            routingSerializer.Serialize(writeStream, data, metaData);

            stream.Dispose();
            writeStream.Dispose();

            OsmSharp.Logging.Log.TraceEvent("CHSerializerFlatFile", OsmSharp.Logging.TraceEventType.Information,
                string.Format("Serialized file: {0}KB", testOutputFile.Length / 1024));

            performanceInfo.Stop();

            performanceInfo = new PerformanceInfoConsumer("CHSerializerFlatFile.Deserialize");
            performanceInfo.Start();
            performanceInfo.Report("Deserializing again...");

            // open file again and read.
            writeStream = testOutputFile.OpenRead();
            var deserializedGraph = routingSerializer.Deserialize(writeStream);

            performanceInfo.Stop();
        }
开发者ID:kochizufan,项目名称:OsmSharp,代码行数:50,代码来源:CHEdgeGraphFlatFileSerializerTests.cs

示例10: SQLServerRoutingRegressionTests1

        public void SQLServerRoutingRegressionTests1()
        {
            // the connectionstring.
            string connectionString =
                @"Server=windows8-test\sqlexpress;User Id=OsmSharp;Password=OsmSharp;Database=OsmData;";

            // drop whatever data is there.
            SqlConnection sqlConnection = new SqlConnection(connectionString);
            sqlConnection.Open();
            SQLServer.SimpleSchema.SchemaTools.SQLServerSimpleSchemaTools.Remove(sqlConnection);
            sqlConnection.Close();

            // create the source from the osm file.
            var xmlSource = new XmlDataProcessorSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream(
                    "OsmSharp.Osm.Data.SQLServer.Unittests.Data.ukraine1.osm"));

            // create the SQLServer processor target.
            var testTarget = new SQLServerSimpleSchemaDataProcessorTarget(connectionString, true);
            testTarget.RegisterSource(xmlSource); // register the source.
            testTarget.Pull(); // pull the data from source to target.

            var source = new SQLServerSimpleSchemaSource(
                connectionString);
            var tagsIndex = new OsmTagsIndex();
            var interpreter = new OsmRoutingInterpreter();
            var routingData = new OsmSourceRouterDataSource(
                interpreter, tagsIndex, source, VehicleEnum.Car);

            IRouter<RouterPoint> router = new Router<PreProcessedEdge>(routingData, interpreter,
                new DykstraRoutingPreProcessed(routingData.TagsIndex));

            OsmSharpRoute route;

            RouterPoint point1 = router.Resolve(VehicleEnum.Car,
                new GeoCoordinate(50.3150034243338, 34.8784106812928));
            RouterPoint point2 = router.Resolve(VehicleEnum.Car,
                new GeoCoordinate(50.3092549484347, 34.8894929841615));
            route = router.Calculate(VehicleEnum.Car, point1, point2);

            Assert.IsNotNull(route);
        }
开发者ID:jorik041,项目名称:osmsharp,代码行数:42,代码来源:SQLServerRoutingTests.cs

示例11: Engine

        /// <summary>
        /// Initializes a new instance of the <see cref="Engine"/> class.
        /// </summary>
        protected Engine()
        {
            // keeps a memory-efficient version of the osm-tags.
            var tagsIndex = new OsmTagsIndex();

            // creates a routing interpreter. (used to translate osm-tags into a routable network)
            interpreter = new OsmRoutingInterpreter();

            // create a routing datasource, keeps all processed osm routing data.
            var osmData = new MemoryRouterDataSource<SimpleWeighedEdge>(tagsIndex);

            // load data into this routing datasource.
            var fileSource = HostingEnvironment.MapPath("~/App_Data/Manchester.osm.pbf");
            Stream osmXmlData = new FileInfo(fileSource).OpenRead(); // for example moscow!
            using (osmXmlData)
            {
                var targetData = new SimpleWeighedDataGraphProcessingTarget(
                                osmData,
                                interpreter,
                                osmData.TagsIndex,
                                VehicleEnum.Car);

                // replace this with PBFdataProcessSource when having downloaded a PBF file.
                var dataProcessorSource = new
                  OsmSharp.Osm.Data.PBF.Raw.Processor.PBFDataProcessorSource(osmXmlData);

                // pre-process the data.
                var sorter = new DataProcessorFilterSort();
                sorter.RegisterSource(dataProcessorSource);
                targetData.RegisterSource(sorter);
                targetData.Pull();
            }

            // create the router object: there all routing functions are available.
            router = new Router<SimpleWeighedEdge>(
                osmData,
                interpreter,
                new DykstraRoutingLive(osmData.TagsIndex));
        }
开发者ID:kwilson,项目名称:TrafficMapScotland,代码行数:42,代码来源:Engine.cs

示例12: 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

示例13: InstructionGenerationNoTurns

        public void InstructionGenerationNoTurns()
        {
            // create new interpreter.
            var interpreter = new OsmRoutingInterpreter();

            // create the language generator.
            var languageGenerator = new LanguageTestGenerator();

            // calculate the route.
            OsmSharpRoute route = this.Calculate(
                new GeoCoordinate(51.09002, 3.44380),
                new GeoCoordinate(51.089900970459, 3.44386267662048));

            // generate the instructions.
            var instructionGenerator = new InstructionGenerator();
            List<Instruction> instructions =
                instructionGenerator.Generate(route, interpreter, languageGenerator);

            // test the results in the language generator.
            Assert.AreEqual(2, instructions.Count);
            Assert.AreEqual("GeneratePoi:1", instructions[0].Text);
            Assert.AreEqual("GeneratePoi:1", instructions[1].Text);
        }
开发者ID:jorik041,项目名称:osmsharp,代码行数:23,代码来源:InstructionsGenerationTests.cs

示例14: Main

        static void Main(string[] args)
        {
            OsmSharp.Logging.Log.Enable();
            OsmSharp.Logging.Log.RegisterListener(new OsmSharp.WinForms.UI.Logging.ConsoleTraceListener());
            // read the source file.
            var lines = OsmSharp.IO.DelimitedFiles.DelimitedFileHandler.ReadDelimitedFile(null,
                new FileInfo("bicylestations.csv").OpenRead(), OsmSharp.IO.DelimitedFiles.DelimiterType.DotCommaSeperated, true);

            // create router.
            var interpreter = new OsmRoutingInterpreter();
            var router = Router.CreateLiveFrom(new PBFOsmStreamSource(new FileInfo("antwerp.osm.pbf").OpenRead()), interpreter);

            // resolve all points.
            var resolvedPoints = new List<RouterPoint>();
            foreach(var line in lines)
            {
                var latitude = double.Parse(line[0], System.Globalization.CultureInfo.InvariantCulture);
                var longitude = double.Parse(line[1], System.Globalization.CultureInfo.InvariantCulture);
                var refId = double.Parse(line[2], System.Globalization.CultureInfo.InvariantCulture);

                var resolved = router.Resolve(Vehicle.Bicycle, new Math.Geo.GeoCoordinate(latitude, longitude));
                if(resolved != null && router.CheckConnectivity(Vehicle.Bicycle, resolved, 100))
                { // point exists and is connected.
                    resolvedPoints.Add(resolved);
                }
                else
                { // report that the point could not be resolved.
                    Console.WriteLine("Point with ref {0} could not be resolved!", refId);
                }
            }

            // calculate TSP.
            var tspSolver = new RouterTSPWrapper<RouterTSP>(
                new RouterTSPAEXGenetic(1000, 200), router, interpreter);
            var route = tspSolver.CalculateTSP(Vehicle.Bicycle, resolvedPoints.ToArray());
            route.SaveAsGpx(new FileInfo("output.gpx").OpenWrite());
        }
开发者ID:nagyistoce,项目名称:OsmSharp-samples,代码行数:37,代码来源:Program.cs

示例15: TestCHEdgeDifferenceNonContracted

        public void TestCHEdgeDifferenceNonContracted()
        {
            IOsmRoutingInterpreter interpreter = new OsmSharp.Routing.Osm.Interpreter.OsmRoutingInterpreter();
            EdgeDifference edgeDifference = this.BuildEdgeDifference(interpreter);

            Assert.AreEqual(1, edgeDifference.Calculate(1)); // witness paths from 2<->4.
            Assert.AreEqual(6, edgeDifference.Calculate(2));
            Assert.AreEqual(0, edgeDifference.Calculate(3));
            Assert.AreEqual(0, edgeDifference.Calculate(4));
            Assert.AreEqual(0, edgeDifference.Calculate(5));
            Assert.AreEqual(0, edgeDifference.Calculate(6));
            Assert.AreEqual(3, edgeDifference.Calculate(7));
            Assert.AreEqual(3, edgeDifference.Calculate(8));
            Assert.AreEqual(0, edgeDifference.Calculate(9));
            Assert.AreEqual(3, edgeDifference.Calculate(10));
            Assert.AreEqual(3, edgeDifference.Calculate(11));
            Assert.AreEqual(0, edgeDifference.Calculate(12));
            Assert.AreEqual(0, edgeDifference.Calculate(13));
            Assert.AreEqual(0, edgeDifference.Calculate(14));
            Assert.AreEqual(0, edgeDifference.Calculate(15));
            Assert.AreEqual(3, edgeDifference.Calculate(16));
            Assert.AreEqual(0, edgeDifference.Calculate(17));
            Assert.AreEqual(0, edgeDifference.Calculate(18));
            Assert.AreEqual(0, edgeDifference.Calculate(19));
            Assert.AreEqual(-1, edgeDifference.Calculate(20));
            Assert.AreEqual(0, edgeDifference.Calculate(21));
            Assert.AreEqual(0, edgeDifference.Calculate(22));
            Assert.AreEqual(-1, edgeDifference.Calculate(23));
        }
开发者ID:jboneng,项目名称:OsmSharp,代码行数:29,代码来源:CHEdgeDifferenceTests.cs


注:本文中的OsmSharp.Routing.Osm.Interpreter.OsmRoutingInterpreter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。