Mercurial > dive4elements > gnv-client
changeset 740:0563389138bb
Changed source of displayed coordinate in 'HorizontalProfil'-charts' subtitle (issue120).
gnv-artifacts/trunk@779 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 15 Mar 2010 15:39:59 +0000 |
parents | a40a6de70459 |
children | 2dc0666db49a |
files | gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileOutputState.java gnv-artifacts/src/main/java/de/intevation/gnv/utils/WKTUtils.java |
diffstat | 4 files changed, 59 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog Mon Mar 15 15:26:26 2010 +0000 +++ b/gnv-artifacts/ChangeLog Mon Mar 15 15:39:59 2010 +0000 @@ -1,3 +1,18 @@ +2010-03-15 Ingo Weinzierl <ingo.weinzierl@intevation.de> + + Issue120 + + * src/main/java/de/intevation/gnv/state/StateBase.java: New method + implemented which searches for a specific parameter by its name in the + current state and in all parent states. Null is returned if no parameter + could be found with this name, otherwise the InputData object. + + * src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileOutputState.java: + Display that point in chart subtitle which have been entered by the user. + + * src/main/java/de/intevation/gnv/utils/WKTUtils.java: Added a new method + to transform a Point object to a user-friendly formatted string. + 2010-03-15 Tim Englich <tim.englich@intevation.de> * doc/conf/products/verticalprofile/conf_timeseriespoint.xml:
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Mon Mar 15 15:26:26 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java Mon Mar 15 15:39:59 2010 +0000 @@ -1027,6 +1027,21 @@ return this.inputData != null ? this.inputData.values() : null; } + public InputData getInputDataByName(String name) { + State state = this; + + while (state != null) { + InputData data = state.inputData().get(name); + if (data != null) { + return data; + } + + state = state.getParent(); + } + + return null; + } + public void endOfLife(Object globalContext) { } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileOutputState.java Mon Mar 15 15:26:26 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileOutputState.java Mon Mar 15 15:39:59 2010 +0000 @@ -1,11 +1,5 @@ -/** - * - */ package de.intevation.gnv.state.profile.horizontal; -import com.vividsolutions.jts.io.ParseException; -import com.vividsolutions.jts.io.WKTReader; - import de.intevation.artifacts.CallContext; import de.intevation.gnv.chart.Chart; @@ -25,17 +19,21 @@ import de.intevation.gnv.state.exception.StateException; +import de.intevation.gnv.state.InputData; + import de.intevation.gnv.state.timeseries.TimeSeriesOutputState; import de.intevation.gnv.statistics.HorizontalProfileStatistics; import de.intevation.gnv.statistics.Statistics; +import de.intevation.gnv.utils.InputValidator; import de.intevation.gnv.utils.WKTUtils; import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Collection; @@ -49,6 +47,7 @@ /** * @author Tim Englich (tim.englich@intevation.de) + * @author Ingo Weinzierl (ingo.weinzierl@intevation.de) */ public class HorizontalProfileOutputState extends TimeSeriesOutputState @@ -257,18 +256,26 @@ return ""; StringBuilder meta = new StringBuilder(); - WKTReader wktReader = new WKTReader(); - for (int i = 0; i < CHART_TITLE_META.length; i++) { String qry = CHART_TITLE_META[i]; if (qry.equals("SHAPE")) { - String wktPoint = result.getString(qry); - - meta.append(getMessage(locale,"coordinate","coordinate")); - meta.append(": "); - meta.append(WKTUtils.toText(wktPoint)); + try { + InputData data = getInputDataByName("mesh_coordinate"); + if (data == null) { + continue; + } + String wktPoint = data.getValue(); + meta.append(getMessage(locale,"coordinate","coordinate")); + meta.append(": "); + meta.append(WKTUtils.toText( + locale, + new InputValidator().getPointValue(wktPoint))); + } + catch (Exception e) { + log.error(e, e); + } } else { log.debug( @@ -330,7 +337,7 @@ endDate = current; } } - catch (java.text.ParseException pe) { + catch (ParseException pe) { log.warn("Error while parsing date: " + data.getValue(), pe); } }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/WKTUtils.java Mon Mar 15 15:26:26 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/WKTUtils.java Mon Mar 15 15:39:59 2010 +0000 @@ -364,6 +364,14 @@ return toText(Locale.getDefault(), wkt); } + public static String toText(Point p) { + return toText(Locale.getDefault(), toWKT(p.getCoordinate())); + } + + public static String toText(Locale locale, Point p) { + return toText(locale, toWKT(p.getCoordinate())); + } + public static String toText(Locale locale, String wkt) { String formattedCoordinate = null; try {