Add in urlTemplate support of variables {z}, {x} and {0} interpreted like {0}, {1} and {2}.

Before now these variables were supported in some cases. Now they are supported always in both .metainso and sqlitedb.
No support in beanshell!
This commit is contained in:
ilasica 2015-02-20 15:01:00 +03:00
parent c916d94070
commit cd8736ee5b
2 changed files with 19 additions and 7 deletions

View file

@ -62,6 +62,14 @@ public class TileSourceManager {
this.bitDensity = bitDensity;
}
public static String normalizeUrl(String url){
if(url != null){
url = url.replaceAll("\\{\\$z\\}", "{0}"); //$NON-NLS-1$ //$NON-NLS-2$
url = url.replaceAll("\\{\\$x\\}", "{1}"); //$NON-NLS-1$//$NON-NLS-2$
url = url.replaceAll("\\{\\$y\\}", "{2}"); //$NON-NLS-1$ //$NON-NLS-2$
}
return url;
}
public void setMinZoom(int minZoom) {
this.minZoom = minZoom;
}
@ -343,9 +351,10 @@ public class TileSourceManager {
new FileInputStream(readUrl), "UTF-8")); //$NON-NLS-1$
url = reader.readLine();
//
url = url.replaceAll("\\{\\$z\\}", "{0}"); //$NON-NLS-1$ //$NON-NLS-2$
url = url.replaceAll("\\{\\$x\\}", "{1}"); //$NON-NLS-1$//$NON-NLS-2$
url = url.replaceAll("\\{\\$y\\}", "{2}"); //$NON-NLS-1$ //$NON-NLS-2$
//url = url.replaceAll("\\{\\$z\\}", "{0}"); //$NON-NLS-1$ //$NON-NLS-2$
//url = url.replaceAll("\\{\\$x\\}", "{1}"); //$NON-NLS-1$//$NON-NLS-2$
//url = url.replaceAll("\\{\\$y\\}", "{2}"); //$NON-NLS-1$ //$NON-NLS-2$
url = TileSourceTemplate.normalizeUrl(url);
reader.close();
}
} catch (IOException e) {
@ -478,9 +487,11 @@ public class TileSourceManager {
if (name == null || (urlTemplate == null && !ignoreTemplate)) {
return null;
}
if(urlTemplate != null){
urlTemplate.replace("${x}", "{1}").replace("${y}", "{2}").replace("${z}", "{0}");
}
//if(urlTemplate != null){
//urlTemplate.replace("${x}", "{1}").replace("${y}", "{2}").replace("${z}", "{0}");
//}
urlTemplate = TileSourceTemplate.normalizeUrl(urlTemplate);
int maxZoom = parseInt(attributes, "max_zoom", 18);
int minZoom = parseInt(attributes, "min_zoom", 5);
int tileSize = parseInt(attributes, "tile_size", 256);

View file

@ -180,7 +180,8 @@ public class SQLiteTileSource implements ITileSource {
if(url != -1) {
String template = cursor.getString(url);
if(!Algorithms.isEmpty(template)){
urlTemplate = template;
//urlTemplate = template;
urlTemplate = TileSourceTemplate.normalizeUrl(template);
}
}
int ruleId = list.indexOf("rule");