Changeset 26508 in osm for applications/viewer/jmapviewer
- Timestamp:
- 2011-08-10T16:50:46+02:00 (13 years ago)
- Location:
- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java
r24989 r26508 15 15 import java.io.OutputStreamWriter; 16 16 import java.io.PrintWriter; 17 import java.lang.Thread; 17 18 import java.net.HttpURLConnection; 18 19 import java.net.URL; … … 20 21 import java.nio.charset.Charset; 21 22 import java.util.Map.Entry; 23 import java.util.Random; 22 24 import java.util.logging.Level; 23 25 import java.util.logging.Logger; … … 132 134 synchronized (cache) { 133 135 tile = cache.getTile(source, tilex, tiley, zoom); 134 if (tile == null || tile.isLoaded() || tile.loading)136 if (tile == null || (tile.isLoaded() && !tile.hasError()) || tile.loading) 135 137 return; 138 tile.loaded = false; 139 tile.error = false; 136 140 tile.loading = true; 137 141 } … … 156 160 157 161 protected void loadOrUpdateTile() { 158 159 162 try { 160 163 // log.finest("Loading tile from OSM: " + tile); … … 210 213 listener.tileLoadingFinished(tile, true); 211 214 } else { 212 byte[] buffer = loadTileInBuffer(urlConn); 213 if (buffer != null) { 214 tile.loadImage(new ByteArrayInputStream(buffer)); 215 tile.setLoaded(true); 216 listener.tileLoadingFinished(tile, true); 217 saveTileToFile(buffer); 215 for(int i = 0; i < 5; ++i) { 216 if (urlConn instanceof HttpURLConnection && ((HttpURLConnection)urlConn).getResponseCode() == 503) { 217 Thread.sleep(5000+(new Random()).nextInt(5000)); 218 continue; 219 } 220 byte[] buffer = loadTileInBuffer(urlConn); 221 if (buffer != null) { 222 tile.loadImage(new ByteArrayInputStream(buffer)); 223 tile.setLoaded(true); 224 listener.tileLoadingFinished(tile, true); 225 saveTileToFile(buffer); 226 break; 227 } 218 228 } 219 229 } … … 252 262 fileAge = tileFile.lastModified(); 253 263 boolean oldTile = System.currentTimeMillis() - fileAge > maxCacheFileAge; 254 // System.out.println("Loaded from file: " + tile);255 264 if (!oldTile) { 256 265 tile.setLoaded(true); -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
r24967 r26508 44 44 synchronized (cache) { 45 45 tile = cache.getTile(source, tilex, tiley, zoom); 46 if (tile == null || tile.isLoaded() || tile.loading)46 if (tile == null || (tile.isLoaded() && !tile.hasError()) || tile.loading) 47 47 return; 48 tile.loaded = false; 49 tile.error = false; 48 50 tile.loading = true; 49 51 }
Note:
See TracChangeset
for help on using the changeset viewer.