Changeset 31122 in osm for applications/viewer


Ignore:
Timestamp:
2015-05-10T13:26:49+02:00 (9 years ago)
Author:
bastik
Message:

applied #josm10454 - Mapbox "empty" tile (imagery with zoom level > 17) (patch by wiktorn)

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

Legend:

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

    r31118 r31122  
    332332        loaded = true;
    333333    }
     334
     335    /**
     336     *
     337     * @return TileSource from which this tile comes
     338     */
     339    public TileSource getTileSource() {
     340        return source;
     341    }
    334342}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java

    r30900 r31122  
    33
    44import java.io.IOException;
     5import java.util.List;
     6import java.util.Map;
    57
    68import org.openstreetmap.gui.jmapviewer.JMapViewer;
     
    156158     */
    157159    double tileYToLat(int y, int zoom);
     160
     161    /**
     162     * Determines, if the returned data from TileSource represent "no tile at this zoom level" situation. Detection
     163     * algorithms differ per TileSource, so each TileSource should implement each own specific way.
     164     *
     165     * @param headers HTTP headers from response from TileSource server
     166     * @param statusCode HTTP status code
     167     * @param content byte array representing the data returned from the server
     168     * @return true, if "no tile at this zoom level" situation detected
     169     */
     170    public boolean isNoTileAtZoom(Map<String, List<String>> headers, int statusCode, byte[] content);
    158171}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractOsmTileSource.java

    r30900 r31122  
    77
    88/**
    9  * Abstract clas for OSM Tile sources
     9 * Abstract class for OSM Tile sources
    1010 */
    1111public abstract class AbstractOsmTileSource extends AbstractTMSTileSource {
     
    2424     */
    2525    public AbstractOsmTileSource(String name, String base_url, String id) {
    26         super(name, base_url, id);
     26        super(new TileSourceInfo(name, base_url, id));
     27
    2728    }
    2829
     30    @Override
    2931    public int getMaxZoom() {
    3032        return 19;
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java

    r30900 r31122  
    33
    44import java.io.IOException;
     5import java.util.List;
     6import java.util.Map;
     7import java.util.Map.Entry;
    58
    69import org.openstreetmap.gui.jmapviewer.OsmMercator;
     
    1114    protected String baseUrl;
    1215    protected String id;
     16    private Map<String, String> noTileHeaders;
    1317
    14     public AbstractTMSTileSource(String name, String base_url, String id) {
    15         this.name = name;
    16         this.baseUrl = base_url;
     18    public AbstractTMSTileSource(TileSourceInfo info) {
     19        this.name = info.getName();
     20        this.baseUrl = info.getUrl();
    1721        if(baseUrl.endsWith("/")) {
    1822            baseUrl = baseUrl.substring(0,baseUrl.length()-1);
    1923        }
    20         this.id = id;
     24        this.id = info.getUrl();
     25        this.noTileHeaders = info.getNoTileHeaders();
    2126    }
    2227
     
    123128        return OsmMercator.XToLon(x * OsmMercator.TILE_SIZE, zoom);
    124129    }
     130
     131    @Override
     132    public boolean isNoTileAtZoom(Map<String, List<String>> headers, int statusCode, byte[] content) {
     133        if(noTileHeaders != null) {
     134            for (Entry<String, String> searchEntry: noTileHeaders.entrySet()) {
     135                List<String> headerVals = headers.get(searchEntry.getKey());
     136                if (headerVals != null && headerVals.contains(searchEntry.getValue())) {
     137                    return true;
     138                }
     139            }
     140        }
     141        return super.isNoTileAtZoom(headers, statusCode, content);
     142    }
    125143}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTileSource.java

    r30223 r31122  
    33
    44import java.awt.Image;
     5import java.util.List;
     6import java.util.Map;
    57
     8import org.openstreetmap.gui.jmapviewer.Coordinate;
    69import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
    7 import org.openstreetmap.gui.jmapviewer.Coordinate;
    810
    911abstract public class AbstractTileSource implements TileSource {
     
    7577    }
    7678
     79    public boolean isNoTileAtZoom(Map<String, List<String>> headers, int statusCode, byte[] content) {
     80        // default handler - when HTTP 404 is returned, then treat this situation as no tile at this zoom level
     81        return statusCode == 404;
     82    }
    7783}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java

    r30900 r31122  
    5353     */
    5454    public BingAerialTileSource() {
    55         this("Bing");
    56     }
    57 
    58     /**
    59      * Constructs a new {@code BingAerialTileSource}.
    60      */
    61     public BingAerialTileSource(String id) {
    62         super("Bing Aerial Maps", "http://example.com/", id);
     55        super(new TileSourceInfo("Bing", null, null));
     56    }
     57
     58    public BingAerialTileSource(TileSourceInfo info) {
     59        super(info);
    6360    }
    6461
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java

    r30900 r31122  
    4646    private ScanexLayer Layer = ScanexLayer.IRS;
    4747
    48     public ScanexTileSource(String name, String url, String id, int maxZoom) {
    49         super(name, url, id, maxZoom);
     48    public ScanexTileSource(TileSourceInfo info) {
     49        super(info);
     50        String url = info.getUrl();
    5051
    5152        for (ScanexLayer layer : ScanexLayer.values()) {
     
    7879    }
    7980
     81    @Override
    8082    public TileUpdate getTileUpdate() {
    8183        return TileUpdate.IfNoneMatch;
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java

    r30900 r31122  
    11// License: GPL. For details, see Readme.txt file.
    22package org.openstreetmap.gui.jmapviewer.tilesources;
     3
    34
    45public class TMSTileSource extends AbstractTMSTileSource {
     
    78    protected int minZoom = 0;
    89
    9     public TMSTileSource(String name, String url, String id, int maxZoom) {
    10         super(name, url, id);
    11         this.maxZoom = maxZoom;
    12     }
    13 
    14     public TMSTileSource(String name, String url, String id, int minZoom, int maxZoom) {
    15         super(name, url, id);
    16         this.minZoom = minZoom;
    17         this.maxZoom = maxZoom;
     10    public TMSTileSource(TileSourceInfo info) {
     11        super(info);
     12        minZoom = info.getMinZoom();
     13        maxZoom = info.getMaxZoom();
    1814    }
    1915
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSource.java

    r30933 r31122  
    22package org.openstreetmap.gui.jmapviewer.tilesources;
    33
     4import java.util.HashMap;
    45import java.util.Map;
    5 import java.util.HashMap;
    66import java.util.Random;
     7import java.util.regex.Matcher;
    78import java.util.regex.Pattern;
    8 import java.util.regex.Matcher;
    99
    1010public class TemplatedTMSTileSource extends TMSTileSource {
     
    2828    };
    2929
    30     public TemplatedTMSTileSource(String name, String url, String id, int maxZoom) {
    31         super(name, url, id, maxZoom);
    32         handleTemplate();
    33     }
    34 
    35     public TemplatedTMSTileSource(String name, String url, String id, int minZoom, int maxZoom) {
    36         super(name, url, id, minZoom, maxZoom);
    37         handleTemplate();
    38     }
    39 
    40     public TemplatedTMSTileSource(String name, String url, String id, int minZoom, int maxZoom, String cookies) {
    41         super(name, url, id, minZoom, maxZoom);
    42         if (cookies != null) {
    43             headers.put(COOKIE_HEADER, cookies);
     30    public TemplatedTMSTileSource(TileSourceInfo info) {
     31        super(info);
     32        if (info.getCookies() != null) {
     33            headers.put(COOKIE_HEADER, info.getCookies());
    4434        }
    4535        handleTemplate();
Note: See TracChangeset for help on using the changeset viewer.