changeset 9609:8232a3f5967b

#20 SinfoResultType
author dnt_bjoernsen <d.tironi@bjoernsen.de>
date Wed, 09 Oct 2019 15:43:39 +0200
parents 96c41d4f4aba
children 020d4a595205
files artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java
diffstat 1 files changed, 59 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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

http://dive4elements.wald.intevation.org