Changeset 26950 in osm
- Timestamp:
- 2011-10-23T14:39:08+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSource.java
r26938 r26950 13 13 private Map<String, String> headers = new HashMap<String, String>(); 14 14 15 public static final String PATTERN_ZOOM = "\\{ zoom([+-]\\d+)?\\}";15 public static final String PATTERN_ZOOM = "\\{(?:(\\d+)-)?zoom([+-]\\d+)?\\}"; 16 16 public static final String PATTERN_X = "\\{x\\}"; 17 17 public static final String PATTERN_Y = "\\{y\\}"; 18 18 public static final String PATTERN_Y_YAHOO = "\\{!y\\}"; 19 public static final String PATTERN_SWITCH = "\\{switch: [^}]+\\}";19 public static final String PATTERN_SWITCH = "\\{switch:([^}]+)\\}"; 20 20 public static final String PATTERN_HEADER = "\\{header\\(([^,]+),([^}]+)\\)\\}"; 21 21 … … 58 58 @Override 59 59 public String getTileUrl(int zoom, int tilex, int tiley) { 60 int finalZoom = zoom; 60 61 Matcher m = Pattern.compile(".*"+PATTERN_ZOOM+".*").matcher(this.baseUrl); 61 if (m.matches() && !m.group(1).isEmpty()) { 62 String ofs = m.group(1); 63 if(ofs.startsWith("+")) 64 ofs = ofs.substring(1); 65 zoom += Integer.valueOf(ofs); 62 if (m.matches()) { 63 if(m.group(1) != null) { 64 finalZoom = Integer.valueOf(m.group(1))-zoom; 65 } 66 if(m.group(2) != null) { 67 String ofs = m.group(2); 68 if(ofs.startsWith("+")) 69 ofs = ofs.substring(1); 70 finalZoom += Integer.valueOf(ofs); 71 } 66 72 } 67 73 String r = this.baseUrl 68 .replaceAll(PATTERN_ZOOM, Integer.toString( zoom))74 .replaceAll(PATTERN_ZOOM, Integer.toString(finalZoom)) 69 75 .replaceAll(PATTERN_X, Integer.toString(tilex)) 70 76 .replaceAll(PATTERN_Y, Integer.toString(tiley)) 71 .replaceAll(PATTERN_Y_YAHOO, Integer.toString((int)Math.pow(2, zoom )-1-tiley));77 .replaceAll(PATTERN_Y_YAHOO, Integer.toString((int)Math.pow(2, zoom-1)-1-tiley)); 72 78 if (rand != null) { 73 79 r = r.replaceAll(PATTERN_SWITCH, randomParts[rand.nextInt(randomParts.length)]);
Note:
See TracChangeset
for help on using the changeset viewer.