[PATCH 2 of 9] Handle flow velocity measurements in the FlowVelocity processor

Wald Commits scm-commit at wald.intevation.org
Thu Sep 26 12:57:00 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1380184701 -7200
# Node ID 4683bdf77ff9551649e28058694e623c212ddc8a
# Parent  b7b839557282dcbb7db4823d503869f69197e0f4
Handle flow velocity measurements in the FlowVelocity processor

diff -r b7b839557282 -r 4683bdf77ff9 artifacts/src/main/java/org/dive4elements/river/exports/process/FlowVelocityProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/FlowVelocityProcessor.java	Thu Sep 26 10:37:24 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/FlowVelocityProcessor.java	Thu Sep 26 10:38:21 2013 +0200
@@ -18,6 +18,7 @@
 import org.dive4elements.river.exports.StyledSeriesBuilder;
 import org.dive4elements.river.jfree.StyledXYSeries;
 import org.dive4elements.river.themes.ThemeDocument;
+import org.dive4elements.river.model.FlowVelocityMeasurementValue.FastFlowVelocityMeasurementValue;
 
 import org.dive4elements.river.artifacts.model.FlowVelocityData;
 
@@ -40,21 +41,28 @@
         CallContext context = generator.getCallContext();
         XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
                 theme);
-        FlowVelocityData data = (FlowVelocityData) bundle.getData(context);
+        String facetName = bundle.getFacetName();
+        Object data = bundle.getData(context);
         if (data == null) {
-            /* Check was there in the old generator */
-            logger.error("Flow velocity data is null. Bad facet.");
+            // Check has been here before so we keep it for security reasons
+            // this should never happen though.
+            logger.error("Data is null for facet: " + facetName);
             return;
         }
-        String facetName = bundle.getFacetName();
         double [][] points;
 
         if (facetName.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL) ||
                 facetName.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL_FILTERED)) {
-            points = data.getTotalChannelPoints();
+            FlowVelocityData fData = (FlowVelocityData) data;
+            points = fData.getTotalChannelPoints();
         } else if (facetName.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL) ||
                 facetName.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL_FILTERED)) {
-            points = data.getMainChannelPoints(); // I hate facets!
+            FlowVelocityData fData = (FlowVelocityData) data;
+            points = fData.getMainChannelPoints(); // I hate facets!
+        } else if (facetName.equals(FacetTypes.FLOW_VELOCITY_MEASUREMENT)) {
+            FastFlowVelocityMeasurementValue fData =
+                (FastFlowVelocityMeasurementValue) data;
+            points = new double[][] {{fData.getStation()},{fData.getV()}};
         } else {
             logger.error("Unknown facet name: " + facetName);
             return;
@@ -69,7 +77,8 @@
         return facettype.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL_FILTERED) ||
             facettype.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL) ||
             facettype.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL_FILTERED) ||
-            facettype.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL);
+            facettype.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL) ||
+            facettype.equals(FacetTypes.FLOW_VELOCITY_MEASUREMENT);
     }
 
     @Override


More information about the Dive4elements-commits mailing list