/// <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)); }
public static void Test(IRoutingAlgorithmData <Edge> data, Vehicle vehicle, int testCount) { // creates the edge router. var router = new Dykstra(); var interpreter = new OsmRoutingInterpreter(); var performanceInfo = new PerformanceInfoConsumer("Routing"); 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("Routing", TraceEventType.Information, "Routing... {0}%", progress); latestProgress = progress; } } performanceInfo.Stop(); OsmSharp.Logging.Log.TraceEvent("Routing", OsmSharp.Logging.TraceEventType.Information, string.Format("{0}/{1} routes successfull!", successCount, totalCount)); }
/// <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)); }
public static void Test(IRoutingAlgorithmData<Edge> data, Vehicle vehicle, int testCount) { // creates the edge router. var router = new Dykstra(); var interpreter = new OsmRoutingInterpreter(); var performanceInfo = new PerformanceInfoConsumer("Routing"); 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("Routing", TraceEventType.Information, "Routing... {0}%", progress); latestProgress = progress; } } performanceInfo.Stop(); OsmSharp.Logging.Log.TraceEvent("Routing", OsmSharp.Logging.TraceEventType.Information, string.Format("{0}/{1} routes successfull!", successCount, totalCount)); }