changeset 6925:972ec1f6cf58

WQKmsInterpolArtifact: Add different facet if wst has only 'fake' Qs. Minor refactoring.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 26 Aug 2013 15:35:39 +0200
parents b87240ac9205
children bf191baa37e7
files artifacts/src/main/java/org/dive4elements/river/artifacts/WQKmsInterpolArtifact.java
diffstat 1 files changed, 45 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/WQKmsInterpolArtifact.java	Mon Aug 26 15:34:46 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/WQKmsInterpolArtifact.java	Mon Aug 26 15:35:39 2013 +0200
@@ -132,7 +132,15 @@
                     name = STATIC_WKMS_INTERPOL;
                 }
                 else {
-                    name = STATIC_WQ;
+                    // If all Qs are zero, add different facet to
+                    // signalize that we want data to be drawn as marks
+                    // on axis.
+                    if (wstValueHasZeroQ()) {
+                        name = STATIC_W_INTERPOL;
+                    }
+                    else {
+                        name = STATIC_WQ;
+                    }
                 }
 
                 Facet wQFacet = new WQFacet(name,
@@ -204,6 +212,40 @@
     }
 
 
+    /** True if Wst has only 'fake' (zero) Q-ranges. */
+    private boolean wstValueHasZeroQ() {
+        WstValueTable table = getValueTable();
+        return table.hasEmptyQ();
+    }
+
+
+    /** Get the WstValueTable that matches parameterization. */
+    private WstValueTable getValueTable() {
+        // Get WstValueTable
+        int wstId = getDataAsInt("wst_id");
+        if (getDataAsString("col_pos") != null) {
+            return WstValueTableFactory.getWstColumnTable(
+                wstId, getDataAsInt("col_pos"));
+        }
+        else {
+            return WstValueTableFactory.getTable(wstId);
+        }
+    }
+
+
+    /**
+     * Get WQ Values at a certain km, interpolating only if distance
+     * between two stations is smaller than given distance.
+     */
+    public double [][] getWQAtKm(
+        Double currentKm,
+        double maxKmInterpolDistance
+    ) {
+        // TODO yet to be implemented (issue1378).
+        return null;
+    }
+
+
     /**
      * Get WQ at a given km.
      *
@@ -213,16 +255,8 @@
      */
     public double [][] getWQAtKm(Double currentKm) {
 
-        WstValueTable interpolator = null;
-        // Get WstValueTable
-        if (getDataAsString("col_pos") != null) {
-            interpolator = WstValueTableFactory.getWstColumnTable(
-                getDataAsInt("wst_id"), getDataAsInt("col_pos"));
-        }
-        else {
-            interpolator = WstValueTableFactory.getTable(
-                getDataAsInt("wst_id"));
-        }
+        // TODO issue1378: only interpolate if dist <= 100m
+        WstValueTable interpolator = getValueTable();
 
         Double tmp = (currentKm != null)
                      ? currentKm

http://dive4elements.wald.intevation.org