Changeset 30854 in osm for applications/viewer/jmapviewer


Ignore:
Timestamp:
2014-12-18T22:56:22+01:00 (10 years ago)
Author:
bastik
Message:

see #josm5309 - rework cache directory structure so you don't have too many files in in one directory
New cache is implemented in TMSFileCacheTileLoader. Old cache in OsmFileCacheTileLoader should work
as before.

Location:
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
Files:
1 added
12 edited

Legend:

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

    r30850 r30854  
    4545    private static final Logger log = FeatureAdapter.getLogger(OsmFileCacheTileLoader.class.getName());
    4646
    47     private static final String TAGS_FILE_EXT = ".tags";
     47    protected static final String TAGS_FILE_EXT = "tags";
    4848
    4949    private static final Charset TAGS_CHARSET = Charset.forName("UTF-8");
     
    392392
    393393        protected File getTagsFile() {
    394             return new File(tileCacheDir + "/" + tile.getZoom() + "_" + tile.getXtile() + "_" + tile.getYtile()
     394            return new File(tileCacheDir + "/" + tile.getZoom() + "_" + tile.getXtile() + "_" + tile.getYtile() + "."
    395395                    + TAGS_FILE_EXT);
    396396        }
    397397
    398398        protected void saveTileToFile(byte[] rawData) {
     399            File file = getTileFile();
     400            file.getParentFile().mkdirs();
    399401            try (
    400                 FileOutputStream f = new FileOutputStream(tileCacheDir + "/" + tile.getZoom() + "_" + tile.getXtile()
    401                         + "_" + tile.getYtile() + "." + tile.getSource().getTileType())
     402                FileOutputStream f = new FileOutputStream(file)
    402403            ) {
    403404                f.write(rawData);
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java

    r30248 r30854  
    6363
    6464    /**
    65      * A tile layer name has to be unique and has to consist only of characters
    66      * valid for filenames.
     65     * A tile layer name as displayed to the user.
    6766     *
    6867     * @return Name of the tile layer
    6968     */
    7069    String getName();
     70
     71    /**
     72     * A unique id for this tile source.
     73     *
     74     * Unlike the name it has to be unique and has to consist only of characters
     75     * valid for filenames.
     76     *
     77     * @return the id
     78     */
     79    String getId();
    7180
    7281    /**
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractMapQuestTileSource.java

    r30223 r30854  
    3131    private int SERVER_NUM = 1;
    3232
    33     public AbstractMapQuestTileSource(String name, String base_url) {
    34         super(name, base_url);
     33    public AbstractMapQuestTileSource(String name, String base_url, String id) {
     34        super(name, base_url, id);
    3535    }
    3636
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractOsmTileSource.java

    r30336 r30854  
    2020     * @param name Source name as displayed in GUI
    2121     * @param base_url Source URL
     22     * @param id unique id for the tile source; contains only characters that
     23     * are safe for file names; can be null
    2224     */
    23     public AbstractOsmTileSource(String name, String base_url) {
    24         super(name, base_url);
     25    public AbstractOsmTileSource(String name, String base_url, String id) {
     26        super(name, base_url, id);
    2527    }
    2628
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java

    r30248 r30854  
    1010    protected String name;
    1111    protected String baseUrl;
     12    protected String id;
    1213
    13     public AbstractTMSTileSource(String name, String base_url) {
     14    public AbstractTMSTileSource(String name, String base_url, String id) {
    1415        this.name = name;
    1516        this.baseUrl = base_url;
     
    1718            baseUrl = baseUrl.substring(0,baseUrl.length()-1);
    1819        }
     20        this.id = id;
    1921    }
    2022
     
    2224    public String getName() {
    2325        return name;
     26    }
     27
     28    @Override
     29    public String getId() {
     30        return id;
    2431    }
    2532
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java

    r30758 r30854  
    5252     * Constructs a new {@code BingAerialTileSource}.
    5353     */
    54     public BingAerialTileSource() {
    55         super("Bing Aerial Maps", "http://example.com/");
     54    public BingAerialTileSource(String id) {
     55        super("Bing Aerial Maps", "http://example.com/", id);
    5656    }
    5757
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/MapQuestOpenAerialTileSource.java

    r30223 r30854  
    99
    1010    public MapQuestOpenAerialTileSource() {
    11         super("MapQuest Open Aerial", PATTERN);
     11        super("MapQuest Open Aerial", PATTERN, "mapquest-oa");
    1212    }
    1313
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/MapQuestOsmTileSource.java

    r30223 r30854  
    99
    1010    public MapQuestOsmTileSource() {
    11         super("MapQuest-OSM", PATTERN);
     11        super("MapQuest-OSM", PATTERN, "mapquest-osm");
    1212    }
    1313   
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java

    r30628 r30854  
    2222         */
    2323        public Mapnik() {
    24             super("Mapnik", PATTERN);
     24            super("Mapnik", PATTERN, "MAPNIK");
    2525        }
    2626
     
    5757         */
    5858        public CycleMap() {
    59             super("Cyclemap", PATTERN);
     59            super("Cyclemap", PATTERN, "opencylemap");
    6060        }
    6161
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java

    r30628 r30854  
    4646    private ScanexLayer Layer = ScanexLayer.IRS;
    4747
    48     public ScanexTileSource(String name, String url, int maxZoom) {
    49         super(name, url, maxZoom);
     48    public ScanexTileSource(String name, String url, String id, int maxZoom) {
     49        super(name, url, id, maxZoom);
    5050
    5151        for (ScanexLayer layer : ScanexLayer.values()) {
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java

    r30849 r30854  
    77    protected int minZoom = 0;
    88
    9     public TMSTileSource(String name, String url, int maxZoom) {
    10         super(name, url);
     9    public TMSTileSource(String name, String url, String id, int maxZoom) {
     10        super(name, url, id);
    1111        this.maxZoom = maxZoom;
    1212    }
    1313
    14     public TMSTileSource(String name, String url, int minZoom, int maxZoom) {
    15         super(name, url);
     14    public TMSTileSource(String name, String url, String id, int minZoom, int maxZoom) {
     15        super(name, url, id);
    1616        this.minZoom = minZoom;
    1717        this.maxZoom = maxZoom;
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSource.java

    r30426 r30854  
    2727    };
    2828
    29     public TemplatedTMSTileSource(String name, String url, int maxZoom) {
    30         super(name, url, maxZoom);
     29    public TemplatedTMSTileSource(String name, String url, String id, int maxZoom) {
     30        super(name, url, id, maxZoom);
    3131        handleTemplate();
    3232    }
    3333
    34     public TemplatedTMSTileSource(String name, String url, int minZoom, int maxZoom) {
    35         super(name, url, minZoom, maxZoom);
     34    public TemplatedTMSTileSource(String name, String url, String id, int minZoom, int maxZoom) {
     35        super(name, url, id, minZoom, maxZoom);
    3636        handleTemplate();
    3737    }
Note: See TracChangeset for help on using the changeset viewer.