Changeset 17495 in josm


Ignore:
Timestamp:
2021-02-20T08:56:49+01:00 (2 weeks ago)
Author:
wiktorn
Message:

Extend the size of MemoryTileCache

Include in the computations:

  • all zoomOffsets that might be visited during paint
  • overloadTiles() method that adds new tiles to be fetched

Merge tooLarge() and insane() method, as only tileCache size limit is sensible and resign from any
artificial limits.

See: #20014, #20497

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r17494 r17495  
    639639            tileSize = tileSource.getTileSize();
    640640        }
    641         // as we can see part of the tile at the top and at the bottom, use Math.ceil(...) + 1 to accommodate for that
    642         int visibileTiles = (int) (Math.ceil((double) height / tileSize + 1) * Math.ceil((double) width / tileSize + 1));
    643         // add 10% for tiles from different zoom levels
     641        /**
     642         * As we can see part of the tile at the top and at the bottom, use Math.ceil(...) + 1 to accommodate for that
     643         * Add another 2 tiles on each axis, as overloadTiles adds one tile in each direction that might be overloaded
     644         *
     645         * @see #overloadTiles()
     646         */
     647        int maxYtiles = (int) Math.ceil((double) height / tileSize + 1) + 2;
     648        int maxXtiles = (int) Math.ceil((double) width / tileSize + 1) + 2;
     649        int visibileTiles = maxXtiles * maxYtiles;
     650        /**
     651         * Take into account ZOOM_OFFSET to calculate real number of tiles and multiply by 8, to cover all tiles, that might be
     652         * accessed when looking for tiles outside current zoom level.
     653         *
     654         * Currently we use otherZooms = {1, 2, -1, -2, -3, -4, -5}
     655         *
     656         * Check call to tryLoadFromDifferentZoom
     657         * @see #tryLoadFromDifferentZoom(Graphics2D, int, List<Tile>,int)
     658         * @see #drawInViewArea((Graphics2D, MapView, ProjectionBounds)
     659         *
     660         */
    644661        int ret = (int) Math.ceil(
    645662                Math.pow(2d, ZOOM_OFFSET.get()) * visibileTiles // use offset to decide, how many tiles are visible
    646                 * 4);
     663                * 8);
    647664        Logging.info("AbstractTileSourceLayer: estimated visible tiles: {0}, estimated cache size: {1}", visibileTiles, ret);
    648665        return ret;
     
    12351252
    12361253        private boolean tooLarge() {
    1237             return insane() || this.tilesSpanned() > MAX_TILES_SPANNED;
    1238         }
    1239 
    1240         private boolean insane() {
    12411254            return tileCache == null || size() > tileCache.getCacheSize();
    12421255        }
     
    12631276         */
    12641277        public Stream<TilePosition> tilePositions() {
    1265             if (zoom == 0 || this.insane()) {
     1278            if (zoom == 0 || this.tooLarge()) {
    12661279                return Stream.empty(); // Tileset is either empty or too large
    12671280            } else {
     
    15991612        g.setColor(Color.lightGray);
    16001613
    1601         if (ts.insane()) {
    1602             myDrawString(g, tr("zoom in to load any tiles"), 120, 120);
    1603         } else if (ts.tooLarge()) {
     1614        if (ts.tooLarge()) {
    16041615            myDrawString(g, tr("zoom in to load more tiles"), 120, 120);
    16051616        } else if (!getDisplaySettings().isAutoZoom() && ts.tooSmall()) {
Note: See TracChangeset for help on using the changeset viewer.