changeset 3886:633fbb61a0cc

Split bed heights into bed height epochs and single bed heights. flys-artifacts/trunk@5536 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 20 Sep 2012 09:31:18 +0000
parents 393c10b07a76
children a1c79d84e3cd
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, 150 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Sep 20 09:26:17 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Sep 20 09:31:18 2012 +0000
@@ -1,3 +1,15 @@
+2012-09-20  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightFactory.java:
+	  Create separate objects for bed height epochs and single bed heights.
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeight.java:
+	  Added morph. width.
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightEpoch.java,
+	  src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightSingle.java:
+	  New. Separate classes for bed height epochs and single bed heights.
+
 2012-09-20  Raimund Renkert <raimund.renkert@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/minfo/BedQualityExporter.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeight.java	Thu Sep 20 09:26:17 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeight.java	Thu Sep 20 09:31:18 2012 +0000
@@ -13,11 +13,13 @@
     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) {
@@ -25,6 +27,7 @@
         heights = new TDoubleArrayList();
         station = new TDoubleArrayList();
         data_gap = new TDoubleArrayList();
+        morphWidth = new TDoubleArrayList();
     }
 
     public BedHeight(int capacity) {
@@ -36,12 +39,14 @@
         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) {
+    public void add(double value, double station, double gap, double width) {
         this.heights.add(value);
         this.station.add(station);
         this.data_gap.add(gap);
+        this.morphWidth.add(width);
     }
 
     public int size() {
@@ -64,13 +69,33 @@
         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() {
         return heights.min();
     }
 
+    public TDoubleArrayList getStations() {
+        return this.station;
+    }
+
+    public double getHeight(double station) {
+        if (this.station.indexOf(station) >= 0) {
+            return this.heights.get(this.station.indexOf(station));
+        }
+        return Double.NaN;
+    }
+
     public static void removeNaNs(TDoubleArrayList [] arrays) {
 
         int dest = 0;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightEpoch.java	Thu Sep 20 09:31:18 2012 +0000
@@ -0,0 +1,44 @@
+package de.intevation.flys.artifacts.model.minfo;
+
+import java.util.Date;
+
+
+public class BedHeightEpoch
+extends BedHeight
+{
+
+    protected Date start;
+    protected Date end;
+
+    public BedHeightEpoch() {
+        this.start = new Date();
+        this.end = new Date();
+    }
+
+    public BedHeightEpoch(String name) {
+        super(name);
+        this.start = new Date();
+        this.end = new Date();
+    }
+
+    public void add(
+        double value,
+        double station,
+        double gap,
+        double width,
+        Date start,
+        Date end
+    ) {
+        super.add(value, station, gap, width);
+        this.start = start;
+        this.end = end;
+    }
+
+    public Date getStart() {
+        return start;
+    }
+
+    public Date getEnd() {
+        return end;
+    }
+}
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightFactory.java	Thu Sep 20 09:26:17 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightFactory.java	Thu Sep 20 09:31:18 2012 +0000
@@ -1,6 +1,7 @@
 package de.intevation.flys.artifacts.model.minfo;
 
 
+import java.util.Date;
 import java.util.List;
 
 import net.sf.ehcache.Cache;
@@ -21,13 +22,16 @@
 
     /** Query to get km and ws for wst_id and column_pos. */
     public static final String SQL_SELECT_SINGLE =
-        "SELECT height, station, data_gap FROM bed_height_single_values " +
-        "WHERE id = :height_id";
+        "SELECT height, station, data_gap, sounding_width, year " +
+        "   FROM bed_height_single_values " +
+        "   WHERE id = :height_id";
 
     /** Query to get name for wst_id and column_pos. */
     public static final String SQL_SELECT_EPOCH =
-        "SELECT height, station FROM bed_height_epoch_values "+
-        "WHERE id = :height_id";
+        "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";
 
     /** Query to get name (description) for wst_id. */
     public static final String SQL_SELECT_DESCR_SINGLE =
@@ -120,37 +124,55 @@
             log.debug("BedHeightFactory.getBedHeightUncached");
         }
 
-        BedHeight height = new BedHeight(getHeightName(type, height_id));
-
         Session session = SessionHolder.HOLDER.get();
         SQLQuery sqlQuery = null;
         if (type.equals("single")) {
+            BedHeightSingle height =
+                new BedHeightSingle(getHeightName(type, height_id));
             sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE)
                 .addScalar("height", StandardBasicTypes.DOUBLE)
                 .addScalar("station", StandardBasicTypes.DOUBLE)
-                .addScalar("data_gap", StandardBasicTypes.DOUBLE);
+                .addScalar("data_gap", StandardBasicTypes.DOUBLE)
+                .addScalar("sounding_width", StandardBasicTypes.DOUBLE)
+                .addScalar("year", StandardBasicTypes.INTEGER);
             sqlQuery.setInteger("height_id", height_id);
             List<Object []> results = sqlQuery.list();
 
             for (int i = 0; i <= results.size(); i++) {
                 Object[] row = results.get(i);
-                height.add((Double) row[0], (Double) row[1], (Double) row[2]);
+                height.add(
+                    (Double) row[0],
+                    (Double) row[1],
+                    (Double) row[2],
+                    (Double) row[3],
+                    (Integer) row[4]);
             }
+            return height;
         }
         else if (type.equals("epoch")) {
+            BedHeightEpoch height =
+                new BedHeightEpoch(getHeightName(type, height_id));
             sqlQuery = session.createSQLQuery(SQL_SELECT_EPOCH)
                 .addScalar("height", StandardBasicTypes.DOUBLE)
-                .addScalar("station", StandardBasicTypes.DOUBLE);
+                .addScalar("station", StandardBasicTypes.DOUBLE)
+                .addScalar("start_time", StandardBasicTypes.DATE)
+                .addScalar("stop_time", StandardBasicTypes.DATE);
             sqlQuery.setInteger("height_id", height_id);
             List<Object []> results = sqlQuery.list();
 
             for (int i = 0; i <= results.size(); i++) {
                 Object[] row = results.get(i);
-                height.add((Double) row[0], (Double) row[1], 0);
+                height.add(
+                    (Double) row[0],
+                    (Double) row[1],
+                    0,
+                    0,
+                    (Date) row[2],
+                    (Date)row[3]);
             }
+            return height;
         }
-
-        return height;
+        return new BedHeight();
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightSingle.java	Thu Sep 20 09:31:18 2012 +0000
@@ -0,0 +1,34 @@
+package de.intevation.flys.artifacts.model.minfo;
+
+
+public class BedHeightSingle
+extends BedHeight
+{
+
+    protected int year;
+
+    public BedHeightSingle() {
+        super();
+        this.year = -1;
+    }
+
+    public BedHeightSingle(String name) {
+        super(name);
+        this.year = -1;
+    }
+
+    public void add(
+        double value,
+        double station,
+        double gap,
+        double width,
+        int year
+    ) {
+        super.add(value, station, gap, width);
+        this.year = year;
+    }
+
+    public int getYear() {
+        return this.year;
+    }
+}

http://dive4elements.wald.intevation.org