changeset 9247:1ec3b891ab02

salix.historical.distance_only_part detail work
author gernotbelger
date Thu, 12 Jul 2018 12:12:01 +0200
parents c08d5cfa4981
children 9e6b70cce337
files artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/DistanceOnlyPartHistoricalSelect.java artifacts/src/main/resources/messages.properties artifacts/src/main/resources/messages_de.properties
diffstat 3 files changed, 40 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/DistanceOnlyPartHistoricalSelect.java	Thu Jul 12 11:15:42 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/DistanceOnlyPartHistoricalSelect.java	Thu Jul 12 12:12:01 2018 +0200
@@ -23,6 +23,8 @@
 import org.dive4elements.river.artifacts.states.DistanceOnlySelect;
 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
 import org.dive4elements.river.model.BedHeight;
+import org.dive4elements.river.model.River;
+import org.dive4elements.river.utils.Formatter;
 import org.w3c.dom.Element;
 
 public class DistanceOnlyPartHistoricalSelect extends DistanceOnlySelect {
@@ -31,6 +33,11 @@
     private static Logger log = Logger.getLogger(DistanceOnlyPartHistoricalSelect.class);
 
     List<BedHeight> bhs = null;
+    Integer epoch = null;
+    Integer year = null;
+    Double lowerKm = null;
+    Double upperKm = null;
+    River river = null;
 
     @Override
     protected String getUIProvider() {
@@ -88,13 +95,24 @@
     }
 
     private List<BedHeight> getBedheights(final Artifact artifact) {
+
+        final SalixLineAccess access = new SalixLineAccess((UINFOArtifact) artifact); // improved lazy-loading
+        final Integer year = access.getYear();
+        final Integer epoch = access.getEpoch();
+        final River river = access.getRiver(); // comparable? workflow does not allow return and change anyway...
+        final Double lower = access.getLowerKm();
+        final Double upper = access.getUpperKm();
+        if (!(this.year == year && this.epoch == epoch && this.river == river && this.lowerKm == lower && this.upperKm == upper)) {
+            this.bhs = null;
+        }
         if (this.bhs == null) {
-            final SalixLineAccess access = new SalixLineAccess((UINFOArtifact) artifact);
-            final Integer year = access.getYear();
-
-            final Integer epoch = access.getEpoch();
             final boolean isEpoch = epoch == null ? false : true;
-            this.bhs = BedHeight.getBedHeightYearEpoch(isEpoch, isEpoch ? epoch : year, access.getRiver(), access.getLowerKm(), access.getUpperKm());
+            this.bhs = BedHeight.getBedHeightYearEpoch(isEpoch, isEpoch ? epoch : year, river, lower, upper);
+            this.year = year;
+            this.epoch = epoch;
+            this.river = river;
+            this.lowerKm = lower;
+            this.upperKm = upper;
         }
         return this.bhs;
 
@@ -105,26 +123,35 @@
 
         final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "year", context.getMeta());
 
-        helper.addColumn(0, "from_to", "100", "year", "INTEGER", "LEFT", null);
-        helper.addColumn(1, "description", "500", "uinfo.salix.soundings", "STRING", "LEFT", null);
+        // TODO: probably aggregating results, no sound-row, output as single row
+
+        int year = 0; // hässlich, aber kommt vermutlich eh bald weg
+        if (bedheights != null && bedheights.size() > 0)
+            year = bedheights.get(0).getYear(); // das jahr/epoche ist immer dasselbe
+
+        helper.addColumn(0, "year", "60", "year", "INTEGER", "LEFT", null);
+        helper.addColumn(1, "range", "130", "state.uinfo.salix.historical.km_range_part", "STRING", "LEFT", null);
+        helper.addColumn(2, "description", "500", "uinfo.salix.sounding", "STRING", "LEFT", null);
 
         final TreeMap<String, String> bedHeightSorted = new TreeMap<>();
         final double min = Double.MAX_VALUE;
         final double max = -Double.MAX_VALUE;
+        final java.text.NumberFormat formatter = Formatter.getCalculationKm(context.getMeta());
 
         for (final BedHeight bh : bedheights) {
             final org.dive4elements.river.model.Range range = BedHeight.getRangeFromBedHeights(bh);
             final Double from = range.getA().doubleValue(); // NullPointer check??
             final Double to = range.getB().doubleValue();
 
-            bedHeightSorted.put(bh.getDescription(), String.valueOf(from) + " - " + String.valueOf(to));
+            bedHeightSorted.put(bh.getDescription(), formatter.format(from) + " - " + formatter.format(to));
         }
         final Iterator<String> iterator = bedHeightSorted.keySet().iterator();
         while (iterator.hasNext()) {
             final String descr = iterator.next();
             final String fromTo = bedHeightSorted.get(descr);
             final Map<String, String> row = new HashMap<>();
-            row.put("from_to", String.valueOf(fromTo));
+            row.put("year", String.valueOf(year));
+            row.put("range", fromTo);
             row.put("description", descr);
             helper.addRow(row);
         }
--- a/artifacts/src/main/resources/messages.properties	Thu Jul 12 11:15:42 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties	Thu Jul 12 12:12:01 2018 +0200
@@ -1088,6 +1088,8 @@
 mainvalue.w.description = Wasserstand/Wasserspiegel-lage ({0})
 mainvalue.duration = \u00dcberflutungsdauer
 mainvalue.duration.description = \u00dcberflutungsdauer ({0})
+state.uinfo.salix.historical.km_range_part = Ausgewertete Strecke
+uinfo.salix.sounding= Peilung
 uinfo.salix.soundings= Soundings
 uinfo.export.salix_line.csv.header.scenario_dwspl = \u0394MW [cm]
 uinfo.export.salix_line.csv.header.scenario = Salix-Linie_Szenario [m]
--- a/artifacts/src/main/resources/messages_de.properties	Thu Jul 12 11:15:42 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Thu Jul 12 12:12:01 2018 +0200
@@ -1088,6 +1088,8 @@
 mainvalue.w.description = Wasserstand/Wasserspiegel-lage ({0})
 mainvalue.duration = \u00dcberflutungsdauer
 mainvalue.duration.description = \u00dcberflutungsdauer ({0})
+state.uinfo.salix.historical.km_range_part = Ausgewertete Strecke
+uinfo.salix.sounding= Peilung
 uinfo.salix.soundings= Peilungen
 uinfo.export.salix_line.csv.header.scenario_dwspl = \u0394MW [cm]
 uinfo.export.salix_line.csv.header.scenario = Salix-Linie_Szenario [m]

http://dive4elements.wald.intevation.org