Ignore:
Timestamp:
2016-07-17T12:40:18+02:00 (8 years ago)
Author:
wiktorn
Message:

Use stale cache tiles if IOException occurs

  • small pretty print fixes (MemoryTileCache, TileSet)
  • increase TileCache estimate (to accomodate larger TileSet's traverses when in offline mode)
  • fix TileSet computations, sometimes it generated tileset of size 2 instead of 4 (for tiles inside the tile)

Closes: #13128

File:
1 edited

Legend:

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

    r10534 r10545  
    703703        int ret = (int) Math.ceil(
    704704                Math.pow(2d, ZOOM_OFFSET.get()) * visibileTiles // use offset to decide, how many tiles are visible
    705                 * 2);
     705                * 4);
    706706        Main.info("AbstractTileSourceLayer: estimated visible tiles: {0}, estimated cache size: {1}", visibileTiles, ret);
    707707        return ret;
     
    12051205
    12061206
    1207     private final TileSet nullTileSet = new TileSet((LatLon) null, (LatLon) null, 0);
     1207    private final TileSet nullTileSet = new TileSet();
    12081208
    12091209    private final class MapWrappingTileSet extends TileSet {
     
    12541254            TileXY t2 = tileSource.latLonToTileXY(botRight.toCoordinate(), zoom);
    12551255
    1256             x0 = t1.getXIndex();
    1257             y0 = t1.getYIndex();
    1258             x1 = t2.getXIndex();
    1259             y1 = t2.getYIndex();
     1256            x0 = (int) Math.floor(t1.getX());
     1257            y0 = (int) Math.floor(t1.getY());
     1258            x1 = (int) Math.ceil(t2.getX());
     1259            y1 = (int) Math.ceil(t2.getY());
    12601260            sanitize();
     1261
     1262        }
     1263
     1264        private TileSet(Tile topLeft, Tile botRight, int zoom) {
     1265        }
     1266
     1267        /**
     1268         * null tile set
     1269         */
     1270        private TileSet() {
     1271            return;
    12611272        }
    12621273
     
    13901401            }
    13911402        }
     1403
     1404        @Override
     1405        public String toString() {
     1406            return getClass().getName() + ": zoom: " + zoom + " X(" + x0 + ", " + x1 + ") Y(" + y0 + ", " + y1 + ") size: " + size();
     1407        }
    13921408    }
    13931409
     
    15581574                }
    15591575                Tile t2 = tempCornerTile(missed);
    1560                 LatLon topLeft2 = getShiftedLatLon(tileSource.tileXYToLatLon(missed));
    1561                 LatLon botRight2 = getShiftedLatLon(tileSource.tileXYToLatLon(t2));
    1562                 TileSet ts2 = new TileSet(topLeft2, botRight2, newzoom);
     1576                TileSet ts2 = new TileSet(
     1577                        getShiftedLatLon(tileSource.tileXYToLatLon(missed)),
     1578                        getShiftedLatLon(tileSource.tileXYToLatLon(t2)),
     1579                        newzoom);
    15631580                // Instantiating large TileSets is expensive.  If there
    15641581                // are no loaded tiles, don't bother even trying.
Note: See TracChangeset for help on using the changeset viewer.