ingo@1328: package de.intevation.flys.client.shared; ingo@1328: ingo@2440: import java.util.Date; ingo@2440: ingo@1328: ingo@1328: public class MapUtils { ingo@1328: ingo@1328: public static final String GET_LEGEND_GRAPHIC_TEMPLATE = ingo@1328: "${SERVER}SERVICE=WMS&VERSION=1.1.1&layer=${LAYER}" + ingo@1328: "&REQUEST=getLegendGraphic&FORMAT=image/png"; ingo@1328: ingo@1328: ingo@1328: private MapUtils() { ingo@1328: } ingo@1328: aheinecke@5676: public static String getLegendGraphicUrl(String server, String layer) { aheinecke@5676: return getLegendGraphicUrl(server, layer, -1); aheinecke@5676: } ingo@1328: aheinecke@5676: public static String getLegendGraphicUrl(String server, String layer, int dpi) { ingo@1328: if (server == null || layer == null) { ingo@1328: return null; ingo@1328: } ingo@1328: aheinecke@5676: if (server.contains("osm.intevation.de")) { aheinecke@5676: // GetLegend is not implemented at osm.intevation.de aheinecke@5676: // This avoids an error in the print log aheinecke@5676: return null; aheinecke@5676: } ingo@1328: server = server.indexOf("?") >= 0 ? server : server + "?"; ingo@1328: ingo@1328: String url = GET_LEGEND_GRAPHIC_TEMPLATE; ingo@1328: url = url.replace("${SERVER}", server); ingo@1328: url = url.replace("${LAYER}", layer); ingo@2440: url = url + "×tamp=" + new Date().getTime(); aheinecke@5676: if (dpi != -1) { aheinecke@5676: url+="&legend_options=dpi:" + dpi; aheinecke@5676: } ingo@1328: ingo@1328: return url; ingo@1328: } ingo@1328: } ingo@1328: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :