Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DischargeTables.java @ 333:67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
flys-artifacts/trunk@1731 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 19 Apr 2011 14:48:28 +0000 |
parents | 0b2358bc716d |
children | b7c8df643dc4 |
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; |
329
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
7 import java.util.Comparator; |
146
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 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
|
10 |
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.Session; |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 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
|
13 |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 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
|
15 |
315
94c176fdcb89
Removed the SessionHolder and adapted imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
311
diff
changeset
|
16 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
|
17 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
|
18 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
|
19 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
|
20 |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 public class DischargeTables |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 implements Serializable |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 { |
329
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
24 private static Logger log = Logger.getLogger(DischargeTables.class); |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
25 |
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
|
26 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
|
27 |
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
|
28 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
|
29 |
146
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 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
|
31 |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 protected String riverName; |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
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
|
34 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
|
35 |
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
|
36 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
|
37 |
150
c904d52cdfd0
Don't used interleaved x/y data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
38 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
|
39 |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 public DischargeTables() { |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 } |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 |
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
|
43 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
|
44 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
|
45 } |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 |
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
|
47 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
|
48 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
|
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 |
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 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
|
52 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
|
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 |
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 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
|
56 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
|
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 |
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 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
|
60 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
|
61 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
|
62 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
|
63 ) { |
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
|
64 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
|
65 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
|
66 this.riverName = riverName; |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 this.gaugeNames = gaugeNames; |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 } |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 |
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
|
70 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
|
71 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
|
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 |
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 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
|
75 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
|
76 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
|
77 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
|
78 } |
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 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
|
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 |
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 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
|
83 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
|
84 } |
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
|
85 |
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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 } |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 return values; |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 } |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 |
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
|
94 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
|
95 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
|
96 |
311
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
97 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
|
98 |
311
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
99 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
|
100 "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
|
101 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
|
102 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
|
103 |
311
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
104 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
|
105 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
|
106 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
|
107 if (gauges.isEmpty()) { |
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
108 log.warn( |
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
109 "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
|
110 continue; |
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
111 } |
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
112 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
|
113 |
311
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
114 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
|
115 |
311
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
116 if (tables.isEmpty()) { |
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
117 log.warn( |
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
118 "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
|
119 continue; |
146
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 } |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 |
311
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
122 // 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
|
123 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
|
124 |
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
125 List<DischargeTableValue> dtvs = |
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
126 table.getDischargeTableValues(); |
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
127 |
333
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
128 final double [][] vs = new double[2][dtvs.size()]; |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
129 |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
130 boolean qSorted = true; |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
131 |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
132 double lastQ = -Double.MAX_VALUE; |
311
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
133 |
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
134 int idx = 0; |
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
135 for (DischargeTableValue dtv: dtvs) { |
333
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
136 double q = dtv.getQ().doubleValue(); |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
137 vs[0][idx] = q * scale; |
311
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
138 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
|
139 ++idx; |
333
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
140 |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
141 if (qSorted && lastQ > q) { |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
142 qSorted = false; |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
143 } |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
144 lastQ = q; |
311
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
145 } |
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
146 |
333
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
147 if (!qSorted) { |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
148 log.debug("need to sort by q values"); |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
149 // TODO: Do this db level. |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
150 // XXX: This is so ugly :-( |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
151 Integer [] indices = new Integer[vs[0].length]; |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
152 for (int i = 0; i < indices.length; ++i) { |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
153 indices[i] = i; |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
154 } |
329
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
155 |
333
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
156 Arrays.sort(indices, new Comparator<Integer>() { |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
157 public int compare(Integer a, Integer b) { |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
158 double va = vs[1][a]; |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
159 double vb = vs[1][b]; |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
160 double d = va - vb; |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
161 if (d < 0.0) return -1; |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
162 if (d > 0.0) return +1; |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
163 return 0; |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
164 } |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
165 }); |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
166 |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
167 double [][] vs2 = new double[2][vs[0].length]; |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
168 for (int i = 0; i < indices.length; ++i) { |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
169 vs2[0][i] = vs[0][indices[i]]; |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
170 vs2[1][i] = vs[0][indices[i]]; |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
171 } |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
172 values.put(gaugeName, vs2); |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
173 } |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
174 else { |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
175 values.put(gaugeName, vs); |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
176 } |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
177 |
146
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
178 } |
311
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
179 |
ea3a438a7021
Backend access: Static methods are using the SessionHolder, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
180 return values; |
146
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
181 } |
329
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
182 |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
183 public static boolean getWForQ( |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
184 double [][] values, |
333
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
185 double q, |
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
186 double [] result |
329
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
187 ) { |
333
67b3f54188aa
Discharge tables: Sorting of q values was done wrong.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
329
diff
changeset
|
188 int index = Arrays.binarySearch(values[1], q); |
329
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
189 if (index >= 0) { |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
190 result[0] = values[1][index]; |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
191 return true; |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
192 } |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
193 |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
194 index = -index - 1; // insert position |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
195 |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
196 if (index == 0 || index+1 >= values.length) { |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
197 // do not extraploate |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
198 return false; |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
199 } |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
200 |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
201 double q1 = values[index ][0]; |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
202 double q2 = values[index+1][0]; |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
203 double w1 = values[index ][1]; |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
204 double w2 = values[index+1][1]; |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
205 |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
206 // w1 = m*q1 + b |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
207 // w2 = m*q2 + b |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
208 // w2 - w1 = m*(q2 - q1) |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
209 // m = (w2 - w1)/(q2 - q1) # q2 != q1 |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
210 // b = w1 - m*q1 |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
211 |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
212 if (q1 == q2) { |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
213 result[0] = 0.5*(w1 + w2); |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
214 } |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
215 else { |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
216 double m = (w2 - w1)/(q2 - q1); |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
217 double b = w1 - m*q1; |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
218 result[0] = q*m + b; |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
219 } |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
220 |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
221 return true; |
0b2358bc716d
Discharge table: Added static method getWForQ() to interpolate a w value for a given q value based on a given discharge table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
328
diff
changeset
|
222 } |
146
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
223 } |
e8dfe6ba2000
Fetch w/q values of discharge tables for given gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
224 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |