annotate gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java @ 253:07650fc6014c

Put a name to each Statistic group which is similar to the name of the Series in the Charts. issue83 gnv-artifacts/trunk@326 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Thu, 12 Nov 2009 10:15:05 +0000
parents 7fb9441dd8af
children 5403452c06fc
rev   line source
93
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 * Title: TimeseriesStatistics, $Header: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/output/statistics/TimeseriesStatistics.java,v 1.3 2008/08/18 14:50:33 drewnak Exp $
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 * Source: $Source: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/output/statistics/TimeseriesStatistics.java,v $
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 * created by: Stefan Blume (blume)
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5 * erstellt am: 06.12.2007
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6 * Copyright: con terra GmbH, 2005
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 *
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8 * modified by: $Author: drewnak $
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 * modified on: $Date: 2008/08/18 14:50:33 $
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10 * Version: $Revision: 1.3 $
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 * TAG: $Name: $
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 * locked from: $Locker: $
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 * CVS State: $State: Exp $
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 * Project: $ProjectName$
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 */
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 package de.intevation.gnv.statistics;
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17
98
156db25ad4b4 Add Statisticssupport also to VerticalProfiles
Tim Englich <tim.englich@intevation.de>
parents: 97
diff changeset
18 import java.sql.SQLException;
93
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 import java.util.ArrayList;
94
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
20 import java.util.Collection;
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
21 import java.util.Iterator;
93
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 import org.apache.commons.math.stat.regression.SimpleRegression;
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25 import org.apache.log4j.Logger;
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26
94
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
27 import de.intevation.gnv.geobackend.base.Result;
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
28 import de.intevation.gnv.statistics.exception.StatisticsException;
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
29 import de.intevation.gnv.transition.describedata.KeyValueDescibeData;
93
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 /**
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 * The class <code>TimeseriesStatistics</code> fulfills the following purposes:
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 * <ol>
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 * <li></li>
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 * </ol>
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
36 *
93
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 * @author blume
94
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
38 * @author Tim Englich <tim.englich@intevation.de>
93
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 * @version 1.0
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 * @serial 1.0
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 * @see
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 * @since 06.12.2007 18:02:27
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 */
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 public class TimeseriesStatistics implements Statistics {
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 /**
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 * Default Logging instance
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 */
95
13402ac8d8fe Put the Statisticscalulation to the Outmethod of the OutputTransition.
Tim Englich <tim.englich@intevation.de>
parents: 94
diff changeset
49 private static Logger log = Logger.getLogger(TimeseriesStatistics.class);
13402ac8d8fe Put the Statisticscalulation to the Outmethod of the OutputTransition.
Tim Englich <tim.englich@intevation.de>
parents: 94
diff changeset
50 private static boolean sDebug = log.isDebugEnabled();
93
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
53 public TimeseriesStatistics() {
95
13402ac8d8fe Put the Statisticscalulation to the Outmethod of the OutputTransition.
Tim Englich <tim.englich@intevation.de>
parents: 94
diff changeset
54 super();
13402ac8d8fe Put the Statisticscalulation to the Outmethod of the OutputTransition.
Tim Englich <tim.englich@intevation.de>
parents: 94
diff changeset
55 }
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
56
98
156db25ad4b4 Add Statisticssupport also to VerticalProfiles
Tim Englich <tim.englich@intevation.de>
parents: 97
diff changeset
57 /**
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
58 * @see de.intevation.gnv.statistics.Statistics#calculateStatistics(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)
98
156db25ad4b4 Add Statisticssupport also to VerticalProfiles
Tim Englich <tim.englich@intevation.de>
parents: 97
diff changeset
59 */
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
60 public Collection<StatisticSet> calculateStatistics(
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
61 Collection<Result> resultSet,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
62 Collection<KeyValueDescibeData> parameters,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
63 Collection<KeyValueDescibeData> measurements,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
64 Collection<KeyValueDescibeData> dates
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
65 )
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
66 throws StatisticsException {
93
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 DescriptiveStatistics lStatistics = null;
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 SimpleRegression lRegression = null;
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
69 Collection<StatisticSet> statisticSets = new ArrayList<StatisticSet>();
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
70 String break1, break2, break3;
94
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
71 int lSeries = 1;
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
72 try {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
73
94
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
74 Iterator<Result> resultIterator = resultSet.iterator();
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
75 if (resultIterator.hasNext()) {
94
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
76 Result row = resultIterator.next();
98
156db25ad4b4 Add Statisticssupport also to VerticalProfiles
Tim Englich <tim.englich@intevation.de>
parents: 97
diff changeset
77 break1 = row.getString("GROUP1");
156db25ad4b4 Add Statisticssupport also to VerticalProfiles
Tim Englich <tim.englich@intevation.de>
parents: 97
diff changeset
78 break2 = row.getString("GROUP2");
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
79 break3 = row.getString("GROUP3");
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
80 lRegression = new SimpleRegression();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
81 lStatistics = DescriptiveStatistics.newInstance();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
82 while (resultIterator.hasNext()) {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
83
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
84 if (!break1.equals(row.getString("GROUP1"))
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
85 || !break2.equals(row.getString("GROUP2"))
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
86 || !break3.equals(row.getString("GROUP3"))
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
87 ) {
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
88 String statisticsName = this.generateStatisticsName(break1, break2,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
89 break3, parameters,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
90 measurements, dates);
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
91 statisticSets.add(this.generateStatisticsValues(lStatistics,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
92 lRegression,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
93 statisticsName));
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
94
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
95 lStatistics.clear();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
96 lRegression.clear();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
97
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
98 lStatistics.addValue(row.getDouble("YORDINATE"));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
99 Double x = this.calculateXOrdinateValue(row);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
100 lRegression.addData(x, row.getDouble("YORDINATE"));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
101
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
102 break1 = row.getString("GROUP1");
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
103 break2 = row.getString("GROUP2");
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
104 break3 = row.getString("GROUP3");
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
105 row = resultIterator.next();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
106 lSeries++;
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
107 } else {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
108
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
109 lStatistics.addValue(row.getDouble("YORDINATE"));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
110 Double x = this.calculateXOrdinateValue(row);
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
111 lRegression.addData(x, row.getDouble("YORDINATE"));
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
112 row = resultIterator.next();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
113 }
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
114
94
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
115 }
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
116 String statisticsName = this.generateStatisticsName(break1, break2,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
117 break3, parameters,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
118 measurements, dates);
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
119
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
120 statisticSets.add(this.generateStatisticsValues(lStatistics,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
121 lRegression,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
122 statisticsName));
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
123 lStatistics.clear();
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
124 lRegression.clear();
94
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
125 }
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
126 } catch (Exception e) {
95
13402ac8d8fe Put the Statisticscalulation to the Outmethod of the OutputTransition.
Tim Englich <tim.englich@intevation.de>
parents: 94
diff changeset
127 log.error(e.getMessage(), e);
94
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
128 }
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
129
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
130 return statisticSets;
93
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
131 }
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
132
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
133 /**
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
134 *
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
135 * @param break1
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
136 * @param break2
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
137 * @param break3
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
138 * @param parameters
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
139 * @param measurements
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
140 * @param dates
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
141 * @return
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
142 */
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
143 protected String generateStatisticsName(String break1,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
144 String break2,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
145 String break3,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
146 Collection<KeyValueDescibeData> parameters,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
147 Collection<KeyValueDescibeData> measurements,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
148 Collection<KeyValueDescibeData> dates){
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
149 log.debug("TimeseriesStatistics.generateStatisticsName");
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
150 return this.findValueTitle(parameters,break1)+ " "+
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
151 this.findValueTitle(measurements,break2) + "m";
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
152 }
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
153
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
154
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
155 protected String findValueTitle(Collection<KeyValueDescibeData> values,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
156 String id) {
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
157 log.debug("TimeseriesStatistics.findValueTitle "+ id);
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
158 if (values != null) {
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
159 Iterator<KeyValueDescibeData> it = values.iterator();
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
160 while (it.hasNext()) {
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
161 KeyValueDescibeData data = it.next();
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
162 if (id.equals(data.getKey())) {
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
163 return data.getValue();
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
164 }
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
165 }
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
166 }
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
167 return "";
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
168 }
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
169 protected double calculateXOrdinateValue(Result row) throws SQLException {
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
170 return new Double((row.getDate("XORDINATE")).getTime() / 1000 / 3600);
98
156db25ad4b4 Add Statisticssupport also to VerticalProfiles
Tim Englich <tim.englich@intevation.de>
parents: 97
diff changeset
171 }
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
172
94
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
173 /**
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
174 * @param lStatistics
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
175 * @param lRegression
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
176 * @param lStats
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
177 * @param lSeries
6a825a184883 Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents: 93
diff changeset
178 */
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
179 private StatisticSet generateStatisticsValues(DescriptiveStatistics lStatistics,
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
180 SimpleRegression lRegression, String statisticName) {
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
181
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
182 StatisticSet statisticSet = new StatisticSet(statisticName);
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
183
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
184 statisticSet.addStatistic(new Statistic(
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
185 "gnviewer.statistics.descriptive.arithmeticMean", lStatistics
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
186 .getMean()));
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
187 statisticSet.addStatistic(new Statistic(
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
188 "gnviewer.statistics.descriptive.kurtosis", lStatistics
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
189 .getKurtosis()));
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
190 statisticSet.addStatistic(new Statistic("gnviewer.statistics.descriptive.max",
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
191 lStatistics.getMax()));
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
192 statisticSet.addStatistic(new Statistic("gnviewer.statistics.descriptive.min",
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
193 lStatistics.getMin()));
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
194 statisticSet.addStatistic(new Statistic("gnviewer.statistics.descriptive.n",
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
195 lStatistics.getN()));
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
196 statisticSet.addStatistic(new Statistic(
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
197 "gnviewer.statistics.descriptive.percentile.90", lStatistics
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
198 .getPercentile(90)));
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
199 statisticSet.addStatistic(new Statistic(
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
200 "gnviewer.statistics.descriptive.percentile.75", lStatistics
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
201 .getPercentile(75)));
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
202 statisticSet.addStatistic(new Statistic(
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
203 "gnviewer.statistics.descriptive.percentile.50", lStatistics
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
204 .getPercentile(50)));
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
205 statisticSet.addStatistic(new Statistic(
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
206 "gnviewer.statistics.descriptive.percentile.10", lStatistics
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
207 .getPercentile(10)));
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
208 statisticSet.addStatistic(new Statistic(
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
209 "gnviewer.statistics.descriptive.deviation", lStatistics
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
210 .getStandardDeviation()));
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
211 statisticSet.addStatistic(new Statistic(
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
212 "gnviewer.statistics.descriptive.variance", lStatistics
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
213 .getVariance()));
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
214 statisticSet.addStatistic(new Statistic(
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
215 "gnviewer.statistics.descriptive.intercept", lRegression
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
216 .getIntercept()));
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
217 statisticSet.addStatistic(new Statistic("gnviewer.statistics.descriptive.slope",
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
218 lRegression.getSlope()));
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 171
diff changeset
219 return statisticSet;
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 115
diff changeset
220 }
93
c476fbbaa4ca Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
221 }

http://dive4elements.wald.intevation.org