Changeset 7823 in josm


Ignore:
Timestamp:
2014-12-18T23:00:19+01:00 (9 years ago)
Author:
bastiK
Message:

see #5309 - too many files in tile cache (see [o30854])
Set Einstein pref tms.newcache=true to test the new cache, it is not yet activated by default.

File:
1 edited

Legend:

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

    r7329 r7823  
    4646import org.openstreetmap.gui.jmapviewer.OsmFileCacheTileLoader;
    4747import org.openstreetmap.gui.jmapviewer.OsmTileLoader;
     48import org.openstreetmap.gui.jmapviewer.TMSFileCacheTileLoader;
    4849import org.openstreetmap.gui.jmapviewer.Tile;
    4950import org.openstreetmap.gui.jmapviewer.interfaces.CachedTileLoader;
     
    110111    public static final IntegerProperty PROP_TMS_JOBS = new IntegerProperty("tmsloader.maxjobs", 25);
    111112    public static final StringProperty PROP_TILECACHE_DIR;
     113   
     114    private static final boolean newcache = Main.pref.getBoolean("tms.newcache");
    112115
    113116    static {
    114117        String defPath = null;
    115118        try {
    116             defPath = OsmFileCacheTileLoader.getDefaultCacheDir().getAbsolutePath();
     119            if (newcache) {
     120                defPath = new File(Main.pref.getCacheDirectory(), "tms").getAbsolutePath();
     121            } else {
     122                defPath = OsmFileCacheTileLoader.getDefaultCacheDir().getAbsolutePath();
     123            }
    117124        } catch (SecurityException e) {
    118125            Main.warn(e);
    119126        }
    120         PROP_TILECACHE_DIR = new StringProperty(PREFERENCE_PREFIX + ".tilecache_path", defPath);
     127        PROP_TILECACHE_DIR = new StringProperty(PREFERENCE_PREFIX + (newcache ? ".tilecache" : ".tilecache_path"), defPath);
    121128    }
    122129
     
    135142            if (cachePath != null && !cachePath.isEmpty()) {
    136143                try {
    137                     OsmFileCacheTileLoader loader = new OsmFileCacheTileLoader(listener, new File(cachePath));
     144                    OsmFileCacheTileLoader loader;
     145                    if (newcache) {
     146                        loader = new TMSFileCacheTileLoader(listener, new File(cachePath));
     147                    } else {
     148                        loader = new OsmFileCacheTileLoader(listener, new File(cachePath));
     149                    }
    138150                    loader.headers.put("User-Agent", Version.getInstance().getFullAgentString());
    139151                    return loader;
     
    319331    private static class CachedAttributionBingAerialTileSource extends BingAerialTileSource {
    320332
     333        public CachedAttributionBingAerialTileSource(String id) {
     334            super(id);
     335        }
     336
    321337        class BingAttributionData extends CacheCustomContent<IOException> {
    322338
     
    374390        if (info.getImageryType() == ImageryType.TMS) {
    375391            checkUrl(info.getUrl());
    376             TMSTileSource t = new TemplatedTMSTileSource(info.getName(), info.getUrl(), info.getMinZoom(), info.getMaxZoom());
     392            TMSTileSource t = new TemplatedTMSTileSource(info.getName(), info.getUrl(), info.getId(), info.getMinZoom(), info.getMaxZoom());
    377393            info.setAttribution(t);
    378394            return t;
    379395        } else if (info.getImageryType() == ImageryType.BING)
    380             return new CachedAttributionBingAerialTileSource();
     396            return new CachedAttributionBingAerialTileSource(info.getId());
    381397        else if (info.getImageryType() == ImageryType.SCANEX) {
    382             return new ScanexTileSource(info.getName(), info.getUrl(), info.getMaxZoom());
     398            return new ScanexTileSource(info.getName(), info.getUrl(), info.getId(), info.getMaxZoom());
    383399        }
    384400        return null;
Note: See TracChangeset for help on using the changeset viewer.