/// <summary> /// Returns the tile data, otherwise null /// </summary> /// <param name="tileId">Canonical tile id to identify the tile</param> /// <returns>tile data as byte[], if tile is not cached returns null</returns> public byte[] GetTile(CanonicalTileId tileId) { tiles tile = _sqlite .Table <tiles>() .Where(t => t.zoom_level == tileId.Z && t.tile_column == tileId.X && t.tile_row == tileId.Y) .FirstOrDefault(); if (null == tile) { return(null); } return(tile.tile_data); }
/// <summary> /// Returns the tile data, otherwise null /// </summary> /// <param name="tileId">Canonical tile id to identify the tile</param> /// <returns>tile data as byte[], if tile is not cached returns null</returns> public CacheItem GetTile(CanonicalTileId tileId) { #if MAPBOX_DEBUG_CACHE string methodName = _className + "." + new System.Diagnostics.StackFrame().GetMethod().Name; Debug.LogFormat("{0} {1} {2}", methodName, _tileset, tileId); #endif tiles tile = null; try { tile = _sqlite .Table <tiles>() .Where(t => t.zoom_level == tileId.Z && t.tile_column == tileId.X && t.tile_row == tileId.Y) .FirstOrDefault(); } catch (Exception ex) { Debug.LogErrorFormat("error getting tile {1} {2} from cache{0}{3}", Environment.NewLine, _tileset, tileId, ex); return(null); } if (null == tile) { return(null); } DateTime?lastModified = null; if (tile.lastmodified.HasValue) { lastModified = UnixTimestampUtils.From((double)tile.lastmodified.Value); } return(new CacheItem() { Data = tile.tile_data, AddedToCacheTicksUtc = tile.timestamp, ETag = tile.etag, LastModified = lastModified }); }