Changeset 11843 in josm for trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
- Timestamp:
- 2017-04-05T12:17:06+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
r11796 r11843 83 83 84 84 @Override 85 public Tile getTile() {86 return getCachedTile();87 }88 89 @Override90 85 public String getCacheKey() { 91 86 if (tile != null) { … … 262 257 } 263 258 264 /**265 * Method for getting the tile from cache only, without trying to reach remote resource266 * @return tile or null, if nothing (useful) was found in cache267 */268 public Tile getCachedTile() {269 BufferedImageCacheEntry data = get();270 if (isObjectLoadable() && isCacheElementValid()) {271 try {272 // set tile metadata273 if (this.attributes != null) {274 for (Entry<String, String> e: this.attributes.getMetadata().entrySet()) {275 tile.putValue(e.getKey(), e.getValue());276 }277 }278 279 if (data != null) {280 if (data.getImage() != null) {281 tile.setImage(data.getImage());282 tile.finishLoading();283 } else {284 // we had some data, but we didn't get any image. Malformed image?285 tile.setError(tr("Could not load image from tile server"));286 }287 }288 if (isNoTileAtZoom()) {289 handleNoTileAtZoom();290 tile.finishLoading();291 }292 if (attributes != null && attributes.getResponseCode() >= 400) {293 if (attributes.getErrorMessage() == null) {294 tile.setError(tr("HTTP error {0} when loading tiles", attributes.getResponseCode()));295 } else {296 tile.setError(tr("Error downloading tiles: {0}", attributes.getErrorMessage()));297 }298 }299 return tile;300 } catch (IOException e) {301 LOG.log(Level.WARNING, "JCS TMS - error loading object for tile {0}: {1}", new Object[] {tile.getKey(), e.getMessage()});302 Main.warn(e);303 return null;304 }305 306 } else {307 return tile;308 }309 }310 311 259 private boolean handleNoTileAtZoom() { 312 260 if (isNoTileAtZoom()) {
Note:
See TracChangeset
for help on using the changeset viewer.