diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTableFactory.java @ 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 c3b44da22a3a
children 7053e3255ab4
line wrap: on
line diff
--- 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