changeset 3078:0e0efd1acb4f

Added getter for current km in chart generator (used for navigation in fix analysis charts). flys-artifacts/trunk@4674 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 15 Jun 2012 12:16:49 +0000
parents 5c87d4ca1bd3
children 8ad8a227d983
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java
diffstat 2 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Jun 15 10:17:22 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Jun 15 12:16:49 2012 +0000
@@ -1,3 +1,8 @@
+2012-06-15  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/ChartGenerator.java:
+	  Added getter for current km.
+
 2012-06-15  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: Added
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Fri Jun 15 10:17:22 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Fri Jun 15 12:16:49 2012 +0000
@@ -94,6 +94,9 @@
     public static final String XPATH_CHART_Y_RANGE =
         "/art:action/art:attributes/art:yrange";
 
+    public static final String XPATH_CHART_CURRENTKM =
+        "/art:action/art:attributes/art:currentKm";
+
 
     /** The document of the incoming out() request.*/
     protected Document request;
@@ -1079,6 +1082,30 @@
     }
 
 
+    public double getCurrentKmFromRequest() {
+        Element km = (Element)XMLUtils.xpath(
+            request,
+            XPATH_CHART_CURRENTKM,
+            XPathConstants.NODE,
+            ArtifactNamespaceContext.INSTANCE);
+
+        if (km == null) {
+            return -1d;
+        }
+
+        String uri = ArtifactNamespaceContext.NAMESPACE_URI;
+
+        String currentKm = km.getAttributeNS(uri, "km");
+        try {
+            double d = Double.valueOf(currentKm).doubleValue();
+            return d;
+        }
+        catch(NumberFormatException nfe) {
+            return -1d;
+        }
+    }
+
+
     /**
      * Returns the default size of a chart export as array.
      *

http://dive4elements.wald.intevation.org