changeset 2326:c321b39b39ab

'Bezugslinienverfahren': Generate valid i18n names for datasets. flys-artifacts/trunk@4010 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 09 Feb 2012 17:28:31 +0000
parents 1fcaeced48f2
children 07c39470e2cb
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation5.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceCurveState.java
diffstat 4 files changed, 32 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Feb 09 15:59:49 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Feb 09 17:28:31 2012 +0000
@@ -1,3 +1,12 @@
+2012-02-09	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/Calculation5.java:
+	  Generate a valid intial i18n name.
+
+	* src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/states/ReferenceCurveState.java:
+	  Pass call context to calculation.
+
 2012-02-09  Ingo Weinzierl <ingo@intevation.de>
 
 	flys/issue485 (Themen können umgenannt werden, dies wird nicht in der Legende reflektiert)
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Thu Feb 09 15:59:49 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Thu Feb 09 17:28:31 2012 +0000
@@ -655,7 +655,7 @@
      *
      * @return the data computed by a reference curve computation.
      */
-    public CalculationResult getReferenceCurveData() {
+    public CalculationResult getReferenceCurveData(CallContext context) {
 
         Double startKm = getReferenceStartKm();
 
@@ -683,7 +683,7 @@
 
         Map<Double, Double> kms2gaugeDatums = r.queryGaugeDatumsKMs();
 
-        return calc5.calculate(wst, kms2gaugeDatums);
+        return calc5.calculate(wst, kms2gaugeDatums, context);
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation5.java	Thu Feb 09 15:59:49 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation5.java	Thu Feb 09 17:28:31 2012 +0000
@@ -1,11 +1,17 @@
 package de.intevation.flys.artifacts.model;
 
+import de.intevation.artifacts.CallContext;
+import de.intevation.artifacts.CallMeta;
+
+import de.intevation.flys.utils.Formatter;
+
+import java.text.NumberFormat;
+
 import java.util.ArrayList;
 import java.util.Map;
 
 import org.apache.log4j.Logger;
 
-
 public class Calculation5
 extends      Calculation
 {
@@ -24,12 +30,15 @@
 
     public CalculationResult calculate(
         WstValueTable       wst, 
-        Map<Double, Double> kms2gaugeDatums
+        Map<Double, Double> kms2gaugeDatums,
+        CallContext         context
     ) {
         ArrayList<WWQQ> results = new ArrayList<WWQQ>();
 
         int numProblems = numProblems();
 
+        CallMeta meta = context.getMeta();
+
         for (double endKm: endKms) {
 
             double [][] wws = wst.relateWs(startKm, endKm, this);
@@ -37,7 +46,7 @@
 
             if (wws.length == 4) {
                 WWQQ wwqq = new WWQQ(
-                    generateName(startKm, endKm),
+                    generateName(meta, startKm, endKm),
                     startKm, kms2gaugeDatums.get(startKm), wws[0], wws[1],
                     endKm,   kms2gaugeDatums.get(endKm),   wws[2], wws[3]);
 
@@ -55,9 +64,14 @@
             this);
     }
 
-    protected static String generateName(double startKm, double endKm) {
-        // TODO: I18N
-        return "W(km " + startKm + ") ~ W(km " + endKm + ")";
+    protected static String generateName(
+        CallMeta meta,
+        double   startKm, 
+        double   endKm
+    ) {
+        NumberFormat nf = Formatter.getCalculationKm(meta);
+        return "W(km " + nf.format(startKm) + 
+               ") ~ W(km " + nf.format(endKm) + ")";
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceCurveState.java	Thu Feb 09 15:59:49 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceCurveState.java	Thu Feb 09 17:28:31 2012 +0000
@@ -46,7 +46,7 @@
 
         CalculationResult res = old instanceof CalculationResult
             ? (CalculationResult)old
-            : winfo.getReferenceCurveData();
+            : winfo.getReferenceCurveData(context);
 
         if (facets == null) {
             return res;

http://dive4elements.wald.intevation.org