changeset 3897:bce2dd4310a6

MINFO: Updated data fields to fit the needs of bedheight difference calculation. flys-artifacts/trunk@5560 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 21 Sep 2012 14:18:16 +0000
parents 82109cea32d2
children 95d699c769fb
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeight.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightEpoch.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightFactory.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightSingle.java
diffstat 5 files changed, 57 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Sep 21 14:03:48 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Sep 21 14:18:16 2012 +0000
@@ -1,3 +1,11 @@
+2012-09-21  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeight.java,
+	  src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightSingle.java,
+	  src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightEpoch.java,
+	  src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightFactory.java:
+	  Updated data fields to fit the needs of bedheight difference calculation.
+
 2012-09-21	Björn Ricks	<bjoern.ricks@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/services/GaugeOverviewInfoService.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeight.java	Fri Sep 21 14:03:48 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeight.java	Fri Sep 21 14:18:16 2012 +0000
@@ -12,22 +12,16 @@
 
     protected TDoubleArrayList heights;
     protected TDoubleArrayList station;
-    protected TDoubleArrayList data_gap;
-    protected TDoubleArrayList morphWidth;
 
     public BedHeight() {
         heights = new TDoubleArrayList();
         station = new TDoubleArrayList();
-        data_gap = new TDoubleArrayList();
-        morphWidth = new TDoubleArrayList();
     }
 
     public BedHeight(String name) {
         super(name);
         heights = new TDoubleArrayList();
         station = new TDoubleArrayList();
-        data_gap = new TDoubleArrayList();
-        morphWidth = new TDoubleArrayList();
     }
 
     public BedHeight(int capacity) {
@@ -38,15 +32,11 @@
         super(name);
         heights = new TDoubleArrayList(capacity);
         station = new TDoubleArrayList(capacity);
-        data_gap = new TDoubleArrayList(capacity);
-        morphWidth = new TDoubleArrayList();
     }
 
-    public void add(double value, double station, double gap, double width) {
+    public void add(double value, double station) {
         this.heights.add(value);
         this.station.add(station);
-        this.data_gap.add(gap);
-        this.morphWidth.add(width);
     }
 
     public int size() {
@@ -68,20 +58,10 @@
     public double [] get(int idx, double [] dst) {
         dst[0] = heights.getQuick(idx);
         dst[1] = station.getQuick(idx);
-        dst[2] = data_gap.getQuick(idx);
-        dst[3] = morphWidth.getQuick(idx);
         return dst;
     }
 
-    public double getMorphWidth(int idx) {
-        return this.morphWidth.get(idx);
-    }
-
-    public double getDataGap(int idx) {
-        return this.data_gap.get(idx);
-    }
-
-    public double minHeights() {
+   public double minHeights() {
         return heights.min();
     }
 
@@ -96,6 +76,7 @@
         return Double.NaN;
     }
 
+
     public static void removeNaNs(TDoubleArrayList [] arrays) {
 
         int dest = 0;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightEpoch.java	Fri Sep 21 14:03:48 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightEpoch.java	Fri Sep 21 14:18:16 2012 +0000
@@ -24,12 +24,10 @@
     public void add(
         double value,
         double station,
-        double gap,
-        double width,
         Date start,
         Date end
     ) {
-        super.add(value, station, gap, width);
+        super.add(value, station);
         this.start = start;
         this.end = end;
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightFactory.java	Fri Sep 21 14:03:48 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightFactory.java	Fri Sep 21 14:18:16 2012 +0000
@@ -22,16 +22,18 @@
 
     /** Query to get km and ws for wst_id and column_pos. */
     public static final String SQL_SELECT_SINGLE =
-        "SELECT height, station, data_gap, sounding_width, year " +
-        "   FROM bed_height_single_values " +
-        "   WHERE id = :height_id";
+        "SELECT bhsv.height, bhsv.station, bhsv.data_gap, bhsv.sounding_width, bhs.year " +
+        "   FROM bed_height_single bhs" +
+        "       JOIN bed_height_single_values bhsv on bhsv.bed_height_single_id = bhs.id" +
+        "   WHERE bhs.id = :height_id";
 
     /** Query to get name for wst_id and column_pos. */
     public static final String SQL_SELECT_EPOCH =
-        "SELECT b.height, b.station, ti.start_time, ti.stop_time" +
-        "   FROM bed_height_epoch_values b" +
-        "       JOIN time_interval ti ON b.time_interval_id = ti.id" +
-        "   WHERE id = :height_id";
+        "SELECT bv.height, bv.station, ti.start_time, ti.stop_time" +
+        "   FROM bed_height_epoch b" +
+        "       JOIN bed_height_epoch_values bv ON b.id = bv.bed_height_epoch_id" +
+        "       JOIN time_intervals ti ON b.time_interval_id = ti.id" +
+        "   WHERE b.id = :height_id";
 
     /** Query to get name (description) for wst_id. */
     public static final String SQL_SELECT_DESCR_SINGLE =
@@ -138,8 +140,9 @@
             sqlQuery.setInteger("height_id", height_id);
             List<Object []> results = sqlQuery.list();
 
-            for (int i = 0; i <= results.size(); i++) {
+            for (int i = 0; i < results.size(); i++) {
                 Object[] row = results.get(i);
+                log.debug("got station: " + (Double)row[1]);
                 height.add(
                     (Double) row[0],
                     (Double) row[1],
@@ -160,13 +163,11 @@
             sqlQuery.setInteger("height_id", height_id);
             List<Object []> results = sqlQuery.list();
 
-            for (int i = 0; i <= results.size(); i++) {
+            for (int i = 0; i < results.size(); i++) {
                 Object[] row = results.get(i);
                 height.add(
                     (Double) row[0],
                     (Double) row[1],
-                    0,
-                    0,
                     (Date) row[2],
                     (Date)row[3]);
             }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightSingle.java	Fri Sep 21 14:03:48 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightSingle.java	Fri Sep 21 14:18:16 2012 +0000
@@ -1,20 +1,28 @@
 package de.intevation.flys.artifacts.model.minfo;
 
+import gnu.trove.TDoubleArrayList;
+
 
 public class BedHeightSingle
 extends BedHeight
 {
 
     protected int year;
+    protected TDoubleArrayList data_gap;
+    protected TDoubleArrayList morphWidth;
 
     public BedHeightSingle() {
         super();
         this.year = -1;
+        data_gap = new TDoubleArrayList();
+        morphWidth = new TDoubleArrayList();
     }
 
     public BedHeightSingle(String name) {
         super(name);
         this.year = -1;
+        data_gap = new TDoubleArrayList();
+        morphWidth = new TDoubleArrayList();
     }
 
     public void add(
@@ -24,11 +32,35 @@
         double width,
         int year
     ) {
-        super.add(value, station, gap, width);
+        super.add(value, station);
         this.year = year;
+        this.data_gap.add(gap);
+        this.morphWidth.add(width);
     }
 
     public int getYear() {
         return this.year;
     }
+
+    public double getMorphWidth(int idx) {
+        return this.morphWidth.get(idx);
+    }
+
+    public double getDataGap(int idx) {
+        return this.data_gap.get(idx);
+    }
+
+    public double getMorphWidth(double station) {
+        if (this.station.indexOf(station) >= 0) {
+            return this.morphWidth.get(this.station.indexOf(station));
+        }
+        return Double.NaN;
+    }
+
+    public double getDataGap(double station) {
+        if (this.station.indexOf(station) >= 0) {
+            return this.getDataGap(this.station.indexOf(station));
+        }
+        return Double.NaN;
+    }
 }

http://dive4elements.wald.intevation.org