Changeset 16457 in osm for applications/editors


Ignore:
Timestamp:
2009-07-12T20:23:10+02:00 (15 years ago)
Author:
dhansen
Message:

Use tile cleanup code to actually flush all tiles objects
at flush time, not just their images.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java

    r16456 r16457  
    138138                        for (SlippyMapTile t : tileStorage.values()) {
    139139                            t.dropImage();
    140                             }
     140                        }
    141141                        System.out.println("done");
    142                         }
    143                     }));
     142                        shrinkTileStorage(0);
     143                    }
     144                }));
    144145        // end of adding menu commands
    145146
     
    234235    }
    235236
    236     long lastCheck = 0;
    237237    /**
    238238     * <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.
    241242     * </p>
    242243     */
    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    {
    249246        TreeSet<SlippyMapTile> tiles = new TreeSet<SlippyMapTile>(new TileTimeComp());
    250247        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 + ")");
    254250            return;
    255251        }
    256         int nr_to_drop = tiles.size() - max_nr_tiles;;
     252        int nr_to_drop = tiles.size() - maxNrTiles;;
    257253        Main.debug("total of " + tiles.size() + " tiles, need to flush " + nr_to_drop + " tiles");
    258254        for (SlippyMapTile t : tiles) {
     
    262258            nr_to_drop--;
    263259        }
     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);
    264269    }
    265270
Note: See TracChangeset for help on using the changeset viewer.