Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java @ 9069:1ffd38826175
access uinfo.vegetationzones+inundation_duration
author | gernotbelger |
---|---|
date | Tue, 15 May 2018 12:00:26 +0200 |
parents | a5cf8d7bff3c |
children | 611a523fc42f |
rev | line source |
---|---|
8996 | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
9006 | 2 * Software engineering by |
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.vegetationzones; | |
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.util.CalculationUtils; | |
23 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | |
24 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; | |
9006 | 25 import org.dive4elements.river.artifacts.uinfo.commons.UInfoResultType; |
8996 | 26 import org.dive4elements.river.model.River; |
27 | |
28 /** | |
29 * @author Domenico Nardi Tironi | |
30 * | |
31 */ | |
32 final class VegetationZonesCalculation { | |
33 | |
9006 | 34 private final CallContext context; |
8996 | 35 |
9006 | 36 public VegetationZonesCalculation(final CallContext context) { |
8996 | 37 this.context = context; |
38 } | |
39 | |
9006 | 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(); | |
9006 | 48 final DoubleRange calcRange = null; |
8996 | 49 final RiverInfo riverInfo = new RiverInfo(river); |
9006 | 50 |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
51 final VegetationzonesAccess vAccess = new VegetationzonesAccess(uinfo); |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
52 final ArrayList<String[]> zones = vAccess.getVegZones(); |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
53 |
8996 | 54 final VegetationZonesCalculationResults results = new VegetationZonesCalculationResults(calcModeLabel, user, riverInfo, calcRange); |
55 | |
9006 | 56 final Collection<ResultRow> rows = new ArrayList<>(); |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
57 for (final String[] zone : zones) { |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
58 final ResultRow row2 = ResultRow.create().// |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
59 putValue(UInfoResultType.vegname, zone[0]).// |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
60 putValue(UInfoResultType.vegdauervon, zone[1]).// |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
61 putValue(UInfoResultType.vegdauerbis, zone[2]); |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
62 rows.add(row2); |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
63 } |
8996 | 64 |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
65 final VegetationZonesCalculationResult result = new VegetationZonesCalculationResult("Ergebnis 1", rows); |
9006 | 66 |
8996 | 67 results.addResult(result, problems); |
9006 | 68 |
8996 | 69 return new CalculationResult(results, problems); |
70 } | |
71 } |