/// <summary> /// Tests routing from a serialized routing file. /// </summary> /// <param name="name"></param> /// <param name="stream"></param> /// <param name="testCount"></param> public static void Test(string name, Stream stream, int testCount) { var vehicle = Vehicle.Pedestrian; var tagsIndex = new TagsIndex(); // 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 RouterDataSource <Edge>(new Graph <Edge>(), tagsIndex); data.DropVertexIndex(); var targetData = new GraphOsmStreamTarget(data, interpreter, tagsIndex); targetData.RegisterSource(reader); targetData.Pull(); data.RebuildVertexIndex(); RoutingTest.Test(data, vehicle, testCount); }
/// <summary> /// Creates a router using interpreted edges. /// </summary> /// <param name="reader">The OSM-stream reader.</param> /// <param name="interpreter">The routing interpreter.</param> /// <returns></returns> public static Router CreateFrom(OsmStreamSource reader, IOsmRoutingInterpreter interpreter) { var tagsIndex = new TagsIndex(); // creates a tagged index. // read from the OSM-stream. var memoryData = new RouterDataSource <Edge>(new Graph <Edge>(), tagsIndex); memoryData.DropVertexIndex(); var targetData = new GraphOsmStreamTarget(memoryData, interpreter, tagsIndex); targetData.RegisterSource(reader); targetData.Pull(); memoryData.RebuildVertexIndex(); // creates the edge router. var typedRouter = new TypedRouterEdge( memoryData, interpreter, new Dykstra()); return(new Router(typedRouter)); // create the actual router. }
/// <summary> /// Creates a router using interpreted edges. /// </summary> /// <param name="reader">The OSM-stream reader.</param> /// <param name="interpreter">The routing interpreter.</param> /// <returns></returns> public static Router CreateFrom(OsmStreamSource reader, IOsmRoutingInterpreter interpreter) { var tagsIndex = new TagsIndex(); // creates a tagged index. // read from the OSM-stream. var memoryData = new RouterDataSource<Edge>(new Graph<Edge>(), tagsIndex); memoryData.DropVertexIndex(); var targetData = new GraphOsmStreamTarget(memoryData, interpreter, tagsIndex); targetData.RegisterSource(reader); targetData.Pull(); memoryData.RebuildVertexIndex(); // creates the edge router. var typedRouter = new TypedRouterEdge( memoryData, interpreter, new Dykstra()); return new Router(typedRouter); // create the actual router. }
/// <summary> /// Tests routing from a serialized routing file. /// </summary> /// <param name="name"></param> /// <param name="stream"></param> /// <param name="testCount"></param> public static void Test(string name, Stream stream, int testCount) { var vehicle = Vehicle.Pedestrian; var tagsIndex = new TagsIndex(); // 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 RouterDataSource<Edge>(new Graph<Edge>(), tagsIndex); data.DropVertexIndex(); var targetData = new GraphOsmStreamTarget(data, interpreter, tagsIndex); targetData.RegisterSource(reader); targetData.Pull(); data.RebuildVertexIndex(); RoutingTest.Test(data, vehicle, testCount); }