[PATCH] Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total

Wald Commits scm-commit at wald.intevation.org
Mon Sep 10 17:06:37 CEST 2018


# HG changeset patch
# User mschaefer
# Date 1536591983 -7200
# Node ID 7228bd10a8cc48f53b100d172aac805490bc78ed
# Parent  2b83d3a967032b60e29d7e94f497c6b8269fc770
Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total

diff -r 2b83d3a96703 -r 7228bd10a8cc artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/BunduResultType.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/BunduResultType.java	Mon Sep 10 15:31:55 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/BunduResultType.java	Mon Sep 10 17:06:23 2018 +0200
@@ -112,6 +112,8 @@
             throw new UnsupportedOperationException();
         }
     };
+
+    // TODO missVolumeTotal und missMassTotal differenzieren in Gesamtsumme und Feld1-10-Summe
     public static final BunduResultType missVolumeTotal = new BunduResultType(I18NStrings.UNIT_CUBIC_M, "bundu.export.bezugswst.csv.meta.miss.volume.total") {
         private static final long serialVersionUID = 1L;
 
@@ -174,6 +176,38 @@
         }
     };
 
+    public static final BunduResultType excavationVolumeTotal = new BunduResultType(I18NStrings.UNIT_CUBIC_M,
+            "bundu.export.bezugswst.csv.meta.miss.excavationtotal", "bundu.export.bezugswst.pdf.meta.miss.excavationtotal") {
+        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.getIntegerFormatter(context);
+        }
+    };
+
+    public static final BunduResultType excavationCostsTotal = new BunduResultType(I18NStrings.UNIT_EURO, "bundu.export.bezugswst.csv.meta.miss.coststotal",
+            "bundu.export.bezugswst.pdf.meta.miss.coststotal") {
+        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.getCurrencyFormat(context);
+        }
+    };
+
     public static final BunduResultType channelWidth = new BunduResultType(I18NStrings.UNIT_M, "bundu.export.bezugswst.csv.meta.miss.channel.width",
             "bundu.export.bezugswst.pdf.meta.miss.channel.width") {
         private static final long serialVersionUID = 1L;
diff -r 2b83d3a96703 -r 7228bd10a8cc artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java	Mon Sep 10 15:31:55 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java	Mon Sep 10 17:06:23 2018 +0200
@@ -102,8 +102,9 @@
         final WstInfo wstInfo = new WstInfo(wqkms.getName(), 0, riverInfoProvider.getReferenceGauge(), true);
 
         // Fetch the bed heights of the selected sounding
-        final Integer bedHeightId = access.getBedHeightID(); // TODO: REMOVE BEDHEIGHTFINDER FROM CALCULATION - HOW?
-        final BedHeightsFinder bedHeightsFinder = bedHeightId == null ? null : BedHeightsFinder.forId(problems, bedHeightId, access.getRange());
+        final Integer bedHeightId = access.getBedHeightID();
+        final BedHeightsFinder bedHeightsFinder = (bedHeightId != null) ? BedHeightsFinder.forId(problems, bedHeightId, access.getRange())
+                : BedHeightsFinder.NullFinder();
 
         // Fetch the river channel data
         final ChannelFinder channelFinder = ChannelFinder.loadValues(problems, river, access.getBezugsJahr());
@@ -112,13 +113,12 @@
 
         // Compute the result rows
         for (int i = 0; i <= wqkms.size() - 1; i++) {
-            // TODO: REMOVE BEDHEIGHTFINDER FROM CALCULATION - HOW?
             this.rows.add(createRow(wqkms.getKm(i), wqkms.getW(i), wqkms.getQ(i), bedHeightsFinder, channelFinder, riverInfoProvider, wstInfo));
         }
 
         // Compute the missing volumes
         if (access.isCalculateMissingValue()) {
-            if (bedHeightsFinder == null)
+            if ((bedHeightsFinder == null) || bedHeightsFinder.isNull())
                 return new CalculationResult(results, problems);
             computeMissingVolumes(problems);
             final BedQualityCalculator bqCalculator = computeDensities(problems, bunduartifact, access, river);
@@ -188,11 +188,12 @@
         row.putValue(GeneralResultType.waterlevelLabel, wstInfo.getLabel());
         row.putValue(GeneralResultType.gaugeLabel, riverInfoProv.findGauge(station));
         row.putValue(GeneralResultType.location, riverInfoProv.getLocation(station));
-        row.putValue(BunduResultType.sounding, bedHeightsFinder.getInfo().getDescription());
+        if (bedHeightsFinder.getInfo() != null)
+            row.putValue(BunduResultType.sounding, bedHeightsFinder.getInfo().getDescription());
+        else
+            row.putValue(BunduResultType.sounding, "");
 
         // Set bed and channel bottom height
-
-        // TODO: REMOVE BEDHEIGHTFINDER FROM CALCULATION - HOW?
         final double msh = bedHeightsFinder.getMeanBedHeight(station);
         row.putValue(SInfoResultType.meanBedHeight, msh);
         if (!Double.isNaN(w) && !Double.isNaN(msh))
@@ -467,8 +468,8 @@
         sumRow.putValue(BunduResultType.missStationRangeTo, Double.valueOf(this.missKmTo));
         sumRow.putValue(BunduResultType.missVolumeTotal, vTotal);
         sumRow.putValue(BunduResultType.missMassTotal, mTotal);
-        // TODO sumRow.putValue(BunduResultType.excavationVolumeTotal, eTotal);
-        // TODO sumRow.putValue(BunduResultType.excavationCostsTotal, cTotal);
+        sumRow.putValue(BunduResultType.excavationVolumeTotal, eTotal);
+        sumRow.putValue(BunduResultType.excavationCostsTotal, cTotal);
         return sumRow;
     }
 
diff -r 2b83d3a96703 -r 7228bd10a8cc artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMainCalculationResult.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMainCalculationResult.java	Mon Sep 10 15:31:55 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMainCalculationResult.java	Mon Sep 10 17:06:23 2018 +0200
@@ -94,7 +94,8 @@
 
         exportContextCSV.writeCSVWaterlevelMetadata(this.wst);
         exportContextCSV.writeBlankLine();
-        exportContextCSV.writeCSVSoundingMetadata(this.sounding, "common.export.csv.meta.header.sounding");
+        if (this.sounding != null)
+            exportContextCSV.writeCSVSoundingMetadata(this.sounding, "common.export.csv.meta.header.sounding");
 
         // Reihenfolge in der LV anders; ich finde sie aber so sinnvoller
         exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.function", this.function);
diff -r 2b83d3a96703 -r 7228bd10a8cc artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/BedHeightsFinder.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/BedHeightsFinder.java	Mon Sep 10 15:31:55 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/BedHeightsFinder.java	Mon Sep 10 17:06:23 2018 +0200
@@ -42,6 +42,8 @@
 
     private Calculation problems;
 
+    private final boolean isNull;
+
     /**
      * Create bed height finders from a collection of bed heights.
      */
@@ -112,6 +114,14 @@
     }
 
     /**
+     * Creates a {@link BedHeightsFinder} that returns always NaN heights
+     */
+    public static BedHeightsFinder NullFinder() {
+        final NavigableMap<Double, BedHeightValue> values = new TreeMap<>();
+        return new BedHeightsFinder(null, null, values, true);
+    }
+
+    /**
      * Create a finder for a given bed height.
      *
      */
@@ -132,13 +142,23 @@
 
         final BedHeightInfo info = BedHeightInfo.from(bedHeight);
 
-        return new BedHeightsFinder(problems, info, values);
+        return new BedHeightsFinder(problems, info, values, false);
     }
 
-    private BedHeightsFinder(final Calculation problems, final BedHeightInfo info, final NavigableMap<Double, BedHeightValue> values) {
+    private BedHeightsFinder(final Calculation problems, final BedHeightInfo info, final NavigableMap<Double, BedHeightValue> values, final boolean isNull) {
         this.info = info;
         this.values = values;
         this.problems = problems;
+        this.isNull = isNull;
+    }
+
+    /**
+     * Whether this is a null (always NaN) finder.
+     * 
+     * @return
+     */
+    public boolean isNull() {
+        return this.isNull;
     }
 
     public boolean isEmpty() {
diff -r 2b83d3a96703 -r 7228bd10a8cc artifacts/src/main/resources/messages.properties
--- a/artifacts/src/main/resources/messages.properties	Mon Sep 10 15:31:55 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties	Mon Sep 10 17:06:23 2018 +0200
@@ -923,8 +923,12 @@
 bundu.export.bezugswst.pdf.meta.miss.costs = Excavation Costs [\u20ac]
 bundu.export.bezugswst.csv.meta.miss.excavation = Excavation Volume [m\u00b3]
 bundu.export.bezugswst.pdf.meta.miss.excavation = Excavation Volume [m\u00b3]
-bundu.export.bezugswst.csv.meta.miss.mass.total = Missing Depth Total Mass [t]
-bundu.export.bezugswst.csv.meta.miss.volume.total = Missing Depth Total Volume [m\u00b3]
+bundu.export.bezugswst.csv.meta.miss.mass.total = Total Missing Mass [t]
+bundu.export.bezugswst.csv.meta.miss.volume.total = Total Missing Volume [m\u00b3]
+bundu.export.bezugswst.csv.meta.miss.coststotal = Total Excavation Costs [\u20ac]
+bundu.export.bezugswst.pdf.meta.miss.coststotal = Total Excavation Costs [\u20ac]
+bundu.export.bezugswst.csv.meta.miss.excavationtotal = Total Excavation Volume [m\u00b3]
+bundu.export.bezugswst.pdf.meta.miss.excavationtotal = Total Excavation Volume [m\u00b3]
 bundu.export.bezugswst.csv.meta.miss.exists = Missing Depths Available?
 bundu.export.bezugswst.pdf.meta.miss.exists = Missing Depths Avail-able?
 bundu.export.bezugswst.csv.meta.miss.channel.min_depth = Channel Depths to be Provided [m]
diff -r 2b83d3a96703 -r 7228bd10a8cc artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties	Mon Sep 10 15:31:55 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Mon Sep 10 17:06:23 2018 +0200
@@ -923,8 +923,12 @@
 bundu.export.bezugswst.pdf.meta.miss.costs = Bagger-kosten [\u20ac]
 bundu.export.bezugswst.csv.meta.miss.excavation = Baggervolumen [m\u00b3]
 bundu.export.bezugswst.pdf.meta.miss.excavation = Bagger-volumen [m\u00b3]
-bundu.export.bezugswst.csv.meta.miss.mass.total = Masse Fehltiefe ges. [t]
-bundu.export.bezugswst.csv.meta.miss.volume.total = Volumen Fehltiefe ges. [m\u00b3]
+bundu.export.bezugswst.csv.meta.miss.mass.total = Fehlmasse gesamt [t]
+bundu.export.bezugswst.csv.meta.miss.volume.total = Fehlvolumen gesamt [m\u00b3]
+bundu.export.bezugswst.csv.meta.miss.coststotal = Baggerkosten gesamt [\u20ac]
+bundu.export.bezugswst.pdf.meta.miss.coststotal = Bagger-kosten gesamt [\u20ac]
+bundu.export.bezugswst.csv.meta.miss.excavationtotal = Baggervolumen gesamt [m\u00b3]
+bundu.export.bezugswst.pdf.meta.miss.excavationtotal = Bagger-volumen gesamt [m\u00b3]
 bundu.export.bezugswst.csv.meta.miss.exists = Fehltiefe vorhanden?
 bundu.export.bezugswst.pdf.meta.miss.exists = Fehl-tiefe vor-handen?
 bundu.export.bezugswst.csv.meta.miss.channel.min_depth = Zu gew\u00e4hrleistende Fahrrinnentiefe [m]


More information about the Dive4Elements-commits mailing list