Mercurial > dive4elements > gnv-client
changeset 1078:5659b5c5e4b5
Added statistics for vectorial horizontalprofiles.
gnv-artifacts/trunk@1180 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 09 Jun 2010 07:29:55 +0000 (2010-06-09) |
parents | 1728aac87717 |
children | 1657ee3ac054 |
files | gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshVectorOutputState.java gnv-artifacts/src/main/java/de/intevation/gnv/statistics/HorizontalProfileVectorStatistics.java gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesVectorStatistics.java gnv-artifacts/src/main/java/de/intevation/gnv/statistics/VectorStatistics.java |
diffstat | 5 files changed, 94 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog Wed Jun 09 07:04:03 2010 +0000 +++ b/gnv-artifacts/ChangeLog Wed Jun 09 07:29:55 2010 +0000 @@ -1,3 +1,17 @@ +2010-06-09 Ingo Weinzierl <ingo.weinzierl@intevation.de> + + * src/main/java/de/intevation/gnv/statistics/HorizontalProfileVectorStatistics.java: + This is a class to create statistics for horizontal profiles with + vectorial parameters. + + * src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshVectorOutputState.java: + Added a new method to return an instance of + HorizontalProfileVectorStatistics. + + * src/main/java/de/intevation/gnv/statistics/TimeseriesVectorStatistics.java, + src/main/java/de/intevation/gnv/statistics/VectorStatistics.java: Added a + method to clean the statistics for the next vector component. + 2010-06-09 Ingo Weinzierl <ingo.weinzierl@intevation.de> * src/main/java/de/intevation/gnv/statistics/VectorStatistics.java: This is
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshVectorOutputState.java Wed Jun 09 07:04:03 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshVectorOutputState.java Wed Jun 09 07:29:55 2010 +0000 @@ -22,6 +22,9 @@ import de.intevation.gnv.state.exception.StateException; +import de.intevation.gnv.statistics.Statistics; +import de.intevation.gnv.statistics.HorizontalProfileVectorStatistics; + import java.io.IOException; import java.io.OutputStream; @@ -185,5 +188,10 @@ export.create(profile, outputStream, result); } + + + protected Statistics getStatisticsGenerator() { + return new HorizontalProfileVectorStatistics(); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/HorizontalProfileVectorStatistics.java Wed Jun 09 07:29:55 2010 +0000 @@ -0,0 +1,63 @@ +package de.intevation.gnv.statistics; + +import com.vividsolutions.jts.geom.Point; +import com.vividsolutions.jts.io.ParseException; +import com.vividsolutions.jts.io.WKTReader; + +import de.intevation.gnv.geobackend.base.Result; +import de.intevation.gnv.geobackend.base.ResultDescriptor; + +import de.intevation.gnv.utils.DistanceCalculator; + +import java.sql.SQLException; + +import org.apache.log4j.Logger; + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class HorizontalProfileVectorStatistics +extends VectorStatistics +{ + + private static Logger logger = + Logger.getLogger(HorizontalProfileVectorStatistics.class); + + private WKTReader wktReader = new WKTReader(); + + private double distance; + + + public HorizontalProfileVectorStatistics() { + distance = 0; + } + + + protected void clear() { + distance = 0; + } + + + protected int getValueIdx(ResultDescriptor rd) { + return rd.getColumnIndex("YORDINATE"); + } + + + protected double calculateXOrdinateValue(Result prev, Result row) + throws SQLException + { + try { + Point start = (Point) wktReader.read(prev.getString("SHAPE")); + Point current = (Point) wktReader.read(row.getString("SHAPE")); + + double delta = DistanceCalculator.calculateDistance(start, current); + + distance = !Double.isNaN(delta) ? distance + delta : distance; + } + catch (ParseException e) { + logger.error(e,e); + } + return distance; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesVectorStatistics.java Wed Jun 09 07:04:03 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesVectorStatistics.java Wed Jun 09 07:29:55 2010 +0000 @@ -16,6 +16,11 @@ } + protected void clear() { + // nothing to clear + } + + protected int getValueIdx(ResultDescriptor rd) { return rd.getColumnIndex("YORDINATE"); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/VectorStatistics.java Wed Jun 09 07:04:03 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/VectorStatistics.java Wed Jun 09 07:29:55 2010 +0000 @@ -77,6 +77,8 @@ lStatistics.clear(); lRegression.clear(); + + clear(); } Double yValue = getValue(row, valueIdx); @@ -114,6 +116,8 @@ } + abstract protected void clear(); + abstract protected int getValueIdx(ResultDescriptor rd); abstract protected double calculateXOrdinateValue(Result prev, Result now)