protected virtual void Dispose(bool disposeManagedResources) { if (!_disposed) { if (disposeManagedResources) { foreach (var mbtCache in _mbTiles) { MbTilesDb mbt = mbtCache.Value; mbt.Dispose(); mbt = null; } _mbTiles.Clear(); } _disposed = true; } }
public void Add(string mapId, CanonicalTileId tileId, byte[] data) { mapId = cleanMapId(mapId); lock (_lock) { if (!_mbTiles.ContainsKey(mapId)) { initializeMbTiles(mapId); } } MbTilesDb currentMbTiles = _mbTiles[mapId]; if (!currentMbTiles.TileExists(tileId)) { _mbTiles[mapId].AddTile(tileId, data); } }
private void initializeMbTiles(string mapId) { if (string.IsNullOrEmpty(mapId)) { throw new Exception("Cannot intialize MbTilesCache without a map id"); } mapId = cleanMapId(mapId); MbTilesDb mbt = new MbTilesDb(mapId + ".cache", _maxCacheSize); MetaDataRequired md = new MetaDataRequired() { TilesetName = mapId, Description = "TODO: " + mapId, Format = "TODO: " + mapId, Type = "TODO: " + mapId, Version = 1 }; mbt.CreateMetaData(md); _mbTiles[mapId] = mbt; }
public void Add(string mapId, CanonicalTileId tileId, CacheItem item, bool forceInsert) { mapId = cleanMapId(mapId); #if MAPBOX_DEBUG_CACHE string methodName = _className + "." + new System.Diagnostics.StackFrame().GetMethod().Name; UnityEngine.Debug.LogFormat("{0} {1} {2} forceInsert:{3}", methodName, mapId, tileId, forceInsert); #endif lock (_lock) { if (!_mbTiles.ContainsKey(mapId)) { initializeMbTiles(mapId); } } MbTilesDb currentMbTiles = _mbTiles[mapId]; if (!currentMbTiles.TileExists(tileId) || forceInsert) { _mbTiles[mapId].AddTile(tileId, item, forceInsert); } }