Changeset 13510 in josm for trunk/src


Ignore:
Timestamp:
2018-03-07T20:52:38+01:00 (7 years ago)
Author:
wiktorn
Message:

Add caching of Tile Size.

getTileSize() was taking about 20% of ImageWarp.warp().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r13439 r13510  
    102102        PATTERN_HEADER,
    103103    };
     104
     105    private int cachedTileSize = -1;
    104106
    105107    private static class TileMatrix {
     
    733735    @Override
    734736    public int getTileSize() {
     737        if (cachedTileSize > 0) {
     738            return cachedTileSize;
     739        }
    735740        if (tileProjection != null) {
    736741            // no support for non-square tiles (tileHeight != tileWidth)
     
    738743            Collection<Layer> projLayers = getLayers(null, tileProjection.toCode());
    739744            if (!projLayers.isEmpty()) {
    740                 return projLayers.iterator().next().tileMatrixSet.tileMatrix.get(0).tileHeight;
     745                cachedTileSize = projLayers.iterator().next().tileMatrixSet.tileMatrix.get(0).tileHeight;
     746                return cachedTileSize;
    741747            }
    742748        }
Note: See TracChangeset for help on using the changeset viewer.