annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DischargeTables.java @ 328:07e642030172

Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge. flys-artifacts/trunk@1726 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 19 Apr 2011 10:32:31 +0000
parents 94c176fdcb89
children 0b2358bc716d
rev   line source
146
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import java.util.List;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4 import java.util.Map;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 import java.util.HashMap;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 import java.util.Arrays;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 import java.io.Serializable;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 import org.hibernate.Session;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 import org.hibernate.Query;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 import org.apache.log4j.Logger;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14
315
94c176fdcb89 Removed the SessionHolder and adapted imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 311
diff changeset
15 import de.intevation.flys.backend.SessionHolder;
146
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 import de.intevation.flys.model.Gauge;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 import de.intevation.flys.model.DischargeTable;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 import de.intevation.flys.model.DischargeTableValue;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 public class DischargeTables
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 implements Serializable
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 {
328
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
23 public static final double DEFAULT_SCALE = 100.0;
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
24
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
25 public static final int MASTER = 0;
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
26
146
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 private static Logger log = Logger.getLogger(DischargeTables.class);
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 protected List<String> gaugeNames;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 protected String riverName;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32
154
03362976fa0f DischargeTables: Cache the scale, too. Otherwise two calls to getValues() with different arguments will result in the same output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 153
diff changeset
33 protected double scale;
03362976fa0f DischargeTables: Cache the scale, too. Otherwise two calls to getValues() with different arguments will result in the same output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 153
diff changeset
34
328
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
35 protected int kind;
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
36
150
c904d52cdfd0 Don't used interleaved x/y data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 146
diff changeset
37 protected Map<String, double [][]> values;
146
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 public DischargeTables() {
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 }
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41
328
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
42 public DischargeTables(String riverName, String gaugeName) {
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
43 this(riverName, gaugeName, MASTER);
146
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 }
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45
328
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
46 public DischargeTables(String riverName, String gaugeName, int kind) {
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
47 this(riverName, new String [] { gaugeName }, kind);
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
48 }
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
49
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
50 public DischargeTables(String riverName, String [] gaugeNames) {
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
51 this(riverName, gaugeNames, MASTER);
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
52 }
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
53
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
54 public DischargeTables(String riverName, String [] gaugeNames, int kind) {
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
55 this(riverName, Arrays.asList(gaugeNames), kind);
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
56 }
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
57
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
58 public DischargeTables(
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
59 String riverName,
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
60 List<String> gaugeNames,
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
61 int kind
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
62 ) {
154
03362976fa0f DischargeTables: Cache the scale, too. Otherwise two calls to getValues() with different arguments will result in the same output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 153
diff changeset
63 scale = Double.NaN;
328
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
64 this.kind = kind;
146
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 this.riverName = riverName;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 this.gaugeNames = gaugeNames;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 }
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68
328
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
69 public double [][] getFirstTable() {
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
70 return getFirstTable(DEFAULT_SCALE);
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
71 }
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
72
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
73 public double [][] getFirstTable(double scale) {
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
74 Map<String, double [][]> values = getValues(scale);
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
75 for (double [][] table: values.values()) {
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
76 return table;
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
77 }
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
78 return null;
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
79 }
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
80
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
81 public Map<String, double [][]> getValues() {
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
82 return getValues(DEFAULT_SCALE);
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
83 }
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
84
153
c97f9bc9b642 The out() operation of the WINFO artifact draws discharge tables for gauges specified by the user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 150
diff changeset
85 public Map<String, double [][]> getValues(double scale) {
154
03362976fa0f DischargeTables: Cache the scale, too. Otherwise two calls to getValues() with different arguments will result in the same output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 153
diff changeset
86 if (values == null || scale != this.scale) {
153
c97f9bc9b642 The out() operation of the WINFO artifact draws discharge tables for gauges specified by the user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 150
diff changeset
87 values = loadValues(scale);
154
03362976fa0f DischargeTables: Cache the scale, too. Otherwise two calls to getValues() with different arguments will result in the same output.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 153
diff changeset
88 this.scale = scale;
146
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89 }
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90 return values;
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91 }
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92
153
c97f9bc9b642 The out() operation of the WINFO artifact draws discharge tables for gauges specified by the user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 150
diff changeset
93 protected Map<String, double [][]> loadValues(double scale) {
150
c904d52cdfd0 Don't used interleaved x/y data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 146
diff changeset
94 Map<String, double [][]> values = new HashMap<String, double [][]>();
146
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95
311
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
96 Session session = SessionHolder.HOLDER.get();
146
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97
311
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
98 Query gaugeQuery = session.createQuery(
328
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
99 "from Gauge where name=:gauge and river.name=:river and kind=:kind");
311
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
100 gaugeQuery.setParameter("river", riverName);
328
07e642030172 Discharge tables: Added convenience constructors/methods to ease the access to the master discharge table of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 315
diff changeset
101 gaugeQuery.setInteger("kind", kind);
146
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102
311
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
103 for (String gaugeName: gaugeNames) {
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
104 gaugeQuery.setParameter("gauge", gaugeName);
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
105 List<Gauge> gauges = gaugeQuery.list();
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
106 if (gauges.isEmpty()) {
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
107 log.warn(
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
108 "no gauge '"+gaugeName+"' at river '"+riverName+"'");
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
109 continue;
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
110 }
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
111 Gauge gauge = gauges.get(0);
146
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112
311
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
113 List<DischargeTable> tables = gauge.getDischargeTables();
146
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
114
311
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
115 if (tables.isEmpty()) {
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
116 log.warn(
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
117 "no discharge table for gauge '" + gaugeName + "'");
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
118 continue;
146
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
119 }
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
120
311
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
121 // TODO: Filter by time interval
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
122 DischargeTable table = tables.get(0);
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
123
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
124 List<DischargeTableValue> dtvs =
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
125 table.getDischargeTableValues();
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
126
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
127 double [][] vs = new double[2][dtvs.size()];
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
128
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
129 int idx = 0;
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
130 for (DischargeTableValue dtv: dtvs) {
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
131 vs[0][idx] = dtv.getQ().doubleValue() * scale;
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
132 vs[1][idx] = dtv.getW().doubleValue() * scale;
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
133 ++idx;
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
134 }
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
135
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
136 values.put(gaugeName, vs);
146
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
137 }
311
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
138
ea3a438a7021 Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 154
diff changeset
139 return values;
146
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
140 }
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
141 }
e8dfe6ba2000 Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
142 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org