Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightCalculation.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 | 250a370c377d |
children | cdbc457e23e2 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightCalculation.java Tue Jul 03 11:03:16 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightCalculation.java Tue Jul 03 12:13:36 2012 +0000 @@ -5,6 +5,7 @@ import org.apache.log4j.Logger; +import de.intevation.artifacts.Artifact; import de.intevation.artifacts.common.utils.DateUtils; import de.intevation.flys.model.BedHeightEpoch; @@ -13,7 +14,7 @@ import de.intevation.flys.model.BedHeightSingleValue; import de.intevation.flys.model.TimeInterval; -import de.intevation.flys.artifacts.MINFOArtifact; +import de.intevation.flys.artifacts.access.BedHeightAccess; import de.intevation.flys.artifacts.model.MiddleBedHeightData; @@ -23,13 +24,16 @@ Logger.getLogger(MiddleBedHeightCalculation.class); - public CalculationResult calculate(MINFOArtifact artifact) { + public CalculationResult calculate(BedHeightAccess access) { logger.info("MiddleBedHeightCalculation.calculate"); - int[] singleIds = artifact.getBedHeightSingleIDs(); - int[] epochIds = artifact.getBedHeightEpochIDs(); + int[] singleIds = access.getBedHeightSingleIDs(); + int[] epochIds = access.getBedHeightEpochIDs(); + if (logger.isDebugEnabled()) { + Artifact artifact = access.getArtifact(); + logger.debug("Artifact '" + artifact.identifier() + "' contains:"); if (singleIds != null) { logger.debug(" " + singleIds.length + " single bedheight ids"); @@ -40,14 +44,17 @@ } } - List<BedHeightSingle> singles = getSingles(artifact, singleIds); - List<BedHeightEpoch> epochs = getEpochs(artifact, epochIds); + List<BedHeightSingle> singles = getSingles(access, singleIds); + List<BedHeightEpoch> epochs = getEpochs(access, epochIds); - return buildCalculationResult(artifact, singles, epochs); + return buildCalculationResult(access, singles, epochs); } - protected List<BedHeightSingle> getSingles(MINFOArtifact minfo, int[] ids) { + protected List<BedHeightSingle> getSingles( + BedHeightAccess access, + int[] ids + ) { List<BedHeightSingle> singles = new ArrayList<BedHeightSingle>(); for (int id: ids) { @@ -66,7 +73,10 @@ } - protected List<BedHeightEpoch> getEpochs(MINFOArtifact minfo, int[] ids) { + protected List<BedHeightEpoch> getEpochs( + BedHeightAccess access, + int[] ids + ) { List<BedHeightEpoch> epochs = new ArrayList<BedHeightEpoch>(); for (int id: ids) { @@ -86,15 +96,14 @@ protected CalculationResult buildCalculationResult( - MINFOArtifact artifact, + BedHeightAccess access, List<BedHeightSingle> singles, List<BedHeightEpoch> epochs ) { logger.info("MiddleBedHeightCalculation.buildCalculationResult"); - int size = singles.size() + epochs.size(); - double kmLo = artifact.getDataAsDouble("ld_from"); - double kmHi = artifact.getDataAsDouble("ld_to"); + double kmLo = access.getLowerKM(); + double kmHi = access.getUpperKM(); List<MiddleBedHeightData> data = new ArrayList<MiddleBedHeightData>();