Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationCalculation.java @ 9070:611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
author | gernotbelger |
---|---|
date | Tue, 15 May 2018 18:04:36 +0200 |
parents | 1ffd38826175 |
children | 431f1c269be5 |
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; | |
9070
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
14 import java.util.List; |
8996 | 15 |
16 import org.apache.commons.lang.math.DoubleRange; | |
17 import org.dive4elements.artifacts.CallContext; | |
18 import org.dive4elements.river.artifacts.access.RiverAccess; | |
19 import org.dive4elements.river.artifacts.common.ResultRow; | |
20 import org.dive4elements.river.artifacts.model.Calculation; | |
21 import org.dive4elements.river.artifacts.model.CalculationResult; | |
22 import org.dive4elements.river.artifacts.resources.Resources; | |
23 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; | |
24 import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils; | |
25 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | |
26 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; | |
9070
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
27 import org.dive4elements.river.artifacts.uinfo.vegetationzones.VegetationZoneAccessHelper; |
8996 | 28 import org.dive4elements.river.model.River; |
29 | |
30 /** | |
31 * @author Domenico Nardi Tironi | |
32 * | |
33 */ | |
34 final class InundationDurationCalculation { | |
35 | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
36 private final CallContext context; |
8996 | 37 |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
38 public InundationDurationCalculation(final CallContext context) { |
8996 | 39 this.context = context; |
40 } | |
41 | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
42 public CalculationResult calculate(final UINFOArtifact uinfo) { |
8996 | 43 final Calculation problems = new Calculation(); |
44 | |
45 final String calcModeLabel = Resources.getMsg(this.context.getMeta(), uinfo.getCalculationMode().name()); | |
46 final String user = CalculationUtils.findArtifactUser(this.context, uinfo); | |
47 | |
48 final RiverAccess access = new RiverAccess(uinfo); | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
49 |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
50 final InundationDurationAccess indurax = new InundationDurationAccess(uinfo); |
9070
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
51 final River river = indurax.getRiver(); |
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
52 final RiverInfo riverInfo = new RiverInfo(river); |
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
53 final DoubleRange calcRange = indurax.getRange(); |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
54 final int[] totalEpoch = indurax.getTotalEpoch(); |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
55 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
|
56 final DoubleRange range = indurax.getRange(); |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
57 final Double sedimentHeight = indurax.getSedimentHeight(); |
9070
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
58 final String zonesRaw = indurax.getVegZones(); |
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
59 final List<VegetationZoneAccessHelper> zones = VegetationZoneAccessHelper.parse(zonesRaw); |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
60 |
8996 | 61 final InundationDurationCalculationResults results = new InundationDurationCalculationResults(calcModeLabel, user, riverInfo, calcRange); |
62 | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
63 final Collection<ResultRow> rows = new ArrayList<>(); |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
64 |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
65 final ResultRow row1 = ResultRow.create(). // |
8996 | 66 putValue(SInfoResultType.discharge, 100). // |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
67 putValue(SInfoResultType.waterlevel, 2). // |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
68 putValue(SInfoResultType.gaugeLabel, "Torgau"); |
8996 | 69 |
70 rows.add(row1); | |
71 | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
72 final ResultRow row2 = ResultRow.create(). // |
8996 | 73 putValue(SInfoResultType.discharge, 200). // |
74 putValue(SInfoResultType.waterlevel, 3). // | |
75 putValue(SInfoResultType.gaugeLabel, "Zollenspieker"); | |
76 | |
77 rows.add(row2); | |
78 | |
79 final InundationDurationCalculationResult result = new InundationDurationCalculationResult("Ergebnis 1", null, rows); | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
80 |
8996 | 81 results.addResult(result, problems); |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
82 |
8996 | 83 return new CalculationResult(results, problems); |
84 } | |
85 } |