simplification, compatibility with MOBAC scripts
This commit is contained in:
parent
7f18152915
commit
07b1117a20
2 changed files with 12 additions and 25 deletions
|
@ -198,7 +198,6 @@ public class TileSourceManager {
|
|||
Map<String, String> properties = new LinkedHashMap<String, String>();
|
||||
if(tm instanceof BeanShellTileSourceTemplate){
|
||||
properties.put("rule", RULE_BEANSHELL);
|
||||
properties.put("init_script", ((BeanShellTileSourceTemplate) tm).getInitScript());
|
||||
}
|
||||
if(tm.getUrlTemplate() == null){
|
||||
return;
|
||||
|
@ -382,7 +381,6 @@ public class TileSourceManager {
|
|||
private static TileSourceTemplate createBeanshellTileSourceTemplate(Map<String, String> attributes) {
|
||||
String name = attributes.get("name");
|
||||
String urlTemplate = attributes.get("url_template");
|
||||
String initScript = attributes.get("init_script");
|
||||
if (name == null || urlTemplate == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -397,7 +395,7 @@ public class TileSourceManager {
|
|||
ellipsoid = true;
|
||||
}
|
||||
TileSourceTemplate templ;
|
||||
templ = new BeanShellTileSourceTemplate(name, initScript, urlTemplate, ext, maxZoom, minZoom, tileSize, bitDensity, avgTileSize);
|
||||
templ = new BeanShellTileSourceTemplate(name, urlTemplate, ext, maxZoom, minZoom, tileSize, bitDensity, avgTileSize);
|
||||
templ.setEllipticYTile(ellipsoid);
|
||||
return templ;
|
||||
}
|
||||
|
@ -407,23 +405,15 @@ public class TileSourceManager {
|
|||
public static class BeanShellTileSourceTemplate extends TileSourceTemplate {
|
||||
|
||||
Interpreter bshInterpreter;
|
||||
protected String initScript;
|
||||
|
||||
public String getInitScript() {
|
||||
return initScript;
|
||||
}
|
||||
|
||||
public BeanShellTileSourceTemplate(String name, String initScript, String urlToLoad, String ext,
|
||||
public BeanShellTileSourceTemplate(String name, String urlToLoad, String ext,
|
||||
int maxZoom, int minZoom, int tileSize, int bitDensity, int avgSize) {
|
||||
super(name, urlToLoad, ext, maxZoom, minZoom, tileSize, bitDensity, avgSize);
|
||||
bshInterpreter = new Interpreter();
|
||||
this.initScript = initScript;
|
||||
if (initScript != null) {
|
||||
try {
|
||||
bshInterpreter.eval(initScript);
|
||||
bshInterpreter.eval(urlToLoad);
|
||||
} catch (bsh.EvalError e) {
|
||||
log.error("Error executing the map init script " + initScript, e);
|
||||
}
|
||||
log.error("Error executing the map init script " + urlToLoad, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -433,7 +423,7 @@ public class TileSourceManager {
|
|||
bshInterpreter.set("x", x);
|
||||
bshInterpreter.set("y", y);
|
||||
bshInterpreter.set("z", zoom);
|
||||
bshInterpreter.eval(urlToLoad);
|
||||
bshInterpreter.eval("url = getTileUrl(z, x, y);");
|
||||
return (String) bshInterpreter.get("url");
|
||||
} catch (bsh.EvalError e) {
|
||||
return null;
|
||||
|
|
|
@ -8,14 +8,11 @@
|
|||
<tile_source name="GoogleMaps Terrain" url_template="http://mt3.google.com/vt/v=w2p.111&hl=en&x={1}&y={2}&z={0}" ext=".jpg" min_zoom="5" max_zoom="15" tile_size="256" img_density="32" avg_img_size="18000"/>
|
||||
|
||||
<tile_source rule="beanshell" name="Microsoft Maps" min_zoom="1" max_zoom="19" tile_size="256" img_density="16" avg_img_size="18000" ext="png"
|
||||
init_script="public static String eqt(int z, int x, int y) {static final char[] NUM_CHAR = { '0', '1', '2', '3' };char[] tn = new char[z];for (int i = z - 1; i >= 0; i--) {int num = (x % 2) | ((y % 2) << 1);tn[i] = NUM_CHAR[num];x >>= 1;y >>= 1;}return new String(tn);}"
|
||||
url_template="url = "http://" + "r" + "0" + ".ortho.tiles.virtualearth.net/tiles/" + "r" + eqt(z,x,y) + ".png" + "?g=45";"/>
|
||||
url_template="public static String eqt(int z, int x, int y) {static final char[] NUM_CHAR = { '0', '1', '2', '3' };char[] tn = new char[z];for (int i = z - 1; i >= 0; i--) {int num = (x % 2) | ((y % 2) << 1);tn[i] = NUM_CHAR[num];x >>= 1;y >>= 1;}return new String(tn);} String getTileUrl(int z, int x, int y) { return "http://" + "r" + "0" + ".ortho.tiles.virtualearth.net/tiles/" + "r" + eqt(z,x,y) + ".png" + "?g=45";}"/>
|
||||
<tile_source rule="beanshell" name="Microsoft Hybrid" min_zoom="1" max_zoom="19" tile_size="256" img_density="32" avg_img_size="18000" ext="jpg"
|
||||
init_script="public static String eqt(int z, int x, int y) {static final char[] NUM_CHAR = { '0', '1', '2', '3' };char[] tn = new char[z];for (int i = z - 1; i >= 0; i--) {int num = (x % 2) | ((y % 2) << 1);tn[i] = NUM_CHAR[num];x >>= 1;y >>= 1;}return new String(tn);}"
|
||||
url_template="url = "http://" + "h" + "0" + ".ortho.tiles.virtualearth.net/tiles/" + "h" + eqt(z,x,y) + ".jpg" + "?g=45";"/>
|
||||
url_template="public static String eqt(int z, int x, int y) {static final char[] NUM_CHAR = { '0', '1', '2', '3' };char[] tn = new char[z];for (int i = z - 1; i >= 0; i--) {int num = (x % 2) | ((y % 2) << 1);tn[i] = NUM_CHAR[num];x >>= 1;y >>= 1;}return new String(tn);} String getTileUrl(int z, int x, int y) { return "http://" + "h" + "0" + ".ortho.tiles.virtualearth.net/tiles/" + "h" + eqt(z,x,y) + ".jpg" + "?g=45";}"/>
|
||||
<tile_source rule="beanshell" name="Microsoft Earth" min_zoom="1" max_zoom="19" tile_size="256" img_density="32" avg_img_size="18000" ext="jpg"
|
||||
init_script="public static String eqt(int z, int x, int y) {static final char[] NUM_CHAR = { '0', '1', '2', '3' };char[] tn = new char[z];for (int i = z - 1; i >= 0; i--) {int num = (x % 2) | ((y % 2) << 1);tn[i] = NUM_CHAR[num];x >>= 1;y >>= 1;}return new String(tn);}"
|
||||
url_template="url = "http://" + "a" + "0" + ".ortho.tiles.virtualearth.net/tiles/" + "a" + eqt(z,x,y) + ".jpg" + "?g=45";"/>
|
||||
url_template="public static String eqt(int z, int x, int y) {static final char[] NUM_CHAR = { '0', '1', '2', '3' };char[] tn = new char[z];for (int i = z - 1; i >= 0; i--) {int num = (x % 2) | ((y % 2) << 1);tn[i] = NUM_CHAR[num];x >>= 1;y >>= 1;}return new String(tn);} String getTileUrl(int z, int x, int y) { return "http://" + "a" + "0" + ".ortho.tiles.virtualearth.net/tiles/" + "a" + eqt(z,x,y) + ".jpg" + "?g=45";}"/>
|
||||
|
||||
<tile_source name="ÖPNV Transit" url_template="http://tile.xn--pnvkarte-m4a.de/tilegen/{0}/{1}/{2}.png" ext=".png" min_zoom="1" max_zoom="18" tile_size="256" img_density="16" avg_img_size="18000"/>
|
||||
<tile_source name="OpenCycleMap" url_template="http://c.tile.opencyclemap.org/cycle/{0}/{1}/{2}.png" ext=".png" min_zoom="1" max_zoom="18" tile_size="256" img_density="16" avg_img_size="18000"/>
|
||||
|
@ -25,7 +22,7 @@
|
|||
<tile_source name="OpenPisteMap" url_template="http://openpistemap.org/tiles/contours/{0}/{1}/{2}.png" ext=".png" min_zoom="5" max_zoom="17" tile_size="256" img_density="32" avg_img_size="18000"/>
|
||||
<tile_source name="Relief" url_template="http://www.maps-for-free.com/layer/relief/z{0}/row{2}/{0}_{1}-{2}.jpg" ext=".jpg" min_zoom="1" max_zoom="12" tile_size="256" img_density="32" avg_img_size="24000"/>
|
||||
|
||||
<tile_source rule="beanshell" name="Cykloatlas CZ" url_template="url = "http://services.tmapserver.cz/tiles/gm/shc/" + z + (z >= 13 ? "c" : "") + "/" + x + "/" + y + ".png";" ext="png" min_zoom="7" max_zoom="16" tile_size="256" img_density="16" avg_img_size="26000"/>
|
||||
<tile_source rule="beanshell" name="Cykloatlas CZ" url_template="String getTileUrl(int z, int x, int y) { return "http://services.tmapserver.cz/tiles/gm/shc/" + z + (z >= 13 ? "c" : "") + "/" + x + "/" + y + ".png";}" ext="png" min_zoom="7" max_zoom="16" tile_size="256" img_density="16" avg_img_size="26000"/>
|
||||
<tile_source name="Cykloatlas CZ HillShade" url_template="http://services.tmapserver.cz/tiles/gm/sum/{0}/{1}/{2}.png" ext=".png" min_zoom="7" max_zoom="15" tile_size="256" img_density="16" avg_img_size="26000"/>
|
||||
|
||||
<tile_source name="MTB Map CZ" url_template="http://tchor.fi.muni.cz:8080/mtbmap_tiles/{0}/{1}/{2}.png" ext=".png" min_zoom="7" max_zoom="16" tile_size="256" img_density="32" avg_img_size="18000"/>
|
||||
|
|
Loading…
Reference in a new issue