Exemplo n.º 1
0
 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;
     }
 }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        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);
            }
        }