Mercurial > dive4elements > river
changeset 6170:194a99865d73
createWSPLGENClassName() now respects user locale (#767).
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Mon, 03 Jun 2013 14:56:10 +0200 |
parents | bd291447fef1 |
children | 4a1af135885a |
files | artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java artifacts/src/main/java/org/dive4elements/river/utils/ThemeUtil.java |
diffstat | 2 files changed, 29 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java Mon Jun 03 14:53:08 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java Mon Jun 03 14:56:10 2013 +0200 @@ -8,8 +8,6 @@ package org.dive4elements.river.exports; -import com.vividsolutions.jts.geom.Envelope; - import org.dive4elements.artifactdatabase.data.StateData; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifactdatabase.state.Facet; @@ -41,6 +39,8 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import com.vividsolutions.jts.geom.Envelope; + public class MapGenerator implements OutGenerator, FacetTypes { @@ -102,7 +102,7 @@ String name = artifactFacet.getFacetName(); logger.debug("MapGenerator.doOut: " + - artifactFacet.getArtifact().identifier() + " | " + name); + artifactFacet.getArtifact().identifier() + " | " + name); D4EArtifact flys = (D4EArtifact) artifactFacet.getArtifact(); Facet nativeFacet = artifactFacet.getFacet(); @@ -161,12 +161,12 @@ mfg.createUeskLayer( flys, (WSPLGENLayerFacet) wms, - ThemeUtil.createDynamicMapserverStyle(attr, from, to, step), + ThemeUtil.createDynamicMapserverStyle(attr, from, to, step, context.getMeta()), context); } else { logger.warn("Cannot create WSPLGEN layer from: " + - wms.getClass()); + wms.getClass()); } } catch (IOException ioe) { @@ -225,9 +225,9 @@ if (wms instanceof WMSDBLayerFacet) { mfg.createDatabaseLayer( - flys, - (WMSDBLayerFacet) wms, - ThemeUtil.createMapserverStyle(attr)); + flys, + (WMSDBLayerFacet) wms, + ThemeUtil.createMapserverStyle(attr)); } else { logger.warn("Cannot create DB layer from: " + wms.getClass()); @@ -244,7 +244,7 @@ @Override public void generate() - throws IOException + throws IOException { logger.debug("MapGenerator.generate"); @@ -253,9 +253,9 @@ Document response = XMLUtils.newDocument(); ElementCreator c = new ElementCreator( - response, - ArtifactNamespaceContext.NAMESPACE_URI, - ArtifactNamespaceContext.NAMESPACE_PREFIX); + response, + ArtifactNamespaceContext.NAMESPACE_URI, + ArtifactNamespaceContext.NAMESPACE_PREFIX); Element root = c.create("floodmap"); Element layers = c.create("layers"); @@ -267,7 +267,7 @@ appendMapInformation(root, c); XMLUtils.toStream(response, out); - } + } protected void appendLayers(Element parent) {
--- a/artifacts/src/main/java/org/dive4elements/river/utils/ThemeUtil.java Mon Jun 03 14:53:08 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/utils/ThemeUtil.java Mon Jun 03 14:56:10 2013 +0200 @@ -8,15 +8,19 @@ package org.dive4elements.river.utils; +import org.dive4elements.artifacts.CallMeta; import org.dive4elements.artifacts.common.utils.XMLUtils; import org.dive4elements.river.artifacts.model.MapserverStyle; import org.dive4elements.river.artifacts.model.MapserverStyle.Clazz; import org.dive4elements.river.artifacts.model.MapserverStyle.Expression; import org.dive4elements.river.artifacts.model.MapserverStyle.Label; import org.dive4elements.river.artifacts.model.MapserverStyle.Style; +import org.dive4elements.river.artifacts.resources.Resources; import java.awt.Color; import java.awt.Font; +import java.text.NumberFormat; +import java.util.Locale; import org.apache.log4j.Logger; import org.w3c.dom.Document; @@ -669,7 +673,7 @@ * @return String representation of the MapserverStyle */ public static String createDynamicMapserverStyle(Document theme, - float from, float to, float step) + float from, float to, float step, CallMeta meta) { MapserverStyle ms = new MapserverStyle(); @@ -701,7 +705,7 @@ newColor.append(startColor.getBlue() + Math.round(n * bd)); String expr = createWSPLGENClassExpression(from + n * step, step, n + 1, numClasses); - String name = createWSPLGENClassName(from + n * step, step, n + 1, numClasses); + String name = createWSPLGENClassName(from + n * step, step, n + 1, numClasses, meta); Clazz c = new Clazz(name); Style s = new Style(); @@ -728,12 +732,19 @@ } // FIXME: i18n - protected static String createWSPLGENClassName(float val, float step, int idx, int maxIdx) { + protected static String createWSPLGENClassName(float val, float step, int idx, int maxIdx, CallMeta meta) { + Locale locale = Resources.getLocale(meta); + NumberFormat nf = NumberFormat.getInstance(locale); if (idx < maxIdx) { - return "[Differenz] >= " + val + "m UND [Differenz] < " + (val + step) + "m"; + return "[Differenz] >= " + + nf.format(val) + + " m UND [Differenz] < " + + nf.format(val + step) + + " m"; } else { - return "[Differenz] >= " + val + "m"; + return "[Differenz] >= " + + nf.format(val) + " m"; } }