[PATCH 7 of 7]

Wald Commits scm-commit at wald.intevation.org
Wed Oct 9 15:45:09 CEST 2019


# HG changeset patch
# User dnt_bjoernsen <d.tironi at bjoernsen.de>
# Date 1570628619 -7200
#      Wed Oct 09 15:43:39 2019 +0200
# Node ID 8232a3f5967b75e6730a0700be9cb05d1398bff0
# Parent  96c41d4f4aba165f940df00d05c2bd1b7fcb1ff7
#20 SinfoResultType

diff -r 96c41d4f4aba -r 8232a3f5967b artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java	Thu Sep 12 15:39:10 2019 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java	Wed Oct 09 15:43:39 2019 +0200
@@ -10,6 +10,7 @@
 package org.dive4elements.river.artifacts.sinfo.common;
 
 import java.text.NumberFormat;
+import java.text.ParseException;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
@@ -64,12 +65,20 @@
         @Override
         public String exportValue(final CallContext context, final Object value) {
             final double doubleValue = asDouble(value);
-            return exportDoubleValue(context, doubleValue);
+            final String significant = Formatter.SIGINIFICANT_FORMATTER_3.format(doubleValue);
+            try {
+                final Number significantD = Formatter.SIGINIFICANT_FORMATTER_3.parse(significant);
+                return exportDoubleValue(context, asDouble(significantD));
+            }
+            catch (final ParseException e) {
+                e.printStackTrace();
+                return "";
+            }
         }
 
         @Override
         protected NumberFormat createFormatter(final CallContext context) {
-            return Formatter.getWaterlevelQ(context);
+            return Formatter.getFormatter(context, 0, 3);
         }
     };
 
@@ -107,6 +116,7 @@
         }
     };
 
+    // TODO: check, if it is being used correctly
     public static final SInfoResultType infrastructuretype = new SInfoResultType(I18NStrings.UNIT_NONE,
             "sinfo.export.flood_duration.csv.header.infrastructure_type", "sinfo.export.flood_duration.pdf.header.infrastructure_type") {
         private static final long serialVersionUID = 1L;
@@ -121,6 +131,21 @@
             throw new UnsupportedOperationException();
         }
     };
+    //
+    public static final SInfoResultType infrastructurepart = new SInfoResultType(I18NStrings.UNIT_NONE,
+            "sinfo.export.flood_duration.csv.header.infrastructure_part", "sinfo.export.flood_duration.pdf.header.infrastructure_part") {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public String exportValue(final CallContext context, final Object value) {
+            return exportStringValue(value);
+        }
+
+        @Override
+        protected NumberFormat createFormatter(final CallContext context) {
+            throw new UnsupportedOperationException();
+        }
+    };
 
     public static final SInfoResultType dischargeLong = new SInfoResultType(I18NStrings.UNIT_CUBIC_M, "sinfo.export.collision.csv.header.discharge_long") {
         private static final long serialVersionUID = 1L;
@@ -205,6 +230,36 @@
         }
     };
 
+    public static final SInfoResultType maxBedHeight = new SInfoResultType(null, null, null) {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public String exportValue(final CallContext context, final Object value) {
+            final double doubleValue = asDouble(value);
+            return exportDoubleValue(context, doubleValue);
+        }
+
+        @Override
+        protected NumberFormat createFormatter(final CallContext context) {
+            return Formatter.getMeanBedHeight(context);
+        }
+    };
+
+    public static final SInfoResultType minBedHeight = new SInfoResultType(null, null, null) {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public String exportValue(final CallContext context, final Object value) {
+            final double doubleValue = asDouble(value);
+            return exportDoubleValue(context, doubleValue);
+        }
+
+        @Override
+        protected NumberFormat createFormatter(final CallContext context) {
+            return Formatter.getMeanBedHeight(context);
+        }
+    };
+
     public static final SInfoResultType meanBedHeight = new SInfoResultType(null, SInfoI18NStrings.CSV_MEAN_BED_HEIGHT_HEADER,
             SInfoI18NStrings.CSV_MEAN_BED_HEIGHT_HEADER_SHORT) {
         private static final long serialVersionUID = 1L;
@@ -280,7 +335,8 @@
         }
     };
 
-    public static final SInfoResultType riverside = new SInfoResultType(I18NStrings.UNIT_NONE, "sinfo.export.flood_duration.csv.header.riverside") {
+    public static final SInfoResultType riverside = new SInfoResultType(I18NStrings.UNIT_NONE, "sinfo.export.flood_duration.csv.header.riverside",
+            "sinfo.export.flood_duration.pdf.header.riverside") {
         private static final long serialVersionUID = 1L;
 
         @Override


More information about the Dive4Elements-commits mailing list