diff --git a/Assets/MapzenGo/Models/CachedDynamicTileManager.cs b/Assets/MapzenGo/Models/CachedDynamicTileManager.cs index 2b414ff..eb3ef76 100644 --- a/Assets/MapzenGo/Models/CachedDynamicTileManager.cs +++ b/Assets/MapzenGo/Models/CachedDynamicTileManager.cs @@ -29,51 +29,21 @@ public override void Start() base.Start(); } - public override void Update() - { - base.Update(); - - lock (_readyToProcess) - { - if (_readyToProcess.Any()) - { - - var tile = _readyToProcess.Dequeue(); - foreach (var factory in Plugins) - { - factory.Create(tile); - } - } - } - } - protected override void LoadTile(Vector2d tileTms, Tile tile) { var url = string.Format(_mapzenUrl, _mapzenLayers, Zoom, tileTms.x, tileTms.y, _mapzenFormat, _key); //this is temporary (hopefully), cant just keep adding stuff to filenames - var tilePath = Path.Combine(string.Format(CacheFolderPath, tile.Zoom), _mapzenLayers.Replace(',', '_') + "_" + tileTms.x + "_" + tileTms.y); + var tilePath = Path.Combine(CacheFolderPath, _mapzenLayers.Replace(',', '_') + "_" + tileTms.x + "_" + tileTms.y); if (File.Exists(tilePath)) { - ThreadPool.QueueUserWorkItem((s) => + using (var r = new StreamReader(tilePath, Encoding.Default)) { - using (var r = new StreamReader((string)s, Encoding.Default)) - { - var mapData = r.ReadToEnd(); - //ConstructTile(mapData, tile); - var json = new JSONObject(mapData); - if (!tile) // checks if tile still exists and haven't destroyed yet - return; - tile.Data = json; - - lock (_readyToProcess) - _readyToProcess.Enqueue(tile); - - } - }, tilePath); + var mapData = r.ReadToEnd(); + ConstructTile(mapData, tile); + } } else { - Debug.Log(url); ObservableWWW.Get(url).Subscribe( success => {