Changeset 29368 in osm for applications/editors/josm/plugins/imagerycache/src/org
- Timestamp:
- 2013-03-16T17:22:07+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagerycache/src/org/openstreetmap/josm/plugins/imagerycache/OsmDBTilesLoader.java
r29363 r29368 13 13 import java.util.Map; 14 14 import java.util.Random; 15 import java.util.logging.Level;16 import java.util.logging.Logger;17 15 import org.mapdb.DB; 18 16 import org.mapdb.DBMaker; 19 import org.mapdb.Serializer;20 17 import org.openstreetmap.gui.jmapviewer.JobDispatcher; 21 18 import org.openstreetmap.gui.jmapviewer.OsmTileLoader; … … 25 22 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 26 23 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource.TileUpdate; 24 import org.openstreetmap.josm.data.preferences.BooleanProperty; 27 25 28 26 /** … … 33 31 34 32 35 private static final Logger log = Logger.getLogger(OsmDBTilesLoader.class.getName());36 33 public static final long FILE_AGE_ONE_DAY = 1000 * 60 * 60 * 24; 37 34 public static final long FILE_AGE_ONE_WEEK = FILE_AGE_ONE_DAY * 7; 38 39 40 35 36 public static final boolean debug = new BooleanProperty("imagerycache.debug", false).get(); 37 41 38 static class TileDAOMapDB { 42 39 protected HashMap<String, DB> dbs = new HashMap<String, DB>(); … … 53 50 try { 54 51 db = DBMaker 55 .newFileDB(new File(cacheFolder, source.replaceAll("[\\\\/:*?\"<>| ]", "_")))52 .newFileDB(new File(cacheFolder, "tiles_"+source.replaceAll("[\\\\/:*?\"<>| ]", "_"))) 56 53 .randomAccessFileEnableIfNeeded() 57 54 .journalDisable() … … 60 57 dbs.put(source, db); 61 58 } catch (Exception e) { 62 log.warning("Error: Can not create MapDB file");63 e.printStackTrace( );59 System.out.println("Error: Can not create MapDB file"); 60 e.printStackTrace(System.out); 64 61 } 65 62 } … … 74 71 m = d.getHashMap("tiles"); 75 72 storages.put(source, m); 76 log.log(Level.FINEST, "Created storage {0}",source);73 if (debug) System.out.println("Created storage "+source); 77 74 } catch (Exception e) { 78 log.severe("Error: Can not create HashMap in MapDB storage");79 e.printStackTrace( );75 System.out.println("Error: Can not create HashMap in MapDB storage"); 76 e.printStackTrace(System.out); 80 77 } 81 78 } … … 93 90 94 91 protected void updateModTime(String source, long id, DBTile dbTile) { 95 log.finest("Updating modification time");92 if (debug) System.out.println("Tile "+id+": Updating modification time"); 96 93 getStorage(source).put(id, dbTile); 97 94 } 98 95 99 96 protected void updateTile(String source, long id, DBTile dbTile) { 100 log.finest("Updating tile in base");97 if (debug) System.out.println("Tile "+id+": Updating tile in base"); 101 98 getStorage(source).put(id, dbTile); 102 99 } … … 240 237 case LastModified: // (2) 241 238 if (!isOsmTileNewer(fileAge)) { 242 log.finest("LastModified test: local version is up to date: " + tile);239 System.out.println("Tile "+id+": LastModified test: local version is up to date"); 243 240 dbTile.lastModified = getLastModTime(); 244 241 dao.updateModTime(sourceName, id, dbTile); … … 271 268 // If we are isModifiedSince or If-None-Match has been set 272 269 // and the server answers with a HTTP 304 = "Not Modified" 273 log.finest("Answer from HTTP: 304 / ETag test: local version is up to date: " + tile);270 if (debug) System.out.println("Tile "+id+": Answer from HTTP=304 / ETag test: local version is up to date"); 274 271 dbTile.lastModified = getLastModTime(); 275 272 dao.updateModTime(sourceName, id, dbTile); … … 290 287 continue; 291 288 } 292 log.log(Level.FINE, "Loading from OSM{0}",tile);289 if (debug) System.out.println("Tile "+id+": Loading from OSM, "+ tile); 293 290 byte[] buffer = loadTileInBuffer(urlConn); 294 291 if (buffer != null) { … … 308 305 listener.tileLoadingFinished(tile, false); 309 306 try { 310 log.log(Level.SEVERE, "Failed loading {0}: {1}", new Object[]{tile.getUrl(), e.getMessage()});311 e.printStackTrace( );307 System.out.println("Tile "+id+": Error: Failed loading from "+tile.getUrl()); 308 e.printStackTrace(System.out); 312 309 } catch(IOException i) { 313 310 }
Note:
See TracChangeset
for help on using the changeset viewer.