changeset 5648:4feda81c38bc

SedimentLoadFacet: Minor refactor.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 10 Apr 2013 13:11:24 +0200
parents ddb2a4e982b8
children 066f3a2f34d6
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFacet.java
diffstat 1 files changed, 26 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- 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() {

http://dive4elements.wald.intevation.org