changeset 6322:8c976bb0362f

Add SQ Relation KM formatter and use it fopr issue 1071
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 13 Jun 2013 09:22:46 +0200
parents 6c41a4ca2876
children f49749526af4
files artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java
diffstat 2 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java	Thu Jun 13 09:09:56 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java	Thu Jun 13 09:22:46 2013 +0200
@@ -156,7 +156,8 @@
     }
 
     protected List<String[]> data2StringArrays(SQResult result) {
-        String km = String.valueOf(result.getKm());
+        String km = Formatter.getSQRelationKM(context
+                    ).format(result.getKm());
         List<String[]> retval = new ArrayList<String[]>();
 
         for (int i = 0; i < SQResult.NUMBER_FRACTIONS; ++i) {
--- a/artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java	Thu Jun 13 09:09:56 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java	Thu Jun 13 09:22:46 2013 +0200
@@ -92,10 +92,12 @@
     public static final int VARIANCE_MAX_DIGITS = 3;
 
     // SQ Relation
-    public static final int SQ_RELATION_A_MAX_DIGITS = 7;
-    public static final int SQ_RELATION_A_MIN_DIGITS = 7;
-    public static final int SQ_RELATION_B_MAX_DIGITS = 3;
-    public static final int SQ_RELATION_B_MIN_DIGITS = 3;
+    public static final int SQ_RELATION_KM_MIN_DIGITS = 2;
+    public static final int SQ_RELATION_KM_MAX_DIGITS = 2;
+    public static final int SQ_RELATION_A_MAX_DIGITS  = 7;
+    public static final int SQ_RELATION_A_MIN_DIGITS  = 7;
+    public static final int SQ_RELATION_B_MAX_DIGITS  = 3;
+    public static final int SQ_RELATION_B_MIN_DIGITS  = 3;
 
     /**
      * Creates a localized NumberFormatter with given range of decimal digits.
@@ -453,6 +455,13 @@
                 SQ_RELATION_B_MAX_DIGITS);
     }
 
+    public static NumberFormat getSQRelationKM(CallContext context) {
+        return getFormatter(
+                context,
+                SQ_RELATION_KM_MIN_DIGITS,
+                SQ_RELATION_KM_MAX_DIGITS);
+    }
+
     public static NumberFormat getMeterFormat(CallContext context) {
         return getFormatter(
                 context,

http://dive4elements.wald.intevation.org