Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
1893:1cf36ffe69b5 | 1894:d5e51cc7da23 |
---|---|
1 package de.intevation.flys.artifacts.model; | 1 package de.intevation.flys.artifacts.model; |
2 | 2 |
3 import java.util.Arrays; | |
3 import java.util.List; | 4 import java.util.List; |
4 import java.util.ArrayList; | 5 import java.util.ArrayList; |
5 | 6 |
6 import net.sf.ehcache.Cache; | 7 import net.sf.ehcache.Cache; |
7 import net.sf.ehcache.Element; | 8 import net.sf.ehcache.Element; |
54 public static WstValueTable getTable(River river) { | 55 public static WstValueTable getTable(River river) { |
55 return getTable(river, DEFAULT_KIND); | 56 return getTable(river, DEFAULT_KIND); |
56 } | 57 } |
57 | 58 |
58 | 59 |
60 /** | |
61 * Get WstValueTable to interpolate values of a given Wst. | |
62 */ | |
63 public static WstValueTable getTable(int wst_id) { | |
64 | |
65 /** @TODO cached/uncached */ | |
66 | |
67 Session session = SessionHolder.HOLDER.get(); | |
68 | |
69 // Fetch data for one column only. | |
70 | |
71 WstValueTable.Column [] columns = loadColumns(session, wst_id); | |
72 loadQRanges(session, columns, wst_id); | |
73 List<WstValueTable.Row> rows = loadRows(session, wst_id, columns.length); | |
74 | |
75 return new WstValueTable(columns, rows); | |
76 } | |
59 public static WstValueTable getTable(River river, int kind) { | 77 public static WstValueTable getTable(River river, int kind) { |
60 | 78 |
61 Cache cache = CacheFactory.getCache(WstValueTableCacheKey.CACHE_NAME); | 79 Cache cache = CacheFactory.getCache(WstValueTableCacheKey.CACHE_NAME); |
62 | 80 |
63 WstValueTableCacheKey cacheKey; | 81 WstValueTableCacheKey cacheKey; |
143 | 161 |
144 for (Object [] result: results) { | 162 for (Object [] result: results) { |
145 int column = (Integer)result[2]; | 163 int column = (Integer)result[2]; |
146 if (column < lastColumn) { | 164 if (column < lastColumn) { |
147 ws = new double[numColumns]; | 165 ws = new double[numColumns]; |
166 Arrays.fill(ws, Double.NaN); | |
148 WstValueTable.Row row = | 167 WstValueTable.Row row = |
149 new WstValueTable.Row((Double)result[0], ws); | 168 new WstValueTable.Row((Double)result[0], ws); |
150 rows.add(row); | 169 rows.add(row); |
151 } | 170 } |
152 Double w = (Double)result[1]; | 171 Double w = (Double)result[1]; |