[Dive4elements-commits] [PATCH 1 of 5] Added container and facet for bed diameter measurements

Wald Commits scm-commit at wald.intevation.org
Mon Jun 10 16:31:24 CEST 2013


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1370874143 -7200
# Node ID 267119b38779fe6763a99ed16807761684e49e47
# Parent  8eb0e5c8db3fc5c2e9c69731cda46872851f0c42
Added container and facet for bed diameter measurements.

diff -r 8eb0e5c8db3f -r 267119b38779 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiameterData.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiameterData.java	Mon Jun 10 16:22:23 2013 +0200
@@ -0,0 +1,27 @@
+package org.dive4elements.river.artifacts.model.minfo;
+
+import gnu.trove.TDoubleArrayList;
+
+
+public class BedDiameterData
+extends BedQualityDiameterResult
+{
+
+    private TDoubleArrayList data;
+
+    public BedDiameterData() {
+        super();
+    }
+
+    public BedDiameterData (
+        String type,
+        TDoubleArrayList kms,
+        TDoubleArrayList data) {
+        super(type, kms);
+        this.data = data;
+    }
+
+    public double[][] getDiameterData() {
+        return new double[][]{kms.toNativeArray(), data.toNativeArray()};
+    }
+}
diff -r 8eb0e5c8db3f -r 267119b38779 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiameterDataFacet.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiameterDataFacet.java	Mon Jun 10 16:22:23 2013 +0200
@@ -0,0 +1,97 @@
+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 BedDiameterDataFacet
+extends DataFacet
+{
+    private static final Logger logger = Logger.getLogger(BedDiameterDataFacet.class);
+
+    private String diameter;
+    private boolean subCap;
+
+    public BedDiameterDataFacet() {
+    }
+
+    public BedDiameterDataFacet(
+        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 top = (getIndex() >> 3) & 1;
+        int diam = (getIndex() >> 4);
+        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.getBedMeasurements(
+                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()) {
+            if (top == 1 && m.getDepth1() == 0d && m.getDepth2() <= 0.3) {
+                kms.add(m.getKm());
+                data.add(m.getDiameter(diameter)*1000);
+            }
+            else if (top == 0 && m.getDepth1() > 0d && m.getDepth2() <= 0.5){
+                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() {
+        BedDiameterDataFacet copy = new BedDiameterDataFacet();
+        copy.set(this);
+        copy.type = type;
+        copy.hash = hash;
+        copy.stateId = stateId;
+        copy.diameter = diameter;
+        return copy;
+    }
+}


More information about the Dive4elements-commits mailing list