diff artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMainCalculationResult.java @ 9444:ecadc9ed0ba0

Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
author mschaefer
date Tue, 21 Aug 2018 13:41:18 +0200
parents d2f5375ede26
children 7228bd10a8cc
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMainCalculationResult.java	Mon Aug 20 18:50:33 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMainCalculationResult.java	Tue Aug 21 13:41:18 2018 +0200
@@ -11,6 +11,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
 import org.dive4elements.river.artifacts.bundu.BunduResultType;
 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult;
@@ -25,6 +26,8 @@
 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo;
 import org.dive4elements.river.artifacts.sinfo.util.WstInfo;
 
+import gnu.trove.TDoubleArrayList;
+
 /**
  * Contains the results of a //TODO LINK{@link BezugswstCalculation}.
  *
@@ -169,4 +172,27 @@
         exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location);
 
     }
+
+    /**
+     * Gets a longitudinal section of a result type value of a cross section field
+     *
+     * @param fieldIndex
+     *            1-based field index
+     * @param type
+     *            result type like bedHeightField
+     */
+    public final double[][] getFieldValuePoints(final int fieldIndex, final BunduResultType type) {
+
+        final TDoubleArrayList x = new TDoubleArrayList(this.getRows().size());
+        final TDoubleArrayList y = new TDoubleArrayList(this.getRows().size());
+
+        for (final ResultRow row : this.getRows()) {
+            x.add(row.getDoubleValue(GeneralResultType.station));
+            @SuppressWarnings("unchecked")
+            final List<Double> fieldHeights = (List<Double>) row.getValue(type);
+            y.add(fieldHeights.get(fieldIndex - 1));
+        }
+
+        return new double[][] { x.toNativeArray(), y.toNativeArray() };
+    }
 }
\ No newline at end of file

http://dive4elements.wald.intevation.org