Changeset 16457 in osm for applications/editors/josm/plugins/slippymap
- Timestamp:
- 2009-07-12T20:23:10+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java
r16456 r16457 138 138 for (SlippyMapTile t : tileStorage.values()) { 139 139 t.dropImage(); 140 140 } 141 141 System.out.println("done"); 142 } 143 })); 142 shrinkTileStorage(0); 143 } 144 })); 144 145 // end of adding menu commands 145 146 … … 234 235 } 235 236 236 long lastCheck = 0;237 237 /** 238 238 * <p> 239 * Check if tiles.size() is not more than max_nr_tiles. If yes, oldest tiles by timestamp 240 * are fired out from cache. 239 * Check if tiles.size() is not more than maxNrTiles. 240 * If yes, oldest tiles by timestamp are flushed from 241 * the cache. 241 242 * </p> 242 243 */ 243 public void checkTileStorage() { 244 int maxZoom = 30; // SlippyMapPreferences.getMaxZoomLvl(); 245 long now = System.currentTimeMillis(); 246 if (now - lastCheck < 1000) 247 return; 248 lastCheck = now; 244 public void shrinkTileStorage(int maxNrTiles) 245 { 249 246 TreeSet<SlippyMapTile> tiles = new TreeSet<SlippyMapTile>(new TileTimeComp()); 250 247 tiles.addAll(tileStorage.values()); 251 int max_nr_tiles = 100; 252 if (tiles.size() < max_nr_tiles) { 253 Main.debug("total of " + tiles.size() + " loaded tiles, size OK " + now); 248 if (tiles.size() < maxNrTiles) { 249 Main.debug("total of " + tiles.size() + " loaded tiles, size OK (< " + maxNrTiles + ")"); 254 250 return; 255 251 } 256 int nr_to_drop = tiles.size() - max _nr_tiles;;252 int nr_to_drop = tiles.size() - maxNrTiles;; 257 253 Main.debug("total of " + tiles.size() + " tiles, need to flush " + nr_to_drop + " tiles"); 258 254 for (SlippyMapTile t : tiles) { … … 262 258 nr_to_drop--; 263 259 } 260 } 261 long lastCheck = 0; 262 public void checkTileStorage() { 263 int maxZoom = 30; // SlippyMapPreferences.getMaxZoomLvl(); 264 long now = System.currentTimeMillis(); 265 if (now - lastCheck < 1000) 266 return; 267 lastCheck = now; 268 shrinkTileStorage(150); 264 269 } 265 270
Note:
See TracChangeset
for help on using the changeset viewer.