Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationCalculation.java @ 9069:1ffd38826175
access uinfo.vegetationzones+inundation_duration
author | gernotbelger |
---|---|
date | Tue, 15 May 2018 12:00:26 +0200 |
parents | fb9430250899 |
children | 611a523fc42f |
rev | line source |
---|---|
8996 | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
2 * Software engineering by |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
3 * Björnsen Beratende Ingenieure GmbH |
8996 | 4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.uinfo.inundationduration; | |
11 | |
12 import java.util.ArrayList; | |
13 import java.util.Collection; | |
14 | |
15 import org.apache.commons.lang.math.DoubleRange; | |
16 import org.dive4elements.artifacts.CallContext; | |
17 import org.dive4elements.river.artifacts.access.RiverAccess; | |
18 import org.dive4elements.river.artifacts.common.ResultRow; | |
19 import org.dive4elements.river.artifacts.model.Calculation; | |
20 import org.dive4elements.river.artifacts.model.CalculationResult; | |
21 import org.dive4elements.river.artifacts.resources.Resources; | |
22 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; | |
23 import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils; | |
24 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | |
25 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; | |
26 import org.dive4elements.river.model.River; | |
27 | |
28 /** | |
29 * @author Domenico Nardi Tironi | |
30 * | |
31 */ | |
32 final class InundationDurationCalculation { | |
33 | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
34 private final CallContext context; |
8996 | 35 |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
36 public InundationDurationCalculation(final CallContext context) { |
8996 | 37 this.context = context; |
38 } | |
39 | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
40 public CalculationResult calculate(final UINFOArtifact uinfo) { |
8996 | 41 final Calculation problems = new Calculation(); |
42 | |
43 final String calcModeLabel = Resources.getMsg(this.context.getMeta(), uinfo.getCalculationMode().name()); | |
44 final String user = CalculationUtils.findArtifactUser(this.context, uinfo); | |
45 | |
46 final RiverAccess access = new RiverAccess(uinfo); | |
47 final River river = access.getRiver(); | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
48 final DoubleRange calcRange = null; |
8996 | 49 final RiverInfo riverInfo = new RiverInfo(river); |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
50 |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
51 final InundationDurationAccess indurax = new InundationDurationAccess(uinfo); |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
52 final int[] totalEpoch = indurax.getTotalEpoch(); |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
53 final Integer year = indurax.getYear(); // null bei year -> Integer.. evtl ungünstig.. evtl. anders lösen |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
54 final DoubleRange range = indurax.getRange(); |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
55 final Double sedimentHeight = indurax.getSedimentHeight(); |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
56 |
8996 | 57 final InundationDurationCalculationResults results = new InundationDurationCalculationResults(calcModeLabel, user, riverInfo, calcRange); |
58 | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
59 final Collection<ResultRow> rows = new ArrayList<>(); |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
60 |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
61 final ResultRow row1 = ResultRow.create(). // |
8996 | 62 putValue(SInfoResultType.discharge, 100). // |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
63 putValue(SInfoResultType.waterlevel, 2). // |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
64 putValue(SInfoResultType.gaugeLabel, "Torgau"); |
8996 | 65 |
66 rows.add(row1); | |
67 | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
68 final ResultRow row2 = ResultRow.create(). // |
8996 | 69 putValue(SInfoResultType.discharge, 200). // |
70 putValue(SInfoResultType.waterlevel, 3). // | |
71 putValue(SInfoResultType.gaugeLabel, "Zollenspieker"); | |
72 | |
73 rows.add(row2); | |
74 | |
75 final InundationDurationCalculationResult result = new InundationDurationCalculationResult("Ergebnis 1", null, rows); | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
76 |
8996 | 77 results.addResult(result, problems); |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
78 |
8996 | 79 return new CalculationResult(results, problems); |
80 } | |
81 } |