/// <summary> /// Downloads, extracts and builds the nwb router db. /// </summary> public static RouterDb DownloadExtractAndBuildRouterDb() { if (!File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "nwb.routerdb"))) { // download test data and extract to 'temp' directory relative to application base directory. Download.DownloadAndExtractShape("http://files.itinero.tech/data/open-data/NWB/WGS84_2016-09-01.zip", "WGS84_2016-09-01.zip"); // create a new router db and load the shapefile. var vehicle = DynamicVehicle.LoadFromEmbeddedResource(System.Reflection.Assembly.GetExecutingAssembly(), "OpenLR.Test.Functional.NWB.car.lua"); // load data for the car profile. var routerDb = new RouterDb(EdgeDataSerializer.MAX_DISTANCE); routerDb.LoadFromShape(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "temp"), "wegvakken.shp", "JTE_ID_BEG", "JTE_ID_END", vehicle); // write the router db to disk for later use. using (var ouputStream = File.OpenWrite(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "nwb.routerdb"))) { routerDb.Serialize(ouputStream); } return(routerDb); } else { return(RouterDb.Deserialize(File.OpenRead(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "nwb.routerdb")))); } }
public void TestOSMCar() { var vehicle = DynamicVehicle.LoadFromEmbeddedResource(typeof(DynamicVehicleTests).Assembly, "Itinero.Test.test_data.profiles.osm.car.lua").Fastest(); // invalid highway types. this.TestFactorAndSpeed(vehicle, 0, 0, 0, "highwey", "road"); // default highway types. this.TestFactorAndSpeed(vehicle, 0, 0, 0, "highway", "footway"); this.TestFactorAndSpeed(vehicle, 0, 0, 0, "highway", "pedestrian"); this.TestFactorAndSpeed(vehicle, 0, 0, 0, "highway", "path"); this.TestFactorAndSpeed(vehicle, 0, 0, 0, "highway", "cycleway"); this.TestFactorAndSpeed(vehicle, 0, null, 05, "highway", "living_street"); this.TestFactorAndSpeed(vehicle, 0, null, 30, "highway", "road"); this.TestFactorAndSpeed(vehicle, 0, null, 30, "highway", "track"); this.TestFactorAndSpeed(vehicle, 0, null, 50, "highway", "unclassified"); this.TestFactorAndSpeed(vehicle, 0, null, 50, "highway", "residential"); this.TestFactorAndSpeed(vehicle, 0, null, 70, "highway", "tertiary"); this.TestFactorAndSpeed(vehicle, 0, null, 70, "highway", "tertiary_link"); this.TestFactorAndSpeed(vehicle, 0, null, 70, "highway", "secondary"); this.TestFactorAndSpeed(vehicle, 0, null, 70, "highway", "secondary_link"); this.TestFactorAndSpeed(vehicle, 0, null, 90, "highway", "primary"); this.TestFactorAndSpeed(vehicle, 0, null, 90, "highway", "primary_link"); this.TestFactorAndSpeed(vehicle, 0, null, 90, "highway", "trunk"); this.TestFactorAndSpeed(vehicle, 0, null, 90, "highway", "trunk_link"); this.TestFactorAndSpeed(vehicle, 3, null, 120, "highway", "motorway"); this.TestFactorAndSpeed(vehicle, 3, null, 120, "highway", "motorway_link"); // designated roads. this.TestFactorAndSpeed(vehicle, 0, null, 50, "highway", "unclassified", "foot", "designated"); this.TestFactorAndSpeed(vehicle, 0, null, 50, "highway", "unclassified", "foot", "yes"); this.TestFactorAndSpeed(vehicle, 0, null, 50, "highway", "unclassified", "foot", "no"); this.TestFactorAndSpeed(vehicle, 0, null, 50, "highway", "unclassified", "bicycle", "designated"); this.TestFactorAndSpeed(vehicle, 0, null, 50, "highway", "unclassified", "bicycle", "yes"); this.TestFactorAndSpeed(vehicle, 0, null, 50, "highway", "unclassified", "bicycle", "no"); this.TestFactorAndSpeed(vehicle, 0, null, 50, "highway", "unclassified", "motorcar", "yes"); this.TestFactorAndSpeed(vehicle, 0, 0, 0, "highway", "unclassified", "motorcar", "no"); // test maxspeed tags. this.TestFactorAndSpeed(vehicle, 0, null, 30 * .75f, "highway", "primary", "maxspeed", "30"); this.TestFactorAndSpeed(vehicle, 0, null, 20 * 1.60934f * .75f, "highway", "primary", "maxspeed", "20 mph"); }
public void TestShapeCar() { var vehicle = DynamicVehicle.LoadFromEmbeddedResource(typeof(DynamicVehicleTests).Assembly, "Itinero.Test.test_data.profiles.shape.car.lua"); var profile = vehicle.Fastest(); // default types. this.TestFactorAndSpeed(profile, 0, null, 50, "BST_CODE", "BVD"); this.TestFactorAndSpeed(profile, 0, null, 70, "BST_CODE", "AF"); this.TestFactorAndSpeed(profile, 0, null, 70, "BST_CODE", "OP"); this.TestFactorAndSpeed(profile, 0, null, 120, "BST_CODE", "HR"); this.TestFactorAndSpeed(profile, 1, null, 30, "BST_CODE", "MRB"); this.TestFactorAndSpeed(profile, 1, null, 30, "BST_CODE", "NRB"); // test parameters. var value = string.Empty; Assert.IsTrue(vehicle.Parameters.TryGetValue("source_vertex", out value)); Assert.AreEqual("JTE_ID_BEG", value); Assert.IsTrue(vehicle.Parameters.TryGetValue("target_vertex", out value)); Assert.AreEqual("JTE_ID_END", value); }