Mercurial > dive4elements > river
changeset 6260:947434874937
New facet for bedload diameter measurements.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 11 Jun 2013 09:17:29 +0200 |
parents | 06ee8e2f8b0b |
children | 83a04004969f |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedloadDiameterDataFacet.java |
diffstat | 1 files changed, 87 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedloadDiameterDataFacet.java Tue Jun 11 09:17:29 2013 +0200 @@ -0,0 +1,87 @@ +package org.dive4elements.river.artifacts.model.minfo; + +import gnu.trove.TDoubleArrayList; + +import org.apache.log4j.Logger; +import org.dive4elements.artifactdatabase.state.Facet; +import org.dive4elements.artifacts.Artifact; +import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.BedQualityAccess; +import org.dive4elements.river.artifacts.model.DataFacet; +import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; + + +public class BedloadDiameterDataFacet +extends DataFacet +{ + private static final Logger logger = Logger.getLogger(BedDiameterDataFacet.class); + + public BedloadDiameterDataFacet() { + } + + public BedloadDiameterDataFacet( + int ndx, + String name, + String description, + ComputeType type, + String stateId, + String hash + ) { + super(ndx, name, description, type, hash, stateId); + } + + public Object getData(Artifact artifact, CallContext context) { + D4EArtifact d4e = (D4EArtifact) artifact; + BedQualityAccess access = new BedQualityAccess(d4e, context); + int ndx = getIndex() & 7; + int diam = (getIndex() >> 3); + String diameter = ""; + switch (diam) { + case 1: diameter = "d10"; break; + case 2: diameter = "d16"; break; + case 3: diameter = "d20"; break; + case 4: diameter = "d25"; break; + case 5: diameter = "d30"; break; + case 6: diameter = "d40"; break; + case 7: diameter = "d50"; break; + case 8: diameter = "d60"; break; + case 9: diameter = "d70"; break; + case 10: diameter = "d75"; break; + case 11: diameter = "d80"; break; + case 12: diameter = "d84"; break; + case 13: diameter = "d90"; break; + case 14: diameter = "dmin"; break; + case 15: diameter = "dmax"; break; + case 16: diameter = "dm"; break; + default: return null; + } + + QualityMeasurements measurements = + QualityMeasurementFactory.getBedloadMeasurements( + access.getRiver(), + access.getFrom(), + access.getTo(), + access.getDateRanges().get(ndx).getFrom(), + access.getDateRanges().get(ndx).getTo()); + TDoubleArrayList kms = new TDoubleArrayList(); + TDoubleArrayList data = new TDoubleArrayList(); + for (QualityMeasurement m : measurements.getMeasurements()) { + kms.add(m.getKm()); + data.add(m.getDiameter(diameter)*1000); + } + BedDiameterData bdd = new BedDiameterData(diameter, kms, data); + return bdd; + } + + /** Copy deeply. */ + @Override + public Facet deepCopy() { + BedloadDiameterDataFacet copy = new BedloadDiameterDataFacet(); + copy.set(this); + copy.type = type; + copy.hash = hash; + copy.stateId = stateId; + return copy; + } +}