[PATCH 13 of 13] WQKmsInterpolArtifact: Add different facet if wst has only 'fake' Qs

Wald Commits scm-commit at wald.intevation.org
Mon Aug 26 15:27:22 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1377524139 -7200
# Node ID 972ec1f6cf582d91463d5f81b52c26bb04fe53fd
# Parent  b87240ac9205cc271b0419a051d45e609fbb8a47
WQKmsInterpolArtifact: Add different facet if wst has only 'fake' Qs.
Minor refactoring.

diff -r b87240ac9205 -r 972ec1f6cf58 artifacts/src/main/java/org/dive4elements/river/artifacts/WQKmsInterpolArtifact.java
--- 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


More information about the Dive4elements-commits mailing list