changeset 1894:d5e51cc7da23

New method to get interpolator for given wst_ids, also prepopulate arrays with NaNs. flys-artifacts/trunk@3254 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 15 Nov 2011 14:43:50 +0000
parents 1cf36ffe69b5
children 1be3a4636ee3
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTableFactory.java
diffstat 2 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Nov 15 14:37:21 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Nov 15 14:43:50 2011 +0000
@@ -1,3 +1,9 @@
+2011-11-15  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/WstValueTableFactory.java
+	  (getTable): New methods to get WstValueTable for given wst_id.
+	  Prepolate Arrays with NaNs.
+
 2011-11-15  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/WKmsFactory.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTableFactory.java	Tue Nov 15 14:37:21 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTableFactory.java	Tue Nov 15 14:43:50 2011 +0000
@@ -1,5 +1,6 @@
 package de.intevation.flys.artifacts.model;
 
+import java.util.Arrays;
 import java.util.List;
 import java.util.ArrayList;
 
@@ -56,6 +57,23 @@
     }
 
 
+    /**
+     * Get WstValueTable to interpolate values of a given Wst.
+     */
+    public static WstValueTable getTable(int wst_id) {
+
+        /** @TODO cached/uncached */
+
+        Session session = SessionHolder.HOLDER.get();
+
+        // Fetch data for one column only.
+        
+        WstValueTable.Column [] columns = loadColumns(session, wst_id);
+        loadQRanges(session, columns, wst_id);
+        List<WstValueTable.Row> rows = loadRows(session, wst_id, columns.length);
+
+        return new WstValueTable(columns, rows);
+    }
     public static WstValueTable getTable(River river, int kind) {
 
         Cache cache = CacheFactory.getCache(WstValueTableCacheKey.CACHE_NAME);
@@ -145,6 +163,7 @@
             int column = (Integer)result[2];
             if (column < lastColumn) {
                 ws = new double[numColumns];
+                Arrays.fill(ws, Double.NaN);
                 WstValueTable.Row row =
                     new WstValueTable.Row((Double)result[0], ws);
                 rows.add(row);

http://dive4elements.wald.intevation.org