public static void Main(string[] args) { Itinero.Logging.Logger.LogAction = (o, level, message, parameters) => { Console.WriteLine(string.Format("[{0}] {1} - {2}", o, level, message)); }; // 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.LoadFromStream(File.OpenRead( Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "car.lua"))); var routerDb = new RouterDb(EdgeDataSerializer.MAX_DISTANCE); routerDb.LoadFromShape(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "temp"), "wegvakken.shp", vehicle); // OPTIONAL: build a contracted version of the routing graph. // routerDb.AddContracted(vehicle.Fastest()); // write the router db to disk for later use. routerDb.Serialize(File.OpenWrite(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "nwb.routerdb"))); // calculate a test route. var router = new Router(routerDb); var route = router.Calculate(vehicle.Fastest(), new Coordinate(52.954718f, 6.338811f), new Coordinate(52.95359f, 6.337916f)); route = router.Calculate(vehicle.Fastest(), new Coordinate(51.57060821506861f, 5.46792984008789f), new Coordinate(51.58711643524425f, 5.4957228899002075f)); // generate instructions based on lua profile. var instructions = route.GenerateInstructions(); }
public static void Main(string[] args) { Itinero.Logging.Logger.LogAction = (o, level, message, parameters) => { Console.WriteLine(string.Format("[{0}] {1} - {2}", o, level, message)); }; // 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 = new Car(); // 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. routerDb.Serialize(File.OpenWrite(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "nwb.routerdb"))); // calculate a test route. var router = new Router(routerDb); var route = router.Calculate(vehicle.Shortest(), new Coordinate(51.57060821506861f, 5.46792984008789f), new Coordinate(51.58711643524425f, 5.4957228899002075f)); }