Ignore:
Timestamp:
2015-08-12T23:10:17+02:00 (9 years ago)
Author:
wiktorn
Message:

More performance improvements

  • Use one MemoryTileCache instance per multiple layers. This results in smaller memory footprint when working with many layers
  • fix default maximum TimeToLive in JCS
  • TemplatedWMSTileSource now caches degreesPerZoom, so it's not computed on every request
File:
1 edited

Legend:

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

    r8652 r8659  
    4343    private int[] tileXMax;
    4444    private int[] tileYMax;
     45    private double[] degreesPerTile;
    4546
    4647    private static final Pattern PATTERN_HEADER  = Pattern.compile("\\{header\\(([^,]+),([^}]+)\\)\\}");
     
    9596        tileXMax = new int[getMaxZoom() + 1];
    9697        tileYMax = new int[getMaxZoom() + 1];
     98        degreesPerTile = new double[getMaxZoom() +1];
    9799        for (int zoom = getMinZoom(); zoom <= getMaxZoom(); zoom++) {
    98100            TileXY maxTileIndex = latLonToTileXY(bottomRight.toCoordinate(), zoom);
    99101            tileXMax[zoom] = maxTileIndex.getXIndex();
    100102            tileYMax[zoom] = maxTileIndex.getYIndex();
    101         }
     103            int tilesPerZoom = (int) Math.pow(2d, zoom - 1);
     104            degreesPerTile[zoom] = Math.max(
     105                    Math.abs(max.getY() - min.getY()) / tilesPerZoom,
     106                    Math.abs(max.getX() - min.getX()) / tilesPerZoom
     107                    );
     108
     109        }
     110
    102111    }
    103112
     
    382391
    383392    private double getDegreesPerTile(int zoom) {
    384         Projection proj = Main.getProjection();
    385         EastNorth min = proj.latlon2eastNorth(worldBounds.getMin());
    386         EastNorth max = proj.latlon2eastNorth(worldBounds.getMax());
    387 
    388         int tilesPerZoom = (int) Math.pow(2d, zoom - 1);
    389         return Math.max(
    390                 Math.abs(max.getY() - min.getY()) / tilesPerZoom,
    391                 Math.abs(max.getX() - min.getX()) / tilesPerZoom
    392                 );
     393        return degreesPerTile[zoom];
    393394    }
    394395
Note: See TracChangeset for help on using the changeset viewer.