Changeset 31122 in osm
- Timestamp:
- 2015-05-10T13:26:49+02:00 (10 years ago)
- 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 332 332 loaded = true; 333 333 } 334 335 /** 336 * 337 * @return TileSource from which this tile comes 338 */ 339 public TileSource getTileSource() { 340 return source; 341 } 334 342 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java
r30900 r31122 3 3 4 4 import java.io.IOException; 5 import java.util.List; 6 import java.util.Map; 5 7 6 8 import org.openstreetmap.gui.jmapviewer.JMapViewer; … … 156 158 */ 157 159 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); 158 171 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractOsmTileSource.java
r30900 r31122 7 7 8 8 /** 9 * Abstract clas for OSM Tile sources9 * Abstract class for OSM Tile sources 10 10 */ 11 11 public abstract class AbstractOsmTileSource extends AbstractTMSTileSource { … … 24 24 */ 25 25 public AbstractOsmTileSource(String name, String base_url, String id) { 26 super(name, base_url, id); 26 super(new TileSourceInfo(name, base_url, id)); 27 27 28 } 28 29 30 @Override 29 31 public int getMaxZoom() { 30 32 return 19; -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java
r30900 r31122 3 3 4 4 import java.io.IOException; 5 import java.util.List; 6 import java.util.Map; 7 import java.util.Map.Entry; 5 8 6 9 import org.openstreetmap.gui.jmapviewer.OsmMercator; … … 11 14 protected String baseUrl; 12 15 protected String id; 16 private Map<String, String> noTileHeaders; 13 17 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(); 17 21 if(baseUrl.endsWith("/")) { 18 22 baseUrl = baseUrl.substring(0,baseUrl.length()-1); 19 23 } 20 this.id = id; 24 this.id = info.getUrl(); 25 this.noTileHeaders = info.getNoTileHeaders(); 21 26 } 22 27 … … 123 128 return OsmMercator.XToLon(x * OsmMercator.TILE_SIZE, zoom); 124 129 } 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 } 125 143 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTileSource.java
r30223 r31122 3 3 4 4 import java.awt.Image; 5 import java.util.List; 6 import java.util.Map; 5 7 8 import org.openstreetmap.gui.jmapviewer.Coordinate; 6 9 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 7 import org.openstreetmap.gui.jmapviewer.Coordinate;8 10 9 11 abstract public class AbstractTileSource implements TileSource { … … 75 77 } 76 78 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 } 77 83 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
r30900 r31122 53 53 */ 54 54 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); 63 60 } 64 61 -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java
r30900 r31122 46 46 private ScanexLayer Layer = ScanexLayer.IRS; 47 47 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(); 50 51 51 52 for (ScanexLayer layer : ScanexLayer.values()) { … … 78 79 } 79 80 81 @Override 80 82 public TileUpdate getTileUpdate() { 81 83 return TileUpdate.IfNoneMatch; -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java
r30900 r31122 1 1 // License: GPL. For details, see Readme.txt file. 2 2 package org.openstreetmap.gui.jmapviewer.tilesources; 3 3 4 4 5 public class TMSTileSource extends AbstractTMSTileSource { … … 7 8 protected int minZoom = 0; 8 9 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(); 18 14 } 19 15 -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSource.java
r30933 r31122 2 2 package org.openstreetmap.gui.jmapviewer.tilesources; 3 3 4 import java.util.HashMap; 4 5 import java.util.Map; 5 import java.util.HashMap;6 6 import java.util.Random; 7 import java.util.regex.Matcher; 7 8 import java.util.regex.Pattern; 8 import java.util.regex.Matcher;9 9 10 10 public class TemplatedTMSTileSource extends TMSTileSource { … … 28 28 }; 29 29 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()); 44 34 } 45 35 handleTemplate();
Note:
See TracChangeset
for help on using the changeset viewer.