[Dive4elements-commits] [PATCH 4 of 7] New facet for bedload diameter measurements

Wald Commits scm-commit at wald.intevation.org
Tue Jun 11 09:21:30 CEST 2013


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1370935049 -7200
# Node ID 947434874937d247e5f7c57083fe7a52a367f41d
# Parent  06ee8e2f8b0b0fd7c7d49d8463211963a4719424
New facet for bedload diameter measurements.

diff -r 06ee8e2f8b0b -r 947434874937 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedloadDiameterDataFacet.java
--- /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;
+    }
+}


More information about the Dive4elements-commits mailing list