[Dive4elements-commits] [PATCH 1 of 7] New Facet for sediment load fraction 'unknown'
Wald Commits
scm-commit at wald.intevation.org
Fri Jun 21 15:38:13 CEST 2013
# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1371821381 -7200
# Node ID 3eff8efb4354ce868ef0925632e7e8988a43dd61
# Parent ef08c4f57edeeacde283d55d5ff9ee46e1a831cc
New Facet for sediment load fraction 'unknown'.
diff -r ef08c4f57ede -r 3eff8efb4354 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java Fri Jun 21 15:29:41 2013 +0200
@@ -0,0 +1,66 @@
+package org.dive4elements.river.artifacts.model.minfo;
+
+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.SedimentLoadAccess;
+import org.dive4elements.river.artifacts.model.DataFacet;
+import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
+
+
+public class SedimentLoadUnknownFacet
+extends DataFacet
+{
+ /** Very own logger. */
+ private static Logger logger = Logger.getLogger(SedimentLoadFacet.class);
+
+ public SedimentLoadUnknownFacet() {
+ }
+
+ public SedimentLoadUnknownFacet(int idx, String name, String description,
+ ComputeType type, String stateId, String hash) {
+ super(idx, name, description, type, hash, stateId);
+ }
+
+ @Override
+ public Object getData(Artifact artifact, CallContext context) {
+ logger.debug("Get data for sediment load at index: " + index);
+
+ D4EArtifact flys = (D4EArtifact) artifact;
+
+ SedimentLoadAccess access = new SedimentLoadAccess(flys);
+ String river = access.getRiver();
+ SedimentLoad[] unknown =
+ SedimentLoadFactory.getSedimentLoadUnknown(river);
+
+ SedimentLoad load = SedimentLoadFactory.getLoadUnknown(
+ river, unknown[index].getDescription());
+ if (access.getUnit().equals("t/a") && load.getUnit().equals("m3/a")) {
+ for (Double km: load.getKms()) {
+ SedimentLoadFraction fraction = load.getFraction(km);
+ fraction.setUnknown(fraction.getUnknown() / 1.8);
+ load.addKm(km, fraction);
+ }
+ }
+ else if (access.getUnit().equals("m3/a") && load.getUnit().equals("t/a")) {
+ for (Double km: load.getKms()) {
+ SedimentLoadFraction fraction = load.getFraction(km);
+ fraction.setUnknown(fraction.getUnknown() * 1.8);
+ load.addKm(km, fraction);
+ }
+ }
+ return load;
+ }
+
+ /** Copy deeply. */
+ @Override
+ public Facet deepCopy() {
+ SedimentLoadUnknownFacet copy = new SedimentLoadUnknownFacet();
+ copy.set(this);
+ copy.hash = hash;
+ copy.stateId = stateId;
+ return copy;
+ }
+}
More information about the Dive4elements-commits
mailing list