Ignore:
Timestamp:
2010-02-06T13:17:41+01:00 (15 years ago)
Author:
daviddean
Message:

Slippymap plugin can now accept custom_tile_sources with non-standard tilepaths. (For example NearMap uses &z=%z&x=%x&y=%y instead of /%z/%x/%y)
Just specify the path in slippymap.custom_tile_source_*.path using %z,%x and %y to show where the numbers go.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferences.java

    r19521 r19887  
    299299
    300300    public static class Custom extends OsmTileSource.AbstractOsmTileSource {
     301
     302        String extension;
     303        String path;
     304
    301305        public Custom(String name, String url) {
    302306            super(name, url);
     
    306310            this.extension = extension;
    307311        }
    308         String extension;
     312        public Custom(String name, String url, String extension, String path) {
     313            super(name, url);
     314            this.extension = extension;
     315            this.path = path;
     316        }
     317
    309318        @Override
    310319        public String getExtension() {
     
    313322            return extension;
    314323        }
     324
     325        @Override
     326        public int getMaxZoom() {
     327            return 21;
     328        }
     329
     330        @Override
     331        public String getTilePath(int zoom, int tilex, int tiley) {
     332            if (path == null)
     333                return super.getTilePath(zoom,tilex,tiley);
     334            String tilepath = path;
     335            tilepath=tilepath.replaceAll("%z",String.valueOf(zoom));
     336            tilepath=tilepath.replaceAll("%x",String.valueOf(tilex));
     337            tilepath=tilepath.replaceAll("%y",String.valueOf(tiley));
     338            return tilepath;
     339        }
     340
    315341        public TileUpdate getTileUpdate() {
    316342            return TileUpdate.IfNoneMatch;
     
    327353            // slippymap.custom_tile_source_1.url=http://a.ooc.openstreetmap.org/npe
    328354            // slippymap.custom_tile_source_1.ext=png
     355            // slippymap.custom_tile_source_1.path=/%z/%x/%y
    329356
    330357            if (!(short_key.endsWith("name")))
     
    332359            String url_key = short_key.replaceFirst("name","url");
    333360            String ext_key = short_key.replaceFirst("name","ext");
     361            String path_key = short_key.replaceFirst("name","path");
    334362            String name = customSources.get(key);
    335363            String url = customSources.get(PREFERENCE_TILE_CUSTOM_SOURCE + url_key);
    336364            String ext = customSources.get(PREFERENCE_TILE_CUSTOM_SOURCE + ext_key);
    337             // ext may be null, but that's OK
    338             System.out.println("found new tile source: '" +name+"' url:'"+url+"'"+"' ext:'"+ext+"'");
    339             ret.add(new Custom(name, url, ext));
     365            String path = customSources.get(PREFERENCE_TILE_CUSTOM_SOURCE + path_key);
     366            // ext and path may be null, but that's OK
     367            System.out.println("found new tile source: '" +name+"' url:'"+url+"'"+"' ext:'"+ext+"' path:'"+path+"'");
     368            ret.add(new Custom(name, url, ext, path));
    340369        }
    341370        return ret;
Note: See TracChangeset for help on using the changeset viewer.