Changeset 17402 in josm for trunk/src/org


Ignore:
Timestamp:
2020-12-12T11:31:51+01:00 (4 years ago)
Author:
wiktorn
Message:

Refuse to download tiles if the tileset is too large

Use TileSet in overloadTiles and move decision whether to load the tileset or not to loadAllTiles.

Closes: #20207

File:
1 edited

Legend:

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

    r16967 r17402  
    920920    public void loadAllTiles(boolean force) {
    921921        TileSet ts = getVisibleTileSet();
    922 
    923         // if there is more than 18 tiles on screen in any direction, do not load all tiles!
    924         if (ts.tooLarge()) {
    925             Logging.warn("Not downloading all tiles because there is more than 18 tiles on an axis!");
    926             return;
    927         }
    928922        ts.loadAllTiles(force);
    929923        invalidate();
     
    12911285
    12921286        private void loadAllTiles(boolean force) {
    1293             if (!getDisplaySettings().isAutoLoad() && !force)
     1287            if (!getDisplaySettings().isAutoLoad() && !force) {
    12941288                return;
     1289            }
     1290            if (tooLarge()) {
     1291                // Too many tiles... refuse to download
     1292                Logging.warn("Not downloading all tiles because there is more than 18 tiles on an axis!");
     1293                return;
     1294            }
    12951295            List<Tile> allTiles = allTilesCreate();
    12961296            allTiles.sort(getTileDistanceComparator());
     
    13051305        private void overloadTiles() {
    13061306            int overload = 1;
     1307
    13071308            int minXo = Utils.clamp(minX-overload, tileSource.getTileXMin(zoom), tileSource.getTileXMax(zoom));
    13081309            int maxXo = Utils.clamp(maxX+overload, tileSource.getTileXMin(zoom), tileSource.getTileXMax(zoom));
    13091310            int minYo = Utils.clamp(minY-overload, tileSource.getTileYMin(zoom), tileSource.getTileYMax(zoom));
    13101311            int maxYo = Utils.clamp(maxY+overload, tileSource.getTileYMin(zoom), tileSource.getTileYMax(zoom));
    1311             for (int x = minXo; x < maxXo; ++x) {
    1312                 for (int y = minYo; y < maxYo; ++y) {
    1313                     loadTile(getOrCreateTile(x, y, zoom), false);
    1314                 }
    1315             }
     1312
     1313            TileSet ts = new TileSet(new TileXY(minXo, minYo), new TileXY(maxXo, maxYo), zoom);
     1314            ts.loadAllTiles(false);
    13161315        }
    13171316
     
    15501549        TileSet ts = dts.getTileSet(zoom);
    15511550
    1552         // Too many tiles... refuse to download
    1553         if (!ts.tooLarge()) {
    1554             // try to load tiles from desired zoom level, no matter what we will show (for example, tiles from previous zoom level
    1555             // on zoom in)
    1556             ts.loadAllTiles(false);
    1557         }
     1551        // try to load tiles from desired zoom level, no matter what we will show (for example, tiles from previous zoom level
     1552        // on zoom in)
     1553        ts.loadAllTiles(false);
    15581554
    15591555        if (displayZoomLevel != zoom) {
Note: See TracChangeset for help on using the changeset viewer.