annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstValueTableFactory.java @ 8705:682a26e4158b

(issue1787) Globally sorting WST-columns over avg(Q)+max(Q) might give unexpected results at some kms. We thus sort locally since Rev 93a31cfb18c0.
author Tom Gottfried <tom@intevation.de>
date Thu, 23 Apr 2015 19:20:40 +0200
parents af13ceeba52a
children 5e38e2924c07
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5423
diff changeset
9 package org.dive4elements.river.artifacts.model;
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
1894
d5e51cc7da23 New method to get interpolator for given wst_ids, also prepopulate arrays with NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1839
diff changeset
11 import java.util.Arrays;
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
12 import java.util.List;
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 import java.util.ArrayList;
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
14
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
15 import net.sf.ehcache.Cache;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
16 import net.sf.ehcache.Element;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
17
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5423
diff changeset
18 import org.dive4elements.river.artifacts.cache.CacheFactory;
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
19
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5423
diff changeset
20 import org.dive4elements.river.backend.SessionHolder;
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
21
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
22 import org.apache.log4j.Logger;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
23
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5423
diff changeset
24 import org.dive4elements.river.model.River;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5423
diff changeset
25 import org.dive4elements.river.model.Wst;
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 import org.hibernate.Session;
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 import org.hibernate.Query;
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 import org.hibernate.SQLQuery;
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 import org.hibernate.type.StandardBasicTypes;
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32
1839
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
33 /**
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
34 * Creates WstValueTable s from database.
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
35 * WstValueTable s are used to interpolate given w/q/km values.
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
36 */
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 public class WstValueTableFactory
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 {
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 private static Logger log = Logger.getLogger(WstValueTableFactory.class);
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
41 public static final int DEFAULT_KIND = 0;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
42
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 // TODO: put this into a property file
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
44
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
45 public static final String HQL_WST =
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
46 "from Wst where river=:river and kind=:kind";
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
47
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
48 public static final String SQL_SELECT_NAMES_POS =
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
49 "SELECT position, name FROM wst_columns " +
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
50 "WHERE wst_id = :wst_id ORDER BY position";
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
51
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
52 /** Select Qs for wst (view sorted by column). */
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
53 public static final String SQL_SELECT_QS =
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
54 "SELECT column_pos, q, a, b FROM wst_q_values " +
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
55 "WHERE wst_id = :wst_id";
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
56
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
57 // (sorted by km)
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
58 public static final String SQL_SELECT_WS =
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
59 "SELECT km, w, column_pos FROM wst_w_values " +
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
60 "WHERE wst_id = :wst_id";
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
62 /** Statement to query qranges of a single column. */
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
63 public static final String SQL_SELECT_QS_AT_COL =
2609
ed550e325248 Little optimization when fetching q ranges for single columns of wsts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1927
diff changeset
64 "SELECT q, a, b FROM wst_q_values " +
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
65 "WHERE wst_id = :wst_id AND column_pos = :column_pos";
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
66
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
67 // (sorted by km)
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
68 public static final String SQL_SELECT_WS_AT_COL =
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
69 "SELECT km, w FROM wst_w_values " +
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
70 "WHERE wst_id = :wst_id AND column_pos = :column_pos";
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
71
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
72
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 private WstValueTableFactory() {
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74 }
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
76
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 public static WstValueTable getTable(River river) {
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
78 return getTable(river, DEFAULT_KIND);
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 }
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80
1839
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
81
1894
d5e51cc7da23 New method to get interpolator for given wst_ids, also prepopulate arrays with NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1839
diff changeset
82 /**
d5e51cc7da23 New method to get interpolator for given wst_ids, also prepopulate arrays with NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1839
diff changeset
83 * Get WstValueTable to interpolate values of a given Wst.
d5e51cc7da23 New method to get interpolator for given wst_ids, also prepopulate arrays with NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1839
diff changeset
84 */
d5e51cc7da23 New method to get interpolator for given wst_ids, also prepopulate arrays with NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1839
diff changeset
85 public static WstValueTable getTable(int wst_id) {
d5e51cc7da23 New method to get interpolator for given wst_ids, also prepopulate arrays with NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1839
diff changeset
86
1898
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
87 Cache cache = CacheFactory.getCache(WstValueTableCacheKey.CACHE_NAME);
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
88
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
89 WstValueTableCacheKey cacheKey;
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
90
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
91 if (cache != null) {
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
92 // "-1" is the symbolic river-id for "no river, but wst_id".
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
93 cacheKey = new WstValueTableCacheKey(-1, wst_id);
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
94 Element element = cache.get(cacheKey);
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
95 if (element != null) {
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
96 log.debug("Got specific wst value table from cache");
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
97 return (WstValueTable) element.getValue();
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
98 }
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
99 }
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
100 else {
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
101 cacheKey = null;
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
102 }
1894
d5e51cc7da23 New method to get interpolator for given wst_ids, also prepopulate arrays with NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1839
diff changeset
103
d5e51cc7da23 New method to get interpolator for given wst_ids, also prepopulate arrays with NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1839
diff changeset
104 Session session = SessionHolder.HOLDER.get();
d5e51cc7da23 New method to get interpolator for given wst_ids, also prepopulate arrays with NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1839
diff changeset
105
d5e51cc7da23 New method to get interpolator for given wst_ids, also prepopulate arrays with NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1839
diff changeset
106 // Fetch data for one column only.
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2610
diff changeset
107
1894
d5e51cc7da23 New method to get interpolator for given wst_ids, also prepopulate arrays with NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1839
diff changeset
108 WstValueTable.Column [] columns = loadColumns(session, wst_id);
8705
682a26e4158b (issue1787) Globally sorting WST-columns over avg(Q)+max(Q) might give unexpected results at some kms. We thus sort locally since Rev 93a31cfb18c0.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
109 loadQRanges(session, columns, wst_id);
682a26e4158b (issue1787) Globally sorting WST-columns over avg(Q)+max(Q) might give unexpected results at some kms. We thus sort locally since Rev 93a31cfb18c0.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
110 List<WstValueTable.Row> rows = loadRows(session, wst_id, columns.length);
1894
d5e51cc7da23 New method to get interpolator for given wst_ids, also prepopulate arrays with NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1839
diff changeset
111
1927
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
112 WstValueTable valueTable = new WstValueTable(columns, rows);
1898
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
113
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
114 if (valueTable != null && cacheKey != null) {
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
115 log.debug("Store wst value table in cache");
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
116 Element element = new Element(cacheKey, valueTable);
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
117 cache.put(element);
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
118 }
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
119
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
120 return valueTable;
1894
d5e51cc7da23 New method to get interpolator for given wst_ids, also prepopulate arrays with NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1839
diff changeset
121 }
1898
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
122
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
123 /**
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
124 * Get Table for a specific column of a wst.
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
125 */
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
126 public static WstValueTable getWstColumnTable(int wst_id, int col_pos) {
1898
7053e3255ab4 Employ cache for WstValueTables that have been fetched by wst_id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1894
diff changeset
127
1927
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
128 Cache cache = CacheFactory.getCache(WstValueTableCacheKey.CACHE_NAME);
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
129
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
130 WstValueTableCacheKey cacheKey;
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
131
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
132 if (cache != null) {
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
133 // A negaitve/negative number is the symbolic 'river-id' for
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
134 // "no river and kind but wst_id and colpos".
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
135 cacheKey = new WstValueTableCacheKey(-wst_id, -col_pos);
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
136 Element element = cache.get(cacheKey);
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
137 if (element != null) {
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
138 log.debug("Got specific wst value table from cache");
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
139 return (WstValueTable) element.getValue();
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
140 }
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
141 }
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
142 else {
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
143 cacheKey = null;
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
144 }
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
145
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
146 Session session = SessionHolder.HOLDER.get();
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
147
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
148 // Fetch data for one column only.
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2610
diff changeset
149
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
150 WstValueTable.Column [] columns = loadColumn(session, wst_id, col_pos);
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
151 loadQRanges(session, columns, wst_id, col_pos);
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
152 List<WstValueTable.Row> rows = loadRowsOneColumn(session, wst_id, col_pos);
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
153
1927
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
154 WstValueTable valueTable = new WstValueTable(columns, rows);
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
155
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
156 if (valueTable != null && cacheKey != null) {
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
157 log.debug("Store wst value table in cache (wst: "
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
158 + wst_id + "/ col: " + col_pos + ")");
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
159 Element element = new Element(cacheKey, valueTable);
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
160 cache.put(element);
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
161 }
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
162
1f90fdd4fa04 Resolved TODO about caching certain WstValueTables.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1909
diff changeset
163 return valueTable;
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
164 }
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
165
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
166
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
167 /**
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
168 * Get table for first wst of given kind at given river.
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
169 */
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
170 public static WstValueTable getTable(River river, int kind) {
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
171
632
07640ab913fd First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 626
diff changeset
172 Cache cache = CacheFactory.getCache(WstValueTableCacheKey.CACHE_NAME);
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
173
626
e3ee131d5dd3 Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 458
diff changeset
174 WstValueTableCacheKey cacheKey;
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
175
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
176 if (cache != null) {
626
e3ee131d5dd3 Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 458
diff changeset
177 cacheKey = new WstValueTableCacheKey(river.getId(), kind);
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
178 Element element = cache.get(cacheKey);
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
179 if (element != null) {
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
180 log.debug("got wst value table from cache");
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
181 return (WstValueTable)element.getValue();
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
182 }
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
183 }
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
184 else {
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
185 cacheKey = null;
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
186 }
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
187
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
188 WstValueTable valueTable = getTableUncached(river, kind);
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
189
632
07640ab913fd First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 626
diff changeset
190 if (valueTable != null && cacheKey != null) {
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
191 log.debug("store wst value table in cache");
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
192 Element element = new Element(cacheKey, valueTable);
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
193 cache.put(element);
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
194 }
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
195
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
196 return valueTable;
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
197 }
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
198
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
199 public static WstValueTable getTableUncached(River river) {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
200 return getTableUncached(river, DEFAULT_KIND);
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
201 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
202
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
203 public static WstValueTable getTableUncached(River river, int kind) {
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
204
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
205 Session session = SessionHolder.HOLDER.get();
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
206
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
207 Wst wst = loadWst(session, river, kind);
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
208
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
209 if (wst == null) {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
210 return null;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
211 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
212
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
213 WstValueTable.Column [] columns = loadColumns(session, wst);
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
214
8705
682a26e4158b (issue1787) Globally sorting WST-columns over avg(Q)+max(Q) might give unexpected results at some kms. We thus sort locally since Rev 93a31cfb18c0.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
215 loadQRanges(session, columns, wst);
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
216
8705
682a26e4158b (issue1787) Globally sorting WST-columns over avg(Q)+max(Q) might give unexpected results at some kms. We thus sort locally since Rev 93a31cfb18c0.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
217 List<WstValueTable.Row> rows = loadRows(session, wst, columns.length);
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
218
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
219 return new WstValueTable(columns, rows);
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
220 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
221
1780
b503d92dd709 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
222 /**
b503d92dd709 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
223 * @param kind Kind of wst.
b503d92dd709 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
224 */
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
225 protected static Wst loadWst(Session session, River river, int kind) {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
226 Query query = session.createQuery(HQL_WST);
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
227 query.setParameter("river", river);
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
228 query.setInteger("kind", kind);
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
229
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
230 List<Wst> wsts = query.list();
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
231
1839
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
232 // TODO Multiple wsts can match, why return just the first one?
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
233 return wsts.isEmpty() ? null : wsts.get(0);
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
234 }
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
235
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
236
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
237 /**
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
238 * Load rows with a single columns result.
3269
b2ea89a665bc Fix issues in 'documentation'.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
239 *
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
240 * @param session session to use for querying db.
3269
b2ea89a665bc Fix issues in 'documentation'.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
241 * @param wstId id of wst (in db).
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
242 * @param column_pos the column_pos (within the db) of the wst_value_table
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
243 * of which the values shall be fetched.
3269
b2ea89a665bc Fix issues in 'documentation'.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
244 *
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
245 * @return resultant rows.
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
246 */
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
247 protected static List<WstValueTable.Row> loadRowsOneColumn(
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
248 Session session,
2610
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2609
diff changeset
249 int wstId,
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
250 int column_pos
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
251 ) {
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
252 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_WS_AT_COL)
2610
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2609
diff changeset
253 .addScalar("km", StandardBasicTypes.DOUBLE)
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2609
diff changeset
254 .addScalar("w", StandardBasicTypes.DOUBLE);
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
255
2610
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2609
diff changeset
256 sqlQuery.setInteger("wst_id", wstId);
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
257 sqlQuery.setInteger("column_pos", column_pos);
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
258
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
259 List<Object []> results = sqlQuery.list();
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
260
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
261 double [] ws = null;
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
262
2610
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2609
diff changeset
263 List<WstValueTable.Row> rows =
3c907758f0ab Added cacheable model for fixing column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2609
diff changeset
264 new ArrayList<WstValueTable.Row>(results.size());
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
265
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
266 // Walk over rows.
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
267 for (Object [] result: results) {
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
268 ws = new double[1];
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
269 WstValueTable.Row row =
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
270 new WstValueTable.Row((Double) result[0], ws);
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
271 rows.add(row);
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
272
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
273 Double w = (Double) result[1];
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
274 ws[0] = w != null ? w : Double.NaN;
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
275 }
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
276
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
277 return rows;
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
278 }
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
279
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
280 protected static List<WstValueTable.Row> loadRows(
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 633
diff changeset
281 Session session,
1839
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
282 int wst_id,
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
283 int numColumns
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
284 ) {
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
285 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_WS)
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
286 .addScalar("km", StandardBasicTypes.DOUBLE)
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
287 .addScalar("w", StandardBasicTypes.DOUBLE)
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
288 .addScalar("column_pos", StandardBasicTypes.INTEGER);
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
289
1839
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
290 sqlQuery.setInteger("wst_id", wst_id);
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
291
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
292 List<Object []> results = sqlQuery.list();
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
293
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
294 int lastColumn = Integer.MAX_VALUE;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
295 double [] ws = null;
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
296
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
297 ArrayList<WstValueTable.Row> rows = new ArrayList<WstValueTable.Row>();
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
298
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
299 for (Object [] result: results) {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
300 int column = (Integer)result[2];
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
301 if (column < lastColumn) {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
302 ws = new double[numColumns];
1894
d5e51cc7da23 New method to get interpolator for given wst_ids, also prepopulate arrays with NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1839
diff changeset
303 Arrays.fill(ws, Double.NaN);
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
304 WstValueTable.Row row =
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
305 new WstValueTable.Row((Double)result[0], ws);
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
306 rows.add(row);
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
307 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
308 Double w = (Double)result[1];
8705
682a26e4158b (issue1787) Globally sorting WST-columns over avg(Q)+max(Q) might give unexpected results at some kms. We thus sort locally since Rev 93a31cfb18c0.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
309 ws[column] = w != null ? w : Double.NaN;
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
310 lastColumn = column;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
311 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
312
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
313 rows.trimToSize();
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
314 return rows;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
315 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
316
1839
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
317 protected static List<WstValueTable.Row> loadRows(
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
318 Session session,
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
319 Wst wst,
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
320 int numColumns
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
321 ) {
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
322 return loadRows(session, wst.getId(), numColumns);
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
323 }
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
324
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
325
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
326 protected static WstValueTable.Column [] loadColumn(
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
327 Session session,
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
328 int wst_id,
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
329 int col_pos
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
330 ) {
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
331 return new WstValueTable.Column [] {
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
332 new WstValueTable.Column(WKmsFactory.getWKmsName(col_pos, wst_id))};
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
333 }
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
334
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
335
1839
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
336 /**
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
337 * Get columns from wst-id.
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
338 */
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
339 protected static WstValueTable.Column [] loadColumns(
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
340 Session session,
1839
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
341 int wst_id
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
342 ) {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
343 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_NAMES_POS)
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
344 .addScalar("position", StandardBasicTypes.INTEGER)
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
345 .addScalar("name", StandardBasicTypes.STRING);
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
346
1839
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
347 sqlQuery.setInteger("wst_id", wst_id);
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
348
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
349 List<Object []> columnNames = sqlQuery.list();
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
350
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
351 WstValueTable.Column [] columns =
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
352 new WstValueTable.Column[columnNames.size()];
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
353
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
354 for (int i = 0; i < columns.length; ++i) {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
355 columns[i] = new WstValueTable.Column(
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
356 (String)columnNames.get(i)[1]);
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
357 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
358 return columns;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
359 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
360
1839
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
361 /**
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
362 * Get columns from Wst.
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
363 */
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
364 protected static WstValueTable.Column [] loadColumns(
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
365 Session session,
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
366 Wst wst
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
367 ) {
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
368 return loadColumns(session, wst.getId());
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
369 }
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
370
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
371
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
372 /**
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
373 * Build a QRange-Tree.
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
374 */
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
375 protected static void loadQRanges(
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
376 Session session,
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
377 WstValueTable.Column [] columns,
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
378 int wst_id,
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
379 int column_pos
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
380 ) {
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
381 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_QS_AT_COL)
2609
ed550e325248 Little optimization when fetching q ranges for single columns of wsts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1927
diff changeset
382 .addScalar("q", StandardBasicTypes.DOUBLE)
ed550e325248 Little optimization when fetching q ranges for single columns of wsts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1927
diff changeset
383 .addScalar("a", StandardBasicTypes.DOUBLE)
ed550e325248 Little optimization when fetching q ranges for single columns of wsts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1927
diff changeset
384 .addScalar("b", StandardBasicTypes.DOUBLE);
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
385
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
386 sqlQuery.setInteger("wst_id", wst_id);
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
387 sqlQuery.setInteger("column_pos", column_pos);
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
388
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
389 List<Object []> qRanges = sqlQuery.list();
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
390
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
391 int qSize = qRanges.size();
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
392
2609
ed550e325248 Little optimization when fetching q ranges for single columns of wsts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1927
diff changeset
393 QRangeTree qRangeTree = new QRangeTree(
ed550e325248 Little optimization when fetching q ranges for single columns of wsts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1927
diff changeset
394 qRanges, QRangeTree.WITHOUT_COLUMN, 0, qSize);
1909
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
395 columns[0].setQRangeTree(qRangeTree);
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
396 }
4b64692b2d1e Added methods to create WstValueTables ('interpolators') for specific columns of wsts.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1898
diff changeset
397
8705
682a26e4158b (issue1787) Globally sorting WST-columns over avg(Q)+max(Q) might give unexpected results at some kms. We thus sort locally since Rev 93a31cfb18c0.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
398 protected static void loadQRanges(
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
399 Session session,
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
400 WstValueTable.Column [] columns,
1839
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
401 int wst_id
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
402 ) {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
403 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_QS)
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
404 .addScalar("column_pos", StandardBasicTypes.INTEGER)
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
405 .addScalar("q", StandardBasicTypes.DOUBLE)
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
406 .addScalar("a", StandardBasicTypes.DOUBLE)
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
407 .addScalar("b", StandardBasicTypes.DOUBLE);
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
408
1839
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
409 sqlQuery.setInteger("wst_id", wst_id);
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
410
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
411 List<Object []> qRanges = sqlQuery.list();
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
412
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
413 int start = -1;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
414 int Q = qRanges.size();
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
415 Integer lastColumn = null;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
416
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
417 for (int i = 0; i < Q; ++i) {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
418 Object [] qRange = qRanges.get(i);
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
419 Integer columnId = (Integer)qRange[0];
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
420 if (lastColumn == null) {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
421 lastColumn = columnId;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
422 start = i;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
423 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
424 else if (!lastColumn.equals(columnId)) {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
425 QRangeTree qRangeTree = new QRangeTree(qRanges, start, i);
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
426 columns[lastColumn].setQRangeTree(qRangeTree);
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
427 lastColumn = columnId;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
428 start = i;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
429 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
430 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
431
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
432 if (start != -1) {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
433 QRangeTree qRangeTree = new QRangeTree(qRanges, start, Q);
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
434 columns[lastColumn].setQRangeTree(qRangeTree);
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
435 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
436
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 633
diff changeset
437 /* This is debug code to visualize the q ranges trees
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
438
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
439 java.io.PrintWriter out = null;
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
440 try {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
441 out = new java.io.PrintWriter(
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
442 new java.io.FileWriter(
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
443 "/tmp/qranges" + System.currentTimeMillis() + ".dot"));
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
444
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
445 out.println("graph \"Q ranges trees\" {");
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
446
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
447 for (int i = 0; i < columns.length; ++i) {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
448 QRangeTree tree = columns[i].getQRangeTree();
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
449 out.println(tree.toGraph());
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
450 }
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
451
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
452 out.println("}");
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
453
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
454 out.flush();
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
455 }
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
456 catch (java.io.IOException ioe) {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
457 log.error(ioe);
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
458 }
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
459 finally {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
460 if (out != null) {
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
461 out.close();
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
462 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
463 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
464 */
1839
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
465 }
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
466
8705
682a26e4158b (issue1787) Globally sorting WST-columns over avg(Q)+max(Q) might give unexpected results at some kms. We thus sort locally since Rev 93a31cfb18c0.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
467 protected static void loadQRanges(
1839
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
468 Session session,
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
469 WstValueTable.Column [] columns,
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
470 Wst wst
c3b44da22a3a Minor refactoring in preparation of generation of interpolators (WstValueTable) for static WQKms.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
471 ) {
8705
682a26e4158b (issue1787) Globally sorting WST-columns over avg(Q)+max(Q) might give unexpected results at some kms. We thus sort locally since Rev 93a31cfb18c0.
Tom Gottfried <tom@intevation.de>
parents: 5994
diff changeset
472 loadQRanges(session, columns, wst.getId());
633
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
473 }
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
474
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
475 }
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
476 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org