Changeset 17494 in josm
- Timestamp:
- 2021-02-20T01:05:00+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r17492 r17494 1570 1570 ts.overloadTiles(); 1571 1571 } 1572 int[] otherZooms = {1, 2, -1, -2, -3, -4, -5}; 1573 for (int zoomOffset : otherZooms) { 1574 if (!getDisplaySettings().isAutoZoom()) { 1575 break; 1576 } 1577 int newzoom = displayZoomLevel + zoomOffset; 1578 if (newzoom < getMinZoomLvl() || newzoom > getMaxZoomLvl()) { 1579 continue; 1580 } 1581 if (missedTiles.isEmpty()) { 1582 break; 1583 } 1584 List<Tile> newlyMissedTiles = new LinkedList<>(); 1585 for (Tile missed : missedTiles) { 1586 if (zoomOffset > 0 && "no-tile".equals(missed.getValue("tile-info"))) { 1587 // Don't try to paint from higher zoom levels when tile is overzoomed 1588 newlyMissedTiles.add(missed); 1589 continue; 1590 } 1591 TileSet ts2 = new TileSet(tileSource.getCoveringTileRange(missed, newzoom)); 1592 // Instantiating large TileSets is expensive. If there are no loaded tiles, don't bother even trying. 1593 if (ts2.allLoadedTiles().isEmpty()) { 1594 if (zoomOffset > 0) { 1595 newlyMissedTiles.add(missed); 1596 continue; 1597 } else { 1598 /* 1599 * We have negative zoom offset. Try to load tiles from lower zoom levels, as they may be not present 1600 * in tile cache (e.g. when user panned the map or opened layer above zoom level, for which tiles are present. 1601 * This will ensure, that tileCache is populated with tiles from lower zoom levels so it will be possible to 1602 * use them to paint overzoomed tiles. 1603 * See: #14562 1604 */ 1605 ts2.loadAllTiles(false); 1606 } 1607 } 1608 if (ts2.tooLarge()) { 1609 continue; 1610 } 1611 newlyMissedTiles.addAll(this.paintTileImages(g, ts2, newzoom, missed)); 1612 } 1613 missedTiles = newlyMissedTiles; 1614 } 1572 if (getDisplaySettings().isAutoZoom()) { 1573 int[] otherZooms = {1, 2, -1, -2, -3, -4, -5}; 1574 1575 for(int otherZoom: otherZooms) { 1576 missedTiles = tryLoadFromDifferentZoom(g, displayZoomLevel, missedTiles, otherZoom); 1577 if (missedTiles.isEmpty()) { 1578 break; 1579 } 1580 } 1581 } 1582 1615 1583 if (Logging.isDebugEnabled() && !missedTiles.isEmpty()) { 1616 1584 Logging.debug("still missed {0} in the end", missedTiles.size()); … … 1655 1623 } 1656 1624 } 1625 } 1626 1627 private List<Tile> tryLoadFromDifferentZoom(Graphics2D g, int displayZoomLevel, List<Tile> missedTiles, 1628 int zoomOffset) { 1629 1630 int newzoom = displayZoomLevel + zoomOffset; 1631 if (newzoom < getMinZoomLvl() || newzoom > getMaxZoomLvl()) { 1632 return missedTiles; 1633 } 1634 1635 List<Tile> newlyMissedTiles = new LinkedList<>(); 1636 for (Tile missed : missedTiles) { 1637 if (zoomOffset > 0 && "no-tile".equals(missed.getValue("tile-info"))) { 1638 // Don't try to paint from higher zoom levels when tile is overzoomed 1639 newlyMissedTiles.add(missed); 1640 continue; 1641 } 1642 TileSet ts2 = new TileSet(tileSource.getCoveringTileRange(missed, newzoom)); 1643 // Instantiating large TileSets is expensive. If there are no loaded tiles, don't bother even trying. 1644 if (ts2.allLoadedTiles().isEmpty()) { 1645 if (zoomOffset > 0) { 1646 newlyMissedTiles.add(missed); 1647 continue; 1648 } else { 1649 /* 1650 * We have negative zoom offset. Try to load tiles from lower zoom levels, as they may be not present 1651 * in tile cache (e.g. when user panned the map or opened layer above zoom level, for which tiles are present. 1652 * This will ensure, that tileCache is populated with tiles from lower zoom levels so it will be possible to 1653 * use them to paint overzoomed tiles. 1654 * See: #14562 1655 */ 1656 ts2.loadAllTiles(false); 1657 } 1658 } 1659 if (ts2.tooLarge()) { 1660 continue; 1661 } 1662 newlyMissedTiles.addAll(this.paintTileImages(g, ts2, newzoom, missed)); 1663 } 1664 return newlyMissedTiles; 1657 1665 } 1658 1666 … … 1863 1871 public void cancel() { 1864 1872 if (tileLoader instanceof TMSCachedTileLoader) { 1865 ((TMSCachedTileLoader) tileLoader).cancelOutstandingTasks(); 1873 TMSCachedTileLoader cachedTileLoader = (TMSCachedTileLoader) tileLoader; 1874 cachedTileLoader.cancelOutstandingTasks(); 1875 cachedTileLoader.getDownloadExecutor().shutdown(); 1866 1876 } 1867 1877 } … … 1879 1889 } else { 1880 1890 Logging.warn("Tile loading failure: " + tile + " - " + tile.getErrorMessage()); 1891 } 1892 if (tileLoader instanceof TMSCachedTileLoader) { 1893 TMSCachedTileLoader cachedTileLoader = (TMSCachedTileLoader) tileLoader; 1894 cachedTileLoader.cancelOutstandingTasks(); 1895 cachedTileLoader.getDownloadExecutor().shutdown(); 1881 1896 } 1882 1897 } … … 1936 1951 MapView.removeZoomChangeListener(this); 1937 1952 adjustAction.destroy(); 1953 if (tileLoader instanceof TMSCachedTileLoader) { 1954 TMSCachedTileLoader cachedTileLoader = (TMSCachedTileLoader) tileLoader; 1955 cachedTileLoader.getDownloadExecutor().shutdown(); 1956 } 1938 1957 } 1939 1958
Note:
See TracChangeset
for help on using the changeset viewer.