Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FlowVelocityCalculation.java @ 3230:b888c5eb65b3
Added new *Access objects for bed height calculation and flow velocity calculation; removed methods for specific data access from MINFOArtifact.
flys-artifacts/trunk@4859 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 03 Jul 2012 12:13:36 +0000 |
parents | 4c00cf83fff1 |
children | cdbc457e23e2 |
comparison
equal
deleted
inserted
replaced
3229:ad9640211db3 | 3230:b888c5eb65b3 |
---|---|
3 import java.util.ArrayList; | 3 import java.util.ArrayList; |
4 import java.util.List; | 4 import java.util.List; |
5 | 5 |
6 import org.apache.log4j.Logger; | 6 import org.apache.log4j.Logger; |
7 | 7 |
8 import de.intevation.artifacts.Artifact; | |
8 import de.intevation.flys.model.DischargeZone; | 9 import de.intevation.flys.model.DischargeZone; |
9 import de.intevation.flys.model.FlowVelocityModel; | 10 import de.intevation.flys.model.FlowVelocityModel; |
10 import de.intevation.flys.model.FlowVelocityModelValue; | 11 import de.intevation.flys.model.FlowVelocityModelValue; |
11 import de.intevation.flys.model.River; | 12 import de.intevation.flys.model.River; |
12 | 13 |
13 import de.intevation.flys.artifacts.MINFOArtifact; | 14 import de.intevation.flys.artifacts.access.FlowVelocityAccess; |
14 import de.intevation.flys.artifacts.model.FlowVelocityData; | 15 import de.intevation.flys.artifacts.model.FlowVelocityData; |
15 import de.intevation.flys.utils.FLYSUtils; | 16 import de.intevation.flys.utils.FLYSUtils; |
16 | 17 |
17 | 18 |
18 public class FlowVelocityCalculation extends Calculation { | 19 public class FlowVelocityCalculation extends Calculation { |
19 | 20 |
20 private static final Logger logger = | 21 private static final Logger logger = |
21 Logger.getLogger(FlowVelocityCalculation.class); | 22 Logger.getLogger(FlowVelocityCalculation.class); |
23 | |
24 | |
22 | 25 |
23 | 26 public CalculationResult calculate(FlowVelocityAccess access) { |
24 public CalculationResult calculate(MINFOArtifact artifact) { | |
25 logger.info("FlowVelocityCalculation.calculate"); | 27 logger.info("FlowVelocityCalculation.calculate"); |
26 | 28 |
27 int[] mainIds = artifact.getMainChannels(); | 29 int[] mainIds = access.getMainChannels(); |
28 int[] totalIds = artifact.getTotalChannels(); | 30 int[] totalIds = access.getTotalChannels(); |
29 | 31 |
30 if (logger.isDebugEnabled()) { | 32 if (logger.isDebugEnabled()) { |
31 logger.debug("Artifact '" + artifact.identifier() + "' contains:"); | 33 Artifact a = access.getArtifact(); |
34 logger.debug("Artifact '" + a.identifier() + "' contains:"); | |
32 if (mainIds != null) { | 35 if (mainIds != null) { |
33 logger.debug(" " + mainIds.length + " main channel ids"); | 36 logger.debug(" " + mainIds.length + " main channel ids"); |
34 } | 37 } |
35 | 38 |
36 if (totalIds != null) { | 39 if (totalIds != null) { |
37 logger.debug(" " + totalIds.length + " total channel ids"); | 40 logger.debug(" " + totalIds.length + " total channel ids"); |
38 } | 41 } |
39 } | 42 } |
40 | 43 |
41 List<DischargeZone> zones = getDischargeZones(mainIds, totalIds); | 44 List<DischargeZone> zones = getDischargeZones(mainIds, totalIds); |
42 List<FlowVelocityModel> models = getFlowVelocityModels(artifact, zones); | 45 List<FlowVelocityModel> models = getFlowVelocityModels(access, zones); |
43 | 46 |
44 return buildCalculationResult(artifact, models); | 47 return buildCalculationResult(access, models); |
45 } | 48 } |
46 | 49 |
47 | 50 |
48 protected List<DischargeZone> getDischargeZones( | 51 protected List<DischargeZone> getDischargeZones( |
49 int[] mainIds, | 52 int[] mainIds, |
74 return zones; | 77 return zones; |
75 } | 78 } |
76 | 79 |
77 | 80 |
78 protected List<FlowVelocityModel> getFlowVelocityModels( | 81 protected List<FlowVelocityModel> getFlowVelocityModels( |
79 MINFOArtifact artifact, | 82 FlowVelocityAccess access, |
80 List<DischargeZone> zones | 83 List<DischargeZone> zones |
81 ) { | 84 ) { |
82 River river = FLYSUtils.getRiver(artifact); | 85 River river = FLYSUtils.getRiver(access.getArtifact()); |
83 | 86 |
84 List<FlowVelocityModel> models = new ArrayList<FlowVelocityModel>(); | 87 List<FlowVelocityModel> models = new ArrayList<FlowVelocityModel>(); |
85 | 88 |
86 for (DischargeZone zone: zones) { | 89 for (DischargeZone zone: zones) { |
87 List<FlowVelocityModel> model = | 90 List<FlowVelocityModel> model = |
127 } | 130 } |
128 } | 131 } |
129 | 132 |
130 | 133 |
131 protected CalculationResult buildCalculationResult( | 134 protected CalculationResult buildCalculationResult( |
132 MINFOArtifact artifact, | 135 FlowVelocityAccess access, |
133 List<FlowVelocityModel> models | 136 List<FlowVelocityModel> models |
134 ) { | 137 ) { |
135 double kmLo = artifact.getDataAsDouble("ld_from"); | 138 double kmLo = access.getLowerKM(); |
136 double kmHi = artifact.getDataAsDouble("ld_to"); | 139 double kmHi = access.getUpperKM(); |
137 | 140 |
138 logger.debug("Prepare data for km range: " + kmLo + " - " + kmHi); | 141 logger.debug("Prepare data for km range: " + kmLo + " - " + kmHi); |
139 | 142 |
140 FlowVelocityData[] data = new FlowVelocityData[models.size()]; | 143 FlowVelocityData[] data = new FlowVelocityData[models.size()]; |
141 | 144 |