# HG changeset patch # User Ingo Weinzierl # Date 1276347645 0 # Node ID 51f3edc9d74384b24b1e77f8d4bdc94872d0614d # Parent 1dc08501a1bef5a400e049ac4227781db2011661 Added missing classes of the last commit. gnv-artifacts/trunk@1204 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 1dc08501a1be -r 51f3edc9d743 gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java Sat Jun 12 12:59:48 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java Sat Jun 12 13:00:45 2010 +0000 @@ -191,8 +191,8 @@ */ protected Object getData(String uuid, CallContext callContext) { Collection result = null; - InputData meshLine = inputData.get("mesh_linestring"); InputData meshId = inputData.get("meshid"); + String meshLine = getLineString(); if (meshLine == null) { log.error("mesh_linestring is not defined"); @@ -205,7 +205,7 @@ } Coordinate [] coords = WKTUtils.toCoordinates( - meshLine.getValue()); + meshLine); if (coords == null) { throw new IllegalStateException("cannot read coordinates"); @@ -243,6 +243,13 @@ } + protected String getLineString() { + InputData meshLine = inputData.get("mesh_linestring"); + + return meshLine != null ? meshLine.getValue() : null; + } + + @Override protected String getSelectedInputDataName(String uuid, String id) { Collection values = getCollection(id, uuid); diff -r 1dc08501a1be -r 51f3edc9d743 gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionParallelOutputState.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionParallelOutputState.java Sat Jun 12 13:00:45 2010 +0000 @@ -0,0 +1,106 @@ +package de.intevation.gnv.state.profile.verticalcrosssection; + +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.impl.CoordinateArraySequenceFactory; + +import com.vividsolutions.jts.io.WKTWriter; + + +import de.intevation.gnv.geobackend.base.Result; +import de.intevation.gnv.geobackend.base.ResultDescriptor; + +import de.intevation.gnv.geobackend.base.query.QueryExecutor; +import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory; + +import de.intevation.gnv.geobackend.base.query.exception.QueryException; + +import de.intevation.gnv.state.InputData; + +import de.intevation.gnv.utils.WKTUtils; + +import java.util.Collection; +import java.util.Iterator; + +import org.apache.log4j.Logger; + +/** + * @author Ingo Weinzierl + */ +public class VerticalCrossSectionParallelOutputState +extends VerticalCrossSectionOutputState +{ + public static final String QUERY_LINESTRING = + "verticalcrosssection_mesh_parallel_linestring"; + + private static Logger logger = + Logger.getLogger(VerticalCrossSectionParallelOutputState.class); + + @Override + protected String getLineString() { + Coordinate[] coordinates = null; + + try { + String[] filters = generateFilterValues(); + + QueryExecutor exec = QueryExecutorFactory + .getInstance() + .getQueryExecutor(); + + Collection results = exec.executeQuery(QUERY_LINESTRING, filters); + Iterator iter = results.iterator(); + + coordinates = new Coordinate[results.size()]; + int sIdx = -1; + int idx = 0; + + while (iter.hasNext()) { + Result result = (Result) iter.next(); + + if (sIdx == -1) { + ResultDescriptor rd = result.getResultDescriptor(); + sIdx = rd.getColumnIndex("SHAPE"); + } + + logger.debug(result.getString(sIdx)); + Coordinate c = WKTUtils.toCoordinate(result.getString(sIdx)); + + coordinates[idx++] = c; + } + } + catch (QueryException qe) { + logger.error(qe, qe); + } + + CoordinateArraySequenceFactory factory = + CoordinateArraySequenceFactory.instance(); + + if (coordinates == null) + return null; + + CoordinateSequence seq = factory.create(coordinates); + return seq != null ? WKTWriter.toLineString(seq) : null; + } + + + protected String[] generateFilterValues() { + String[] filters = new String[7]; + + InputData parameterid = inputData.get("parameterid"); + InputData timevalue = inputData.get("dateid"); + InputData meshid = inputData.get("meshid"); + InputData axisid = inputData.get("axisid"); + InputData meshpoint = inputData.get("mesh_point"); + + filters[0] = parameterid.getValue(); + filters[1] = "to_date('" + timevalue.getValue() + "', 'YYYY.MM.DD HH24:MI:SS')"; + filters[2] = meshid.getValue(); + filters[3] = meshid.getValue(); + filters[4] = axisid.getValue(); + filters[5] = axisid.getValue(); + filters[6] = meshpoint.getValue(); + + return filters; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :