Changeset 16392 in osm for applications/viewer/jmapviewer


Ignore:
Timestamp:
2009-07-09T00:12:50+02:00 (15 years ago)
Author:
szeller
Message:

added possibility to define a cache directory for tiles

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java

    r13758 r16392  
    2828 *
    2929 * @author Jan Peter Stotz
     30 * @author Stefan Zeller
    3031 */
    3132public class OsmFileCacheTileLoader extends OsmTileLoader {
     
    4546    protected long recheckAfter = FILE_AGE_ONE_DAY;
    4647
    47     public OsmFileCacheTileLoader(TileLoaderListener map) {
     48    /**
     49     * Create a OSMFileCacheTileLoader with given cache directory.
     50     * If cacheDir is <code>null</code> the system property temp dir
     51     * is used. If not set an IOException will be thrown.
     52     * @param map
     53     * @param cacheDir
     54     */
     55    public OsmFileCacheTileLoader(TileLoaderListener map, File cacheDir) {
    4856        super(map);
    4957        String tempDir = System.getProperty("java.io.tmpdir");
    5058        try {
    51             if (tempDir == null)
     59            if (cacheDir == null) {
     60                if (tempDir == null) {
     61                    throw new IOException("No temp directory set");
     62                }
     63                cacheDir = new File(tempDir, "JMapViewerTiles");
     64            }
     65            log.finest("Tile cache directory: " + cacheDir);
     66            if (!cacheDir.exists() && !cacheDir.mkdirs()) {
    5267                throw new IOException();
    53             File cacheDir = new File(tempDir, "JMapViewerTiles");
    54             log.finest("Tile cache directory: " + cacheDir);
    55             if (!cacheDir.exists() && !cacheDir.mkdirs())
    56                 throw new IOException();
     68            }
    5769            cacheDirBase = cacheDir.getAbsolutePath();
    5870        } catch (Exception e) {
    5971            cacheDirBase = "tiles";
    6072        }
     73    }
     74   
     75    /**
     76     * Create a OSMFileCacheTileLoader with system property temp dir.
     77     * If not set an IOException will be thrown.
     78     * @param map
     79     */
     80    public OsmFileCacheTileLoader(TileLoaderListener map) {
     81        this(map, null);
    6182    }
    6283
Note: See TracChangeset for help on using the changeset viewer.