Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation6.java @ 2249:997df76c6f58
Create title, subtitle and axes labels for charts from type historical discharge curve.
flys-artifacts/trunk@3898 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 03 Feb 2012 13:42:48 +0000 |
parents | 7335c526befd |
children | 40608c82e9cb |
rev | line source |
---|---|
2215
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
3 import java.util.ArrayList; |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
4 import java.util.Date; |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
5 import java.util.List; |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
6 |
2215
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import org.apache.log4j.Logger; |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
9 import de.intevation.flys.model.DischargeTable; |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
10 import de.intevation.flys.model.Gauge; |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
11 import de.intevation.flys.model.TimeInterval; |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
12 |
2215
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 /** |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 */ |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 public class Calculation6 extends Calculation { |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 private static final Logger logger = Logger.getLogger(Calculation6.class); |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
21 private int mode; |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
22 private long[] timerange; |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
23 private double[] values; |
2215
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
25 |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
26 public static final int MODE_W = 0; |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
27 public static final int MODE_Q = 1; |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
28 |
2230
59af81364eb1
Improved the 'historical discharge' calculation: implemented findValueForW().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2228
diff
changeset
|
29 public static final double SCALE = 100d; |
59af81364eb1
Improved the 'historical discharge' calculation: implemented findValueForW().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2228
diff
changeset
|
30 |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
31 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
32 public Calculation6(int mode, long[] timerange, double[] values) { |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
33 this.mode = mode; |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
34 this.timerange = timerange; |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
35 this.values = values; |
2215
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 } |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
39 public CalculationResult calculate(Gauge gauge) { |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
40 if (!checkParameters() || gauge == null) { |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
41 logger.warn("Parameters not valid for calculation."); |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
42 |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
43 return null; |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
44 } |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
45 |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
46 if (logger.isDebugEnabled()) { |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
47 debug(); |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
48 } |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
49 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
50 List<DischargeTable> dts = fetchDischargeTables(gauge); |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
51 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
52 logger.debug("Take " + dts.size() + " into account."); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
53 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
54 WQTimerange[] wqt = prepareCalculationData(dts); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
55 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
56 return new CalculationResult(wqt, this); |
2215
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 } |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
58 |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
59 |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
60 protected boolean checkParameters() { |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
61 if (!(mode == MODE_W || mode == MODE_Q)) { |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
62 logger.warn("Invalid mode '" + mode + "' for calculation."); |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
63 return false; |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
64 } |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
65 |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
66 if (timerange == null || timerange.length < 2) { |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
67 logger.warn("Invalid timerange for calculation."); |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
68 return false; |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
69 } |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
70 |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
71 if (values == null || values.length == 0) { |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
72 logger.warn("No values for W or Q specified."); |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
73 return false; |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
74 } |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
75 |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
76 return true; |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
77 } |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
78 |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
79 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
80 protected List<DischargeTable> fetchDischargeTables(Gauge gauge) { |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
81 List<DischargeTable> relevant = new ArrayList<DischargeTable>(); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
82 List<DischargeTable> all = gauge.getDischargeTables(); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
83 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
84 for (DischargeTable dt: all) { |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
85 if (isDischargeTableRelevant(dt)) { |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
86 relevant.add(dt); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
87 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
88 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
89 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
90 return relevant; |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
91 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
92 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
93 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
94 protected boolean isDischargeTableRelevant(DischargeTable dt) { |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
95 TimeInterval ti = dt.getTimeInterval(); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
96 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
97 Date start = ti.getStartTime(); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
98 long startTime = start.getTime(); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
99 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
100 if (startTime >= timerange[0] && startTime <= timerange[1]) { |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
101 return true; |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
102 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
103 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
104 Date stop = ti.getStopTime(); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
105 long stopTime = stop != null ? stop.getTime() : -1l; |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
106 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
107 if (stopTime >= timerange[0] && stopTime <= timerange[1]) { |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
108 return true; |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
109 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
110 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
111 logger.debug("DischargeTable not in range: " + start + " -> " + stop); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
112 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
113 return false; |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
114 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
115 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
116 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
117 protected WQTimerange[] prepareCalculationData(List<DischargeTable> dts) { |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
118 List<WQTimerange> wqts = new ArrayList<WQTimerange>(values.length); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
119 |
2230
59af81364eb1
Improved the 'historical discharge' calculation: implemented findValueForW().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2228
diff
changeset
|
120 boolean debug = logger.isDebugEnabled(); |
59af81364eb1
Improved the 'historical discharge' calculation: implemented findValueForW().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2228
diff
changeset
|
121 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
122 for (double value: values) { |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
123 logger.debug("Prepare data for value: " + value); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
124 |
2244
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
125 String name = mode == MODE_W ? "W=" + value : "Q=" + value; |
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
126 WQTimerange wqt = null; |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
127 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
128 for (DischargeTable dt: dts) { |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
129 TimeInterval ti = dt.getTimeInterval(); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
130 |
2244
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
131 Date start = ti.getStartTime(); |
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
132 Date end = ti.getStopTime(); |
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
133 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
134 Timerange t = new Timerange(ti.getStartTime(),ti.getStopTime()); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
135 double w; |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
136 double q; |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
137 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
138 if (mode == MODE_W) { |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
139 w = value; |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
140 q = findValueForW(dt, w); |
2244
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
141 |
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
142 if (Double.isNaN(q)) { |
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
143 logger.warn("Cannot find Q for W: " + w); |
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
144 addProblem("cannot.find.hist.q.for.w", w, start, end); |
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
145 continue; |
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
146 } |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
147 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
148 else { |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
149 q = value; |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
150 w = findValueForQ(dt, q); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
151 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
152 |
2230
59af81364eb1
Improved the 'historical discharge' calculation: implemented findValueForW().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2228
diff
changeset
|
153 if (debug) { |
59af81364eb1
Improved the 'historical discharge' calculation: implemented findValueForW().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2228
diff
changeset
|
154 logger.debug("Q=" + q + " | W=" + w); |
59af81364eb1
Improved the 'historical discharge' calculation: implemented findValueForW().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2228
diff
changeset
|
155 } |
59af81364eb1
Improved the 'historical discharge' calculation: implemented findValueForW().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2228
diff
changeset
|
156 |
2244
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
157 if (wqt == null) { |
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
158 wqt = new WQTimerange(name); |
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
159 } |
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
160 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
161 wqt.add(w, q, t); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
162 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
163 |
2244
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
164 if (wqt != null) { |
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
165 wqts.add(wqt); |
7335c526befd
Added an error report for historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2230
diff
changeset
|
166 } |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
167 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
168 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
169 return (WQTimerange[]) wqts.toArray(new WQTimerange[wqts.size()]); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
170 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
171 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
172 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
173 protected double findValueForW(DischargeTable dt, double w) { |
2230
59af81364eb1
Improved the 'historical discharge' calculation: implemented findValueForW().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2228
diff
changeset
|
174 double[][] vs = DischargeTables.loadDischargeTableValues(dt,SCALE,true); |
59af81364eb1
Improved the 'historical discharge' calculation: implemented findValueForW().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2228
diff
changeset
|
175 return DischargeTables.getQForW(vs, w); |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
176 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
177 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
178 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
179 protected double findValueForQ(DischargeTable dt, double q) { |
2230
59af81364eb1
Improved the 'historical discharge' calculation: implemented findValueForW().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2228
diff
changeset
|
180 double[][] vs = DischargeTables.loadDischargeTableValues(dt,SCALE,true); |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
181 logger.warn("TODO: IMPLEMENT ME!"); |
2230
59af81364eb1
Improved the 'historical discharge' calculation: implemented findValueForW().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2228
diff
changeset
|
182 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
183 return 10; |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
184 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
185 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
186 |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
187 /** |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
188 * Writes the parameters used for this calculation to logger. |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
189 */ |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
190 public void debug() { |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
191 StringBuilder sb = new StringBuilder(); |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
192 for (double value: values) { |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
193 sb.append(String.valueOf(value) + " "); |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
194 } |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
195 |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
196 logger.debug("========== Calculation6 =========="); |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
197 logger.debug(" Mode: " + mode); |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
198 logger.debug(" Timerange: " + timerange[0] + " - " + timerange[1]); |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
199 logger.debug(" Input values: " + sb.toString()); |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
200 logger.debug("=================================="); |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
201 } |
2215
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
202 } |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
203 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |