protected override void RequestTile(int tileX, int tileY, int roundedZoom, Tile tile) { //double[] tile = GeoHelpers.TileToWGS84(tileX, tileY, roundedZoom); //Debug.Log("DEBUG: tile: " + tileX + " " + tileY + " => " + tile[0] + " " + tile[1]); TileDownloader.Instance.Get(GetTileURL(tileX, tileY, roundedZoom), tile); }
protected void Awake() { // create the tile template if needed if (tileTemplate == null) { tileTemplate = Tile.CreateTileTemplate(); tileTemplate.hideFlags = HideFlags.HideAndDontSave; tileTemplate.renderer.enabled = false; } ++tileTemplateUseCount; }
// <summary> // Gets a tile by its URL, the main texture of the material is assigned if successful. // </summary> public void Get(string url, Tile tile) { #if DEBUG_LOG Debug.Log("DEBUG: TileDownloader.Get: url: " + url); #endif tileURLLookedFor = url; if (tilesToLoad.Exists(tileURLMatchPredicate)) { #if DEBUG_LOG Debug.LogWarning("WARNING: TileDownloader.Get: already asked for url: " + url); #endif return ; } if (tilesLoading.Exists(tileURLMatchPredicate)) { #if DEBUG_LOG Debug.LogWarning("WARNING: TileDownloader.Get: already downloading url: " + url); #endif return ; } #if !UNITY_WEBPLAYER TileEntry cachedEntry = tiles.Find(tileURLMatchPredicate); if (cachedEntry == null) #endif { #if DEBUG_LOG Debug.Log("DEBUG: TileDownloader.Get: adding '" + url + "' to loading list"); #endif tilesToLoad.Add(new TileEntry(url, tile)); } #if !UNITY_WEBPLAYER else { #if DEBUG_LOG Debug.Log("DEBUG: TileDownloader.Get: adding '" + url + "' to loading list (cached)"); #endif cachedEntry.cached = true; cachedEntry.tile = tile; //cachedEntry.Complete = material; tilesToLoad.Add(cachedEntry); } #endif }
public TileEntry(string url, Tile tile) { this.url = url; if (tile == null) throw new ArgumentNullException("tile"); this.tile = tile; this.jobCompleteHandler = new Job.JobCompleteHandler(TileDownloader.Instance.JobTerminationEvent); }
/// <summary> /// Requests the tile's texture and assign it. /// </summary> /// <param name='tileX'> /// Tile x. /// </param> /// <param name='tileY'> /// Tile y. /// </param> /// <param name='roundedZoom'> /// Rounded zoom. /// </param> /// <param name='tile'> /// Tile. /// </param> protected abstract void RequestTile(int tileX, int tileY, int roundedZoom, Tile tile);
protected override void RequestTile(int tileX, int tileY, int roundedZoom, Tile tile) { if (db == null) { throw new NullReferenceException("db"); } DataTable dt = db.ExecuteQuery("SELECT tile_data FROM tiles WHERE zoom_level=" + roundedZoom + " AND tile_column=" + tileX + " AND tile_row=" + tileY); if (dt.Rows.Count == 0) { #if DEBUG_LOG Debug.LogWarning("WARNING: no rows in MBTiles db for tile: " + tileX + "," + tileY + "," + roundedZoom); #endif return ; } Texture2D tex = new Texture2D((int)Map.TileResolution, (int)Map.TileResolution); if (tex.LoadImage((byte[])dt.Rows[0]["tile_data"])) tile.SetTexture(tex); else { #if DEBUG_LOG Debug.LogError("ERROR: MBTilesLayer.RequestTile: couldn't load image for: " + tileX + "," + tileY + "," + roundedZoom); #endif } }