Changeset 32021 in osm for applications/viewer/jmapviewer/src
- Timestamp:
- 2016-01-24T14:39:06+01:00 (9 years ago)
- Location:
- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java
r31573 r32021 4 4 import java.awt.Point; 5 5 import java.io.IOException; 6 import java.security.MessageDigest; 7 import java.security.NoSuchAlgorithmException; 6 8 import java.util.HashMap; 7 9 import java.util.List; … … 27 29 protected String id; 28 30 private final Map<String, String> noTileHeaders; 31 private final Map<String, String> noTileChecksums; 29 32 private final Map<String, String> metadataHeaders; 30 33 protected int tileSize; … … 44 47 this.id = info.getUrl(); 45 48 this.noTileHeaders = info.getNoTileHeaders(); 49 this.noTileChecksums = info.getNoTileChecksums(); 46 50 this.metadataHeaders = info.getMetadataHeaders(); 47 51 this.tileSize = info.getTileSize(); … … 219 223 } 220 224 } 225 if (noTileChecksums != null) { 226 for (Entry<String, String> searchEntry: noTileChecksums.entrySet()) { 227 MessageDigest md = null; 228 try { 229 md = MessageDigest.getInstance(searchEntry.getKey()); 230 } catch (NoSuchAlgorithmException e) { 231 break; 232 } 233 byte[] byteDigest = md.digest(content); 234 final int len = byteDigest.length; 235 236 char[] hexChars = new char[len * 2]; 237 for (int i = 0, j = 0; i < len; i++) { 238 final int v = byteDigest[i]; 239 int vn = (v & 0xf0) >> 4; 240 hexChars[j++] = (char)(vn + (vn >= 10 ? 'a'-10 : '0')); 241 vn = (v & 0xf); 242 hexChars[j++] = (char)(vn + (vn >= 10 ? 'a'-10 : '0')); 243 } 244 if (new String(hexChars).equalsIgnoreCase(searchEntry.getValue())) { 245 return true; 246 } 247 } 248 } 221 249 return super.isNoTileAtZoom(headers, statusCode, content); 222 250 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TileSourceInfo.java
r31791 r32021 23 23 /** headers meaning, that there is no tile at this zoom level */ 24 24 protected Map<String, String> noTileHeaders; 25 26 /** checksum of empty tiles */ 27 protected Map<String, String> noTileChecksums; 25 28 26 29 /** minimum zoom level supported by the tile source */ … … 102 105 103 106 /** 107 * Checkusm for empty tiles for servers delivering such tile types 108 * @return map of checksums, that when detected, means that this is "no tile at this zoom level" situation 109 * @since 32021 110 */ 111 public Map<String, String> getNoTileChecksums() { 112 return noTileChecksums; 113 } 114 115 /** 104 116 * Request supported minimum zoom level 105 117 * @return minimum zoom level supported by tile source
Note:
See TracChangeset
for help on using the changeset viewer.