Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/ExtremeCalculation.java @ 3785:a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
file:///home/clients/bsh/bsh-generischer-viewer/Material/SVN/flys-artifacts/trunk
........
r5501 | felix | 2012-09-18 11:49:45 +0200 (Di, 18 Sep 2012) | 1 line
fix issue865 - missing showarea theme prop.
........
r5502 | clins | 2012-09-18 12:18:30 +0200 (Di, 18 Sep 2012) | 1 line
Add robustness checks to prevent NPEs
........
r5504 | felix | 2012-09-18 14:03:15 +0200 (Di, 18 Sep 2012) | 1 line
i18n for area label (fix issue487).
........
r5505 | clins | 2012-09-18 16:19:59 +0200 (Di, 18 Sep 2012) | 1 line
Update themes to show point descriptions
........
r5506 | rrenkert | 2012-09-18 17:00:30 +0200 (Di, 18 Sep 2012) | 3 lines
Removed incorrect characteristic diameter.
........
r5507 | rrenkert | 2012-09-18 17:03:20 +0200 (Di, 18 Sep 2012) | 3 lines
Fixed some stupid bugs in bed quality data factory and calculation.
........
r5508 | teichmann | 2012-09-18 17:45:49 +0200 (Di, 18 Sep 2012) | 1 line
The usual whitespace and import cleanups.
........
r5511 | teichmann | 2012-09-18 18:24:51 +0200 (Di, 18 Sep 2012) | 1 line
Use generics aware Collections.emptyList().
........
r5512 | teichmann | 2012-09-18 20:36:52 +0200 (Di, 18 Sep 2012) | 1 line
Some more little steps towards "Auslagerung extremer Wasserspiegellagen".
........
r5513 | clins | 2012-09-18 23:38:19 +0200 (Di, 18 Sep 2012) | 1 line
A and B facets of fix analyis are now deactivated by default
........
r5516 | bricks | 2012-09-19 10:45:51 +0200 (Mi, 19 Sep 2012) | 2 lines
Add the gauge station to the GaugeOverviewInfoService xml response
........
r5517 | rrenkert | 2012-09-19 10:50:23 +0200 (Mi, 19 Sep 2012) | 3 lines
Added CSV export to bed quality calculation.
........
r5518 | bricks | 2012-09-19 11:04:04 +0200 (Mi, 19 Sep 2012) | 2 lines
Fix date in changelog entry
........
r5519 | teichmann | 2012-09-19 11:17:14 +0200 (Mi, 19 Sep 2012) | 1 line
Removed trailing whitespace.
........
flys-artifacts/tags/2.9.1@5531 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 19 Sep 2012 14:58:31 +0000 |
parents | d52c4ca93ffb |
children | 363445873737 |
comparison
equal
deleted
inserted
replaced
3784:9f9d5ada96ca | 3785:a5f65e8983be |
---|---|
1 package de.intevation.flys.artifacts.model.extreme; | 1 package de.intevation.flys.artifacts.model.extreme; |
2 | 2 |
3 import de.intevation.flys.artifacts.access.ExtremeAccess; | 3 import de.intevation.flys.artifacts.access.ExtremeAccess; |
4 | 4 |
5 import de.intevation.flys.artifacts.math.fitting.Function; | |
6 import de.intevation.flys.artifacts.math.fitting.FunctionFactory; | |
7 | |
5 import de.intevation.flys.artifacts.model.Calculation; | 8 import de.intevation.flys.artifacts.model.Calculation; |
6 import de.intevation.flys.artifacts.model.CalculationResult; | 9 import de.intevation.flys.artifacts.model.CalculationResult; |
10 import de.intevation.flys.artifacts.model.RangeWithValues; | |
11 import de.intevation.flys.artifacts.model.RiverFactory; | |
12 import de.intevation.flys.artifacts.model.WstValueTable; | |
13 import de.intevation.flys.artifacts.model.WstValueTableFactory; | |
14 | |
15 import de.intevation.flys.model.River; | |
16 | |
17 import de.intevation.flys.utils.DoubleUtil; | |
18 | |
19 import java.util.List; | |
7 | 20 |
8 public class ExtremeCalculation | 21 public class ExtremeCalculation |
9 extends Calculation | 22 extends Calculation |
10 { | 23 { |
24 protected String river; | |
25 protected String function; | |
26 protected double from; | |
27 protected double to; | |
28 protected double step; | |
29 protected double percent; | |
30 protected List<RangeWithValues> ranges; | |
31 | |
11 public ExtremeCalculation() { | 32 public ExtremeCalculation() { |
12 } | 33 } |
13 | 34 |
14 public ExtremeCalculation(ExtremeAccess access) { | 35 public ExtremeCalculation(ExtremeAccess access) { |
15 // TODO: Implement me! | 36 String river = access.getRiver(); |
37 String function = access.getFunction(); | |
38 Double from = access.getFrom(); | |
39 Double to = access.getTo(); | |
40 Double step = access.getStep(); | |
41 Double percent = access.getPercent(); | |
42 List<RangeWithValues> ranges = access.getRanges(); | |
43 | |
44 if (river == null) { | |
45 // TODO: i18n | |
46 addProblem("extreme.no.river"); | |
47 } | |
48 | |
49 if (function == null) { | |
50 // TODO: i18n | |
51 addProblem("extreme.no.function"); | |
52 } | |
53 | |
54 if (from == null) { | |
55 // TODO: i18n | |
56 addProblem("extreme.no.from"); | |
57 } | |
58 | |
59 if (to == null) { | |
60 // TODO: i18n | |
61 addProblem("extreme.no.to"); | |
62 } | |
63 | |
64 if (step == null) { | |
65 // TODO: i18n | |
66 addProblem("extreme.no.step"); | |
67 } | |
68 | |
69 if (percent == null) { | |
70 // TODO: i18n | |
71 addProblem("extreme.no.percent"); | |
72 } | |
73 | |
74 if (ranges == null) { | |
75 // TODO: i18n | |
76 addProblem("extreme.no.ranges"); | |
77 } | |
78 | |
79 if (!hasProblems()) { | |
80 this.river = river; | |
81 this.function = function; | |
82 this.from = Math.min(from, to); | |
83 this.to = Math.max(from, to); | |
84 this.step = Math.max(0.001d, Math.abs(step)/1000d); | |
85 this.percent = Math.max(0d, Math.min(100d, percent)); | |
86 this.ranges = ranges; | |
87 } | |
16 } | 88 } |
17 | 89 |
18 public CalculationResult calculate() { | 90 public CalculationResult calculate() { |
19 if (hasProblems()) { | 91 |
20 return new CalculationResult(this); | 92 WstValueTable wst = null; |
93 | |
94 River river = RiverFactory.getRiver(this.river); | |
95 if (river == null) { | |
96 // TODO: i18n | |
97 addProblem("extreme.no.such.river", this.river); | |
21 } | 98 } |
22 // TODO: Implement me! | 99 else { |
100 wst = WstValueTableFactory.getTable(river); | |
101 if (wst == null) { | |
102 // TODO: i18n | |
103 addProblem("extreme.no.wst.table"); | |
104 } | |
105 } | |
106 | |
107 Function function = | |
108 FunctionFactory.getInstance().getFunction(this.function); | |
109 if (function == null) { | |
110 // TODO: i18n | |
111 addProblem("extreme.no.such.function", this.function); | |
112 } | |
113 | |
114 return hasProblems() | |
115 ? new CalculationResult(this) | |
116 : innerCalculate(wst, function); | |
117 } | |
118 | |
119 protected CalculationResult innerCalculate( | |
120 WstValueTable wst, | |
121 Function function | |
122 ) { | |
123 RangeWithValues range = null; | |
124 | |
125 KMs: for (double km = from; km <= to; km += step) { | |
126 double currentKm = DoubleUtil.round(km); | |
127 | |
128 if (range == null || !range.inside(currentKm)) { | |
129 for (RangeWithValues r: ranges) { | |
130 if (r.inside(currentKm)) { | |
131 range = r; | |
132 break; | |
133 } | |
134 } | |
135 // TODO: i18n | |
136 addProblem(currentKm, "extreme.no.range"); | |
137 continue KMs; | |
138 } | |
139 | |
140 double [][] wqs = wst.interpolateTabulated(currentKm); | |
141 if (wqs == null) { | |
142 // TODO: i18n | |
143 addProblem(currentKm, "extreme.no.raw.data"); | |
144 continue; | |
145 } | |
146 | |
147 // XXX: This should not be necessary for model data. | |
148 if (!DoubleUtil.isValid(wqs)) { | |
149 // TODO: i18n | |
150 addProblem(currentKm, "extreme.invalid.data"); | |
151 continue; | |
152 } | |
153 // TODO: Implement extraction of points for curve fitting. | |
154 // TODO: Implement curve fitting. | |
155 // TODO: Implement generating Curve object per km. | |
156 } | |
157 | |
23 ExtremeResult result = new ExtremeResult(); | 158 ExtremeResult result = new ExtremeResult(); |
24 | |
25 return new CalculationResult(result, this); | 159 return new CalculationResult(result, this); |
26 } | 160 } |
27 } | 161 } |
28 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : | 162 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |