annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/FlowVelocityCalculation.java @ 7261:a56fe3bc6700

Refactoring: Let RiverAccess.getRiver return an River. Renamed getRiver in getRiverName. Update Callers.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 08 Oct 2013 14:50:58 +0200
parents af13ceeba52a
children be0e3b93144c
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5323
diff changeset
9 package org.dive4elements.river.artifacts.model;
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5323
diff changeset
11 import org.dive4elements.artifacts.Artifact;
3777
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3317
diff changeset
12
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5323
diff changeset
13 import org.dive4elements.river.artifacts.access.FlowVelocityAccess;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5323
diff changeset
14
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5323
diff changeset
15 import org.dive4elements.river.model.DischargeZone;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5323
diff changeset
16 import org.dive4elements.river.model.FlowVelocityModel;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5323
diff changeset
17 import org.dive4elements.river.model.FlowVelocityModelValue;
5323
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4623
diff changeset
18
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4623
diff changeset
19 import java.util.ArrayList;
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4623
diff changeset
20 import java.util.Collections;
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4623
diff changeset
21 import java.util.List;
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22
3777
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3317
diff changeset
23 import org.apache.log4j.Logger;
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
4483
cc6323401643 Cosmetics: Removed some WSP, obsolete imports. Documentation added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
26 /** Calculate flow velocity. */
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 public class FlowVelocityCalculation extends Calculation {
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
4483
cc6323401643 Cosmetics: Removed some WSP, obsolete imports. Documentation added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
29 /** Own logger. */
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 private static final Logger logger =
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 Logger.getLogger(FlowVelocityCalculation.class);
3232
cdbc457e23e2 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3230
diff changeset
32
cdbc457e23e2 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3230
diff changeset
33
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2702
diff changeset
34 public CalculationResult calculate(FlowVelocityAccess access) {
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 logger.info("FlowVelocityCalculation.calculate");
3232
cdbc457e23e2 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3230
diff changeset
36
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2702
diff changeset
37 int[] mainIds = access.getMainChannels();
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2702
diff changeset
38 int[] totalIds = access.getTotalChannels();
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 if (logger.isDebugEnabled()) {
3258
3c006a53e551 Replaced tabs with four spaces each.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3232
diff changeset
41 Artifact a = access.getArtifact();
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2702
diff changeset
42 logger.debug("Artifact '" + a.identifier() + "' contains:");
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 if (mainIds != null) {
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 logger.debug(" " + mainIds.length + " main channel ids");
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 if (totalIds != null) {
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 logger.debug(" " + totalIds.length + " total channel ids");
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 List<DischargeZone> zones = getDischargeZones(mainIds, totalIds);
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2702
diff changeset
53 List<FlowVelocityModel> models = getFlowVelocityModels(access, zones);
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2702
diff changeset
55 return buildCalculationResult(access, models);
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 protected List<DischargeZone> getDischargeZones(
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 int[] mainIds,
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 int[] totalIds
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 ) {
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 List<DischargeZone> zones = new ArrayList<DischargeZone>();
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 if (mainIds != null) {
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 for (int id: mainIds) {
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 DischargeZone zone = DischargeZone.getDischargeZoneById(id);
4623
89322548b044 Set the discharge zone type to be able to generate the appropriate facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 4483
diff changeset
68 zone.putType("main");
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 if (zone != null) {
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 zones.add(zone);
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 if (totalIds != null) {
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 for (int id: totalIds) {
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 DischargeZone zone = DischargeZone.getDischargeZoneById(id);
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 if (zone != null) {
4623
89322548b044 Set the discharge zone type to be able to generate the appropriate facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 4483
diff changeset
80 int ndx = zones.indexOf(zone);
89322548b044 Set the discharge zone type to be able to generate the appropriate facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 4483
diff changeset
81 if (zones.contains(zone) &&
89322548b044 Set the discharge zone type to be able to generate the appropriate facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 4483
diff changeset
82 zones.get(ndx).fetchType().equals("main")) {
89322548b044 Set the discharge zone type to be able to generate the appropriate facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 4483
diff changeset
83 zone.putType("main_total");
89322548b044 Set the discharge zone type to be able to generate the appropriate facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 4483
diff changeset
84 }
89322548b044 Set the discharge zone type to be able to generate the appropriate facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 4483
diff changeset
85 else {
89322548b044 Set the discharge zone type to be able to generate the appropriate facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 4483
diff changeset
86 zone.putType("total");
89322548b044 Set the discharge zone type to be able to generate the appropriate facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 4483
diff changeset
87 zones.add(zone);
89322548b044 Set the discharge zone type to be able to generate the appropriate facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 4483
diff changeset
88 }
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 return zones;
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 protected List<FlowVelocityModel> getFlowVelocityModels(
3258
3c006a53e551 Replaced tabs with four spaces each.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3232
diff changeset
98 FlowVelocityAccess access,
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 List<DischargeZone> zones
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 ) {
7261
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
101 String riverName = access.getRiverName();
3777
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3317
diff changeset
102 if (riverName == null) {
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3317
diff changeset
103 logger.warn("No river name found");
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3317
diff changeset
104 return Collections.<FlowVelocityModel>emptyList();
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3317
diff changeset
105 }
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3317
diff changeset
106
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 List<FlowVelocityModel> models = new ArrayList<FlowVelocityModel>();
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 for (DischargeZone zone: zones) {
5323
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4623
diff changeset
110 List<FlowVelocityModel> model = FlowVelocityModel.getModels(zone);
c7ce7c9e405e Removed river dependency from flow velocity model.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4623
diff changeset
111 models.addAll(model);
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 return models;
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 protected void prepareData(
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 FlowVelocityData data,
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 FlowVelocityModel model,
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 double kmLo,
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 double kmHi
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 ) {
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 List<FlowVelocityModelValue> values =
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 FlowVelocityModelValue.getValues(model, kmLo, kmHi);
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 logger.debug("Found " + values.size() + " values for model.");
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129 for (FlowVelocityModelValue value: values) {
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130 data.addKM(value.getStation().doubleValue());
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131 data.addQ(value.getQ().doubleValue());
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132 data.addVTotal(value.getTotalChannel().doubleValue());
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133 data.addVMain(value.getMainChannel().doubleValue());
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134 data.addTauMain(value.getShearStress().doubleValue());
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137 DischargeZone zone = model.getDischargeZone();
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138 String lo = zone.getLowerDischarge();
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139 String hi = zone.getUpperDischarge();
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140
4623
89322548b044 Set the discharge zone type to be able to generate the appropriate facets.
Raimund Renkert <rrenkert@intevation.de>
parents: 4483
diff changeset
141 data.setType(zone.fetchType());
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142 if (lo.equals(hi)) {
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 data.setZone(lo);
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 else {
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146 data.setZone(lo + " - " + hi);
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 protected CalculationResult buildCalculationResult(
4433
5b8919ef601d Backed out changeset e8a4d2fd25cc
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4432
diff changeset
152 FlowVelocityAccess access,
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 List<FlowVelocityModel> models
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 ) {
3230
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2702
diff changeset
155 double kmLo = access.getLowerKM();
b888c5eb65b3 Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2702
diff changeset
156 double kmHi = access.getUpperKM();
2702
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 logger.debug("Prepare data for km range: " + kmLo + " - " + kmHi);
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 FlowVelocityData[] data = new FlowVelocityData[models.size()];
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161 for (int i = 0, n = models.size(); i < n; i++) {
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162 FlowVelocityData d = new FlowVelocityData();
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 prepareData(d, models.get(i), kmLo, kmHi);
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
166 data[i] = d;
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 logger.debug("Calculation contains " + data.length + " data items.");
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171 return new CalculationResult(data, this);
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173 }
4c00cf83fff1 Added state, calculation and csv exporter for MINFO flow velociy calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org