Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java @ 440:eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
gnv-artifacts/trunk@488 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 28 Dec 2009 17:13:12 +0000 |
parents | 8975de9d7483 |
children | f42ed4f10b79 |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java Mon Dec 28 16:24:05 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java Mon Dec 28 17:13:12 2009 +0000 @@ -14,6 +14,8 @@ import java.util.Locale; import java.util.Map; import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import org.apache.log4j.Logger; @@ -25,9 +27,6 @@ import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.LineString; -import com.vividsolutions.jts.io.ParseException; -import com.vividsolutions.jts.io.WKTReader; import de.intevation.artifacts.CallContext; @@ -51,6 +50,8 @@ import de.intevation.gnv.math.XYColumn; import de.intevation.gnv.math.IJKey; +import de.intevation.gnv.state.InputData; + import de.intevation.gnv.state.describedata.KeyValueDescibeData; import de.intevation.gnv.state.exception.StateException; import de.intevation.gnv.state.timeseries.TimeSeriesOutputState; @@ -106,59 +107,64 @@ return element.getObjectValue(); log.debug("No results in cache yet."); - if (inputData.containsKey("mesh_linestring")) { - - try { - LineString ls = (LineString) new WKTReader().read( - inputData.get("mesh_linestring").getValue()); - - Coordinate[] coords = ls.getCoordinates(); - - String additionWhere = WKTUtils.worldCoordinatesToIndex( - result, - inputData, - ijkQueryID - ); - - - String[] filterValues = - generateFilterValuesFromInputData(); - String[] addedFilterValues = - new String[filterValues.length + 1]; - System.arraycopy( - filterValues, 0, - addedFilterValues, 0, - filterValues.length - ); - addedFilterValues[filterValues.length] = additionWhere; - - QueryExecutor exec = QueryExecutorFactory - .getInstance() - .getQueryExecutor(); + InputData meshLine = inputData.get("mesh_linestring"); + InputData meshId = inputData.get("meshid"); - result = exec.executeQuery(queryID, addedFilterValues); - } - catch (ParseException pe) { - log.error(pe, pe); - } - catch (QueryException qe) { - log.error(qe, qe); - } - } - else { - // TODO What should happen if there is no linestring? - log.warn("No linestring in inputData."); + if (meshLine == null) { + log.error("mesh_linestring is not defined"); + throw new IllegalStateException("missing mesh_linestring"); } - Object obj = process(preProcess(result)); + if (meshId == null) { + log.error("meshid is not defined"); + throw new IllegalStateException("missing meshid"); + } + + Coordinate [] coords = WKTUtils.toCoordinates( + meshLine.getValue()); + + if (coords == null) { + throw new IllegalStateException("cannot read coordinates"); + } + + try { + String additionWhere = WKTUtils.worldCoordinatesToIndex( + coords, + result, + meshId.getValue(), + ijkQueryID); + + String[] addedFilterValues = StringUtils.append( + generateFilterValuesFromInputData(), + additionWhere); + + QueryExecutor exec = QueryExecutorFactory + .getInstance() + .getQueryExecutor(); + + result = exec.executeQuery(queryID, addedFilterValues); + } + catch (QueryException qe) { + log.error(qe, qe); + } + + Object obj = process( + Arrays.asList(coords), + preProcess(result), + callContext); + CacheFactory.getInstance().getCache().put(new Element(key, obj)); return obj; } - protected Object process(AttributedXYColumns columns) { + protected Object process( + List<Coordinate> path, + AttributedXYColumns columns, + CallContext callContext + ) { // TODO Implement me return null; @@ -230,16 +236,6 @@ } - protected boolean attributeInList(String name) { - for (int i = 0; i < ATTRIBUTE_LIST.length; i++) { - if (name.equals(ATTRIBUTE_LIST[i])) - return true; - } - - return false; - } - - @Override protected Chart getChart( ChartLabels chartLables,