[Dive4elements-commits] [PATCH 16 of 17] SedimentLoadFacet: Minor refactor

Wald Commits scm-commit at wald.intevation.org
Wed Apr 10 17:14:22 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1365592284 -7200
# Node ID 4feda81c38bccf3920900da441be21ba0271aef7
# Parent  ddb2a4e982b8b375e631dda39125e3f5194ea399
SedimentLoadFacet: Minor refactor.

diff -r ddb2a4e982b8 -r 4feda81c38bc flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFacet.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFacet.java	Wed Apr 10 13:10:55 2013 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFacet.java	Wed Apr 10 13:11:24 2013 +0200
@@ -69,23 +69,7 @@
         }
 
         // Access data according to type.
-        double[][] sd = null;
-        if (getName().equals(FacetTypes.SEDIMENT_LOAD_SAND))
-            sd = result.getSandData();
-        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_COARSE))
-            sd = result.getCoarseData();
-        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_FINEMIDDLE))
-            sd = result.getFineMiddleData();
-        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_SUSP_SAND))
-            sd = result.getSuspSandData();
-        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_SUSP_SAND_BED))
-            sd = result.getSuspSandBedData();
-        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_SUSP_SEDIMENT))
-            sd = result.getSuspSedimentData();
-        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_TOTAL_LOAD))
-            sd = result.getTotalLoadData();
-        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_TOTAL))
-            sd = result.getTotalData();
+        double[][] sd = getLoadData(result);
 
         double[] km   = sd[0];
         double[] load = sd[1];
@@ -107,6 +91,7 @@
                     matchFound = true;
                 }
             }
+            // For now, add point if no matching measurement station found.
             if (!matchFound) {
                 values[0][i*2] = km[i];
                 values[1][i*2] = load[i];
@@ -117,6 +102,30 @@
     }
 
 
+    /** Get data according to type of facet. */
+    private double[][] getLoadData(SedimentLoadResult result) {
+        if (getName().equals(FacetTypes.SEDIMENT_LOAD_SAND))
+            return result.getSandData();
+        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_COARSE))
+            return result.getCoarseData();
+        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_FINEMIDDLE))
+            return result.getFineMiddleData();
+        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_SUSP_SAND))
+            return result.getSuspSandData();
+        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_SUSP_SAND_BED))
+            return result.getSuspSandBedData();
+        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_SUSP_SEDIMENT))
+            return result.getSuspSedimentData();
+        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_TOTAL_LOAD))
+            return result.getTotalLoadData();
+        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_TOTAL))
+            return result.getTotalData();
+        else {
+            logger.error("SedimentLoadFacet " + getName() + " cannot determine data type.");
+            return null;
+        }
+    }
+
     /** Copy deeply. */
     @Override
     public Facet deepCopy() {


More information about the Dive4elements-commits mailing list