Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java @ 255:5403452c06fc
Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
gnv-artifacts/trunk@330 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Thu, 12 Nov 2009 14:47:20 +0000 |
parents | 07650fc6014c |
children | e964a3d8f7bc |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java Thu Nov 12 11:40:32 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java Thu Nov 12 14:47:20 2009 +0000 @@ -47,9 +47,10 @@ * Default Logging instance */ private static Logger log = Logger.getLogger(TimeseriesStatistics.class); - private static boolean sDebug = log.isDebugEnabled(); - + /** + * Constructor + */ public TimeseriesStatistics() { super(); } @@ -64,6 +65,7 @@ Collection<KeyValueDescibeData> dates ) throws StatisticsException { + this.clearStatistics(); DescriptiveStatistics lStatistics = null; SimpleRegression lRegression = null; Collection<StatisticSet> statisticSets = new ArrayList<StatisticSet>(); @@ -74,6 +76,7 @@ Iterator<Result> resultIterator = resultSet.iterator(); if (resultIterator.hasNext()) { Result row = resultIterator.next(); + Result previousRow = row; break1 = row.getString("GROUP1"); break2 = row.getString("GROUP2"); break3 = row.getString("GROUP3"); @@ -94,21 +97,25 @@ lStatistics.clear(); lRegression.clear(); + + this.clearStatistics(); lStatistics.addValue(row.getDouble("YORDINATE")); - Double x = this.calculateXOrdinateValue(row); + Double x = this.calculateXOrdinateValue(previousRow,row); lRegression.addData(x, row.getDouble("YORDINATE")); break1 = row.getString("GROUP1"); break2 = row.getString("GROUP2"); break3 = row.getString("GROUP3"); + previousRow = row; row = resultIterator.next(); lSeries++; } else { lStatistics.addValue(row.getDouble("YORDINATE")); - Double x = this.calculateXOrdinateValue(row); + Double x = this.calculateXOrdinateValue(previousRow, row); lRegression.addData(x, row.getDouble("YORDINATE")); + previousRow = row; row = resultIterator.next(); } @@ -130,6 +137,8 @@ return statisticSets; } + protected void clearStatistics(){} + /** * * @param break1 @@ -166,7 +175,7 @@ } return ""; } - protected double calculateXOrdinateValue(Result row) throws SQLException { + protected double calculateXOrdinateValue(Result previousRow, Result row) throws SQLException { return new Double((row.getDate("XORDINATE")).getTime() / 1000 / 3600); }