/// <summary> /// Loads all OSM data in the given bounding box by using routable tiles. /// </summary> /// <param name="db">The routerdb to fill.</param> /// <param name="box">The bounding box to fetch tiles for.</param> /// <param name="keepGlobalIds">Flag to keep the global ids.</param> /// <param name="baseUrl">The base url of the routeable tile source.</param> /// <param name="vehicleCache">The vehicle cache to use.</param> public static void LoadOsmDataFromTiles(this RouterDb db, Box box, string baseUrl = TileParser.BaseUrl, bool keepGlobalIds = true, VehicleCache vehicleCache = null) { // build the tile range. var tileRange = new TileRange(box, Zoom); // build the vehicle cache. if (vehicleCache == null) { vehicleCache = new VehicleCache(db.GetSupportedVehicles().ToArray()); } // get all the tiles and build the routerdb. var globalIdMap = db.ExtractGlobalIds(); db.Network.GeometricGraph.Graph.MarkAsMulti(); // when loading data we need a multigraph. var tiles = tileRange.ToList(); for (var t = 0; t < tiles.Count; t++) { var tile = tiles[t]; Logger.Log(nameof(RouterDbExtensions), Logging.TraceEventType.Information, $"Loading tile {t+1}/{tiles.Count}: {tile}({tile.LocalId})"); db.AddOsmTile(globalIdMap, tile, vehicleCache, baseUrl); } // keep global ids if it's a requirement. if (keepGlobalIds) { db.AddOrUpdateGlobalIds(globalIdMap); } // sort the network. db.Sort(); // optimize the network by applying simplifications. db.OptimizeNetwork(); // compress the network. db.Compress(); }
public TileRangeEnumerator(TileRange tileRange) { _tileRange = tileRange; _x = uint.MaxValue; _y = uint.MaxValue; }