Changeset 8176 in josm for trunk/src/org/openstreetmap/josm/data/imagery
- Timestamp:
- 2015-04-07T22:17:42+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
r8174 r8176 133 133 } 134 134 135 private boolean isNoTileAtZoom() { 136 return attributes != null && attributes.isNoTileAtZoom(); 137 } 138 135 139 @Override 136 140 protected boolean cacheAsEmpty() { 137 if (attributes != null && attributes.isNoTileAtZoom()) { 138 // do not remove file - keep the information, that there is no tile, for further requests 139 // the code above will check, if this information is still valid 141 return isNoTileAtZoom(); 142 } 143 144 private boolean handleNoTileAtZoom() { 145 if (isNoTileAtZoom()) { 140 146 log.log(Level.FINE, "JCS TMS - Tile valid, but no file, as no tiles at this level {0}", tile); 141 147 tile.setError("No tile at this zoom level"); … … 143 149 return true; 144 150 } 145 return false; // as there is no other cache to cache the Tile, also cache other empty requests151 return false; 146 152 } 147 153 … … 157 163 158 164 @Override 159 public void loadingFinished(CacheEntry object, boolean success) {165 public void loadingFinished(CacheEntry object, LoadResult result) { 160 166 try { 161 loadTile(object, success); 167 tile.finishLoading(); // whatever happened set that loading has finished 168 switch(result){ 169 case FAILURE: 170 tile.setError("Problem loading tile"); 171 case SUCCESS: 172 handleNoTileAtZoom(); 173 if (object != null) { 174 byte[] content = object.getContent(); 175 if (content != null && content.length > 0) { 176 tile.loadImage(new ByteArrayInputStream(content)); 177 } 178 } 179 case REJECTED: 180 // do not set anything here, leave waiting sign 181 } 162 182 if (listener != null) { 163 listener.tileLoadingFinished(tile, success);183 listener.tileLoadingFinished(tile, result.equals(LoadResult.SUCCESS)); 164 184 } 165 185 } catch (IOException e) { … … 181 201 if (isObjectLoadable()) { 182 202 try { 183 loadTile(data); 203 if (data != null && data.getImage() != null) { 204 tile.setImage(data.getImage()); 205 tile.finishLoading(); 206 } 207 if (isNoTileAtZoom()) { 208 handleNoTileAtZoom(); 209 tile.finishLoading(); 210 } 184 211 return tile; 185 212 } catch (IOException e) { … … 189 216 190 217 } else { 191 return null; 192 } 193 } 194 195 // loads tile when calling back from cache 196 private void loadTile(CacheEntry object, boolean success) throws IOException { 197 tile.finishLoading(); 198 if (object != null) { 199 byte[] content = object.getContent(); 200 if (content != null && content.length > 0) { 201 tile.loadImage(new ByteArrayInputStream(content)); 202 } 203 } 204 if (!success) { 205 tile.setError("Problem loading tile"); 206 } 207 } 208 209 // loads tile when geting stright from cache 210 private void loadTile(BufferedImageCacheEntry object) throws IOException { 211 tile.finishLoading(); 212 if (cacheAsEmpty() || object != null) { // if cache as empty object, do not try to load image 213 if (object.getImage() != null) { 214 tile.setImage(object.getImage()); 215 } 218 return tile; 216 219 } 217 220 }
Note:
See TracChangeset
for help on using the changeset viewer.