# HG changeset patch # User Christian Lins # Date 1370264170 -7200 # Node ID 194a99865d7370f3238a3dd5a1715cdcec73ced8 # Parent bd291447fef16b9a0a9ddb9b3cf040ca13d31a6b createWSPLGENClassName() now respects user locale (#767). diff -r bd291447fef1 -r 194a99865d73 artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java --- 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) { diff -r bd291447fef1 -r 194a99865d73 artifacts/src/main/java/org/dive4elements/river/utils/ThemeUtil.java --- 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"; } }