- Timestamp:
- 2021-02-20T08:56:49+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r17494 r17495 639 639 tileSize = tileSource.getTileSize(); 640 640 } 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 */ 644 661 int ret = (int) Math.ceil( 645 662 Math.pow(2d, ZOOM_OFFSET.get()) * visibileTiles // use offset to decide, how many tiles are visible 646 * 4);663 * 8); 647 664 Logging.info("AbstractTileSourceLayer: estimated visible tiles: {0}, estimated cache size: {1}", visibileTiles, ret); 648 665 return ret; … … 1235 1252 1236 1253 private boolean tooLarge() { 1237 return insane() || this.tilesSpanned() > MAX_TILES_SPANNED;1238 }1239 1240 private boolean insane() {1241 1254 return tileCache == null || size() > tileCache.getCacheSize(); 1242 1255 } … … 1263 1276 */ 1264 1277 public Stream<TilePosition> tilePositions() { 1265 if (zoom == 0 || this. insane()) {1278 if (zoom == 0 || this.tooLarge()) { 1266 1279 return Stream.empty(); // Tileset is either empty or too large 1267 1280 } else { … … 1599 1612 g.setColor(Color.lightGray); 1600 1613 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()) { 1604 1615 myDrawString(g, tr("zoom in to load more tiles"), 120, 120); 1605 1616 } else if (!getDisplaySettings().isAutoZoom() && ts.tooSmall()) {
Note:
See TracChangeset
for help on using the changeset viewer.