Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationCalculation.java @ 9559:ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
author | gernotbelger |
---|---|
date | Wed, 24 Oct 2018 18:40:38 +0200 |
parents | 709a73badd48 |
children |
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 | |
9537
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
12 import java.io.IOException; |
8996 | 13 |
14 import org.dive4elements.artifacts.CallContext; | |
15 import org.dive4elements.river.artifacts.model.Calculation; | |
16 import org.dive4elements.river.artifacts.model.CalculationResult; | |
9537
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
17 import org.dive4elements.river.artifacts.sinfo.tkhstate.TsvHelper.TsvReaderException; |
8996 | 18 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; |
9481 | 19 import org.dive4elements.river.artifacts.uinfo.inundationduration.InundationDurationCalculationResult.WmsLayer; |
9559
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
20 import org.dive4elements.river.artifacts.uinfo.inundationduration.UedauernConfiguration.YearType; |
8996 | 21 |
22 /** | |
23 * @author Domenico Nardi Tironi | |
24 * | |
25 */ | |
26 final class InundationDurationCalculation { | |
27 | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
28 private final CallContext context; |
8996 | 29 |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
30 public InundationDurationCalculation(final CallContext context) { |
8996 | 31 this.context = context; |
32 } | |
33 | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
34 public CalculationResult calculate(final UINFOArtifact uinfo) { |
8996 | 35 final Calculation problems = new Calculation(); |
36 | |
9537
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
37 try { |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
38 final InundationDurationAccess indurax = new InundationDurationAccess(uinfo); |
8996 | 39 |
9558
709a73badd48
VegetationZone removed from Uinfo-Ü'Dauern Workflow
gernotbelger
parents:
9537
diff
changeset
|
40 // VegetationZones have been removed - these two lines should be deleted |
709a73badd48
VegetationZone removed from Uinfo-Ü'Dauern Workflow
gernotbelger
parents:
9537
diff
changeset
|
41 // final String zonesRaw = indurax.getVegZones(); |
709a73badd48
VegetationZone removed from Uinfo-Ü'Dauern Workflow
gernotbelger
parents:
9537
diff
changeset
|
42 // final List<VegetationZoneServerClientXChange> zones = VegetationZoneServerClientXChange.parse(zonesRaw); |
9537
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
43 // FIXME: instead find out a-uuid of referenced vegetations |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
44 // FIXME: |
9559
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
45 // final String vegZoneId = "unknown"; |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
8996
diff
changeset
|
46 |
9537
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
47 final boolean isUseScenario = indurax.getIsUseScenario(); |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
48 |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
49 final InundationDurationCalculationResult result = new InundationDurationCalculationResult(); |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
50 |
9559
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
51 final String selectedItem = indurax.getSelectedLabel(); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
52 final YearType type = indurax.isUseYear() ? YearType.jahre : YearType.mittel; |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
53 final UedauernConfiguration config = UedauernConfiguration.getInstance(indurax.getRiverName(), type); |
9537
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
54 |
9559
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
55 addLayer(indurax, "uinfo.export.url.inundationduration.inundationduration", selectedItem, config.getDefaultWmsConfig(selectedItem), result, true); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
56 addLayer(indurax, "uinfo.export.url.inundationduration.vegetation", selectedItem, config.getVegWmsConfig(selectedItem), result, false); |
9537
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
57 |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
58 if (isUseScenario) { |
9559
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
59 |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
60 final UedauernConfiguration configSzenario = UedauernConfiguration.getInstance(indurax.getRiverName(), YearType.szenario); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
61 |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
62 final String selectedScenario = indurax.getSelectedSzenario(); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
63 |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
64 addLayer(indurax, "uinfo.export.url.inundationduration.scenario", selectedScenario, configSzenario.getDefaultWmsConfig(selectedScenario), |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
65 result, true); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
66 |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
67 addLayer(indurax, "uinfo.export.url.inundationduration.vegetation_scenario", selectedScenario, configSzenario.getVegWmsConfig(selectedScenario), |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
68 result, false); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
69 |
9537
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
70 // // TODO: add vegetationzone-values as styles to layer |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
71 // final WmsLayer scenarioVegetationLayer = indurax.createScenarioWMSLayer(this.context.getMeta(), |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
72 // "uinfo.export.url.inundationduration.vegetation_scenario"); |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
73 // result.addLayer(scenarioVegetationLayer); |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
74 } |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
75 |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
76 return new CalculationResult(result, problems); |
9190 | 77 } |
9537
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
78 catch (IOException | TsvReaderException e) { |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
79 e.printStackTrace(); |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
80 problems.addProblem("Invalid server configuration: " + e.getLocalizedMessage()); |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
81 return new CalculationResult(null, problems); |
bf6b63208f34
Work on uinfo inundation duration calculation.
gernotbelger
parents:
9481
diff
changeset
|
82 } |
8996 | 83 } |
9559
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
84 |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
85 private void addLayer(final InundationDurationAccess indurax, final String label, final String selectedItem, final UedauernConfiguration.WmsConfig config, |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
86 final InundationDurationCalculationResult result, final boolean show) throws IOException, TsvReaderException { |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
87 if (config != null) { |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
88 final WmsLayer layer = indurax.createWMSLayer(this.context, label, selectedItem, config, show); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
89 if (layer != null) |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
90 result.addLayer(layer); |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
91 } |
ba0561906f81
Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
gernotbelger
parents:
9558
diff
changeset
|
92 } |
8996 | 93 } |