Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java @ 364:2413273f1c13
Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly.
gnv-artifacts/trunk@439 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 16 Dec 2009 11:58:44 +0000 |
parents | 59ad8f37a590 |
children | 04a242c67fe6 |
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; |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
255
diff
changeset
|
28 import de.intevation.gnv.state.describedata.KeyValueDescibeData; |
94
6a825a184883
Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents:
93
diff
changeset
|
29 import de.intevation.gnv.statistics.exception.StatisticsException; |
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); |
93
c476fbbaa4ca
Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
50 |
255
5403452c06fc
Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents:
253
diff
changeset
|
51 /** |
5403452c06fc
Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents:
253
diff
changeset
|
52 * Constructor |
5403452c06fc
Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents:
253
diff
changeset
|
53 */ |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
54 public TimeseriesStatistics() { |
95
13402ac8d8fe
Put the Statisticscalulation to the Outmethod of the OutputTransition.
Tim Englich <tim.englich@intevation.de>
parents:
94
diff
changeset
|
55 super(); |
13402ac8d8fe
Put the Statisticscalulation to the Outmethod of the OutputTransition.
Tim Englich <tim.englich@intevation.de>
parents:
94
diff
changeset
|
56 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
57 |
98
156db25ad4b4
Add Statisticssupport also to VerticalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
97
diff
changeset
|
58 /** |
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
|
59 * @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
|
60 */ |
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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 ) |
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
|
67 throws StatisticsException { |
255
5403452c06fc
Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents:
253
diff
changeset
|
68 this.clearStatistics(); |
93
c476fbbaa4ca
Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
69 DescriptiveStatistics lStatistics = null; |
c476fbbaa4ca
Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
70 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
|
71 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
|
72 String break1, break2, break3; |
94
6a825a184883
Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents:
93
diff
changeset
|
73 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
|
74 try { |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
75 |
94
6a825a184883
Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents:
93
diff
changeset
|
76 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
|
77 if (resultIterator.hasNext()) { |
94
6a825a184883
Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents:
93
diff
changeset
|
78 Result row = resultIterator.next(); |
255
5403452c06fc
Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents:
253
diff
changeset
|
79 Result previousRow = row; |
98
156db25ad4b4
Add Statisticssupport also to VerticalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
97
diff
changeset
|
80 break1 = row.getString("GROUP1"); |
156db25ad4b4
Add Statisticssupport also to VerticalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
97
diff
changeset
|
81 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
|
82 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
|
83 lRegression = new SimpleRegression(); |
354
0970d9a7d65e
Upgraded to Apache Commons Math 2.0.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
84 lStatistics = new DescriptiveStatistics(); |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
85 while (resultIterator.hasNext()) { |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
86 |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
87 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
|
88 || !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
|
89 || !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
|
90 ) { |
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 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
|
92 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
|
93 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
|
94 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
|
95 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
|
96 statisticsName)); |
171
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.clear(); |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
99 lRegression.clear(); |
255
5403452c06fc
Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents:
253
diff
changeset
|
100 |
5403452c06fc
Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents:
253
diff
changeset
|
101 this.clearStatistics(); |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
102 |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
103 lStatistics.addValue(row.getDouble("YORDINATE")); |
255
5403452c06fc
Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents:
253
diff
changeset
|
104 Double x = this.calculateXOrdinateValue(previousRow,row); |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
105 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
|
106 |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
107 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
|
108 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
|
109 break3 = row.getString("GROUP3"); |
255
5403452c06fc
Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents:
253
diff
changeset
|
110 previousRow = row; |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
111 row = resultIterator.next(); |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
112 lSeries++; |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
113 } else { |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
114 |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
115 lStatistics.addValue(row.getDouble("YORDINATE")); |
255
5403452c06fc
Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents:
253
diff
changeset
|
116 Double x = this.calculateXOrdinateValue(previousRow, row); |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
117 lRegression.addData(x, row.getDouble("YORDINATE")); |
255
5403452c06fc
Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents:
253
diff
changeset
|
118 previousRow = row; |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
119 row = resultIterator.next(); |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
120 } |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
121 |
94
6a825a184883
Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents:
93
diff
changeset
|
122 } |
359
59ad8f37a590
Issue96 Resloved big that one entry is missiing in the Statitic.
Tim Englich <tim.englich@intevation.de>
parents:
354
diff
changeset
|
123 |
59ad8f37a590
Issue96 Resloved big that one entry is missiing in the Statitic.
Tim Englich <tim.englich@intevation.de>
parents:
354
diff
changeset
|
124 lStatistics.addValue(row.getDouble("YORDINATE")); |
59ad8f37a590
Issue96 Resloved big that one entry is missiing in the Statitic.
Tim Englich <tim.englich@intevation.de>
parents:
354
diff
changeset
|
125 Double x = this.calculateXOrdinateValue(previousRow, row); |
59ad8f37a590
Issue96 Resloved big that one entry is missiing in the Statitic.
Tim Englich <tim.englich@intevation.de>
parents:
354
diff
changeset
|
126 lRegression.addData(x, row.getDouble("YORDINATE")); |
59ad8f37a590
Issue96 Resloved big that one entry is missiing in the Statitic.
Tim Englich <tim.englich@intevation.de>
parents:
354
diff
changeset
|
127 |
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
|
128 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
|
129 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
|
130 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
|
131 |
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
|
132 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
|
133 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
|
134 statisticsName)); |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
135 lStatistics.clear(); |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
136 lRegression.clear(); |
94
6a825a184883
Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents:
93
diff
changeset
|
137 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
138 } catch (Exception e) { |
95
13402ac8d8fe
Put the Statisticscalulation to the Outmethod of the OutputTransition.
Tim Englich <tim.englich@intevation.de>
parents:
94
diff
changeset
|
139 log.error(e.getMessage(), e); |
94
6a825a184883
Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents:
93
diff
changeset
|
140 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
141 |
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
|
142 return statisticSets; |
93
c476fbbaa4ca
Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
143 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
144 |
255
5403452c06fc
Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents:
253
diff
changeset
|
145 protected void clearStatistics(){} |
5403452c06fc
Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents:
253
diff
changeset
|
146 |
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
|
147 /** |
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 * |
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 * @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
|
150 * @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
|
151 * @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
|
152 * @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
|
153 * @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
|
154 * @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
|
155 * @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
|
156 */ |
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 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
|
158 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
|
159 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
|
160 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
|
161 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
|
162 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
|
163 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
|
164 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
|
165 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
|
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 |
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 |
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
|
169 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
|
170 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
|
171 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
|
172 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
|
173 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
|
174 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
|
175 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
|
176 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
|
177 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
|
178 } |
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 } |
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 } |
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 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
|
182 } |
255
5403452c06fc
Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents:
253
diff
changeset
|
183 protected double calculateXOrdinateValue(Result previousRow, Result row) throws SQLException { |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
184 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
|
185 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
186 |
94
6a825a184883
Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents:
93
diff
changeset
|
187 /** |
6a825a184883
Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents:
93
diff
changeset
|
188 * @param lStatistics |
6a825a184883
Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents:
93
diff
changeset
|
189 * @param lRegression |
6a825a184883
Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents:
93
diff
changeset
|
190 * @param lStats |
6a825a184883
Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents:
93
diff
changeset
|
191 * @param lSeries |
6a825a184883
Remove Compile-Errors from the StatisticsPart
Tim Englich <tim.englich@intevation.de>
parents:
93
diff
changeset
|
192 */ |
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
|
193 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
|
194 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
|
195 |
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 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
|
197 |
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
|
198 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
|
199 "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
|
200 .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
|
201 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
|
202 "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
|
203 .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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 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
|
211 "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
|
212 .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
|
213 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
|
214 "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
|
215 .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
|
216 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
|
217 "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
|
218 .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
|
219 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
|
220 "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
|
221 .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
|
222 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
|
223 "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
|
224 .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
|
225 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
|
226 "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
|
227 .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
|
228 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
|
229 "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
|
230 .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
|
231 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
|
232 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
|
233 return statisticSet; |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
115
diff
changeset
|
234 } |
93
c476fbbaa4ca
Imported Statistics-Classes from old Project. Revision: 3101 Does not compile
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
235 } |