Mercurial > dive4elements > gnv-client
comparison 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 |
comparison
equal
deleted
inserted
replaced
254:ce408af0ee57 | 255:5403452c06fc |
---|---|
45 | 45 |
46 /** | 46 /** |
47 * Default Logging instance | 47 * Default Logging instance |
48 */ | 48 */ |
49 private static Logger log = Logger.getLogger(TimeseriesStatistics.class); | 49 private static Logger log = Logger.getLogger(TimeseriesStatistics.class); |
50 private static boolean sDebug = log.isDebugEnabled(); | 50 |
51 | 51 /** |
52 | 52 * Constructor |
53 */ | |
53 public TimeseriesStatistics() { | 54 public TimeseriesStatistics() { |
54 super(); | 55 super(); |
55 } | 56 } |
56 | 57 |
57 /** | 58 /** |
62 Collection<KeyValueDescibeData> parameters, | 63 Collection<KeyValueDescibeData> parameters, |
63 Collection<KeyValueDescibeData> measurements, | 64 Collection<KeyValueDescibeData> measurements, |
64 Collection<KeyValueDescibeData> dates | 65 Collection<KeyValueDescibeData> dates |
65 ) | 66 ) |
66 throws StatisticsException { | 67 throws StatisticsException { |
68 this.clearStatistics(); | |
67 DescriptiveStatistics lStatistics = null; | 69 DescriptiveStatistics lStatistics = null; |
68 SimpleRegression lRegression = null; | 70 SimpleRegression lRegression = null; |
69 Collection<StatisticSet> statisticSets = new ArrayList<StatisticSet>(); | 71 Collection<StatisticSet> statisticSets = new ArrayList<StatisticSet>(); |
70 String break1, break2, break3; | 72 String break1, break2, break3; |
71 int lSeries = 1; | 73 int lSeries = 1; |
72 try { | 74 try { |
73 | 75 |
74 Iterator<Result> resultIterator = resultSet.iterator(); | 76 Iterator<Result> resultIterator = resultSet.iterator(); |
75 if (resultIterator.hasNext()) { | 77 if (resultIterator.hasNext()) { |
76 Result row = resultIterator.next(); | 78 Result row = resultIterator.next(); |
79 Result previousRow = row; | |
77 break1 = row.getString("GROUP1"); | 80 break1 = row.getString("GROUP1"); |
78 break2 = row.getString("GROUP2"); | 81 break2 = row.getString("GROUP2"); |
79 break3 = row.getString("GROUP3"); | 82 break3 = row.getString("GROUP3"); |
80 lRegression = new SimpleRegression(); | 83 lRegression = new SimpleRegression(); |
81 lStatistics = DescriptiveStatistics.newInstance(); | 84 lStatistics = DescriptiveStatistics.newInstance(); |
92 lRegression, | 95 lRegression, |
93 statisticsName)); | 96 statisticsName)); |
94 | 97 |
95 lStatistics.clear(); | 98 lStatistics.clear(); |
96 lRegression.clear(); | 99 lRegression.clear(); |
100 | |
101 this.clearStatistics(); | |
97 | 102 |
98 lStatistics.addValue(row.getDouble("YORDINATE")); | 103 lStatistics.addValue(row.getDouble("YORDINATE")); |
99 Double x = this.calculateXOrdinateValue(row); | 104 Double x = this.calculateXOrdinateValue(previousRow,row); |
100 lRegression.addData(x, row.getDouble("YORDINATE")); | 105 lRegression.addData(x, row.getDouble("YORDINATE")); |
101 | 106 |
102 break1 = row.getString("GROUP1"); | 107 break1 = row.getString("GROUP1"); |
103 break2 = row.getString("GROUP2"); | 108 break2 = row.getString("GROUP2"); |
104 break3 = row.getString("GROUP3"); | 109 break3 = row.getString("GROUP3"); |
110 previousRow = row; | |
105 row = resultIterator.next(); | 111 row = resultIterator.next(); |
106 lSeries++; | 112 lSeries++; |
107 } else { | 113 } else { |
108 | 114 |
109 lStatistics.addValue(row.getDouble("YORDINATE")); | 115 lStatistics.addValue(row.getDouble("YORDINATE")); |
110 Double x = this.calculateXOrdinateValue(row); | 116 Double x = this.calculateXOrdinateValue(previousRow, row); |
111 lRegression.addData(x, row.getDouble("YORDINATE")); | 117 lRegression.addData(x, row.getDouble("YORDINATE")); |
118 previousRow = row; | |
112 row = resultIterator.next(); | 119 row = resultIterator.next(); |
113 } | 120 } |
114 | 121 |
115 } | 122 } |
116 String statisticsName = this.generateStatisticsName(break1, break2, | 123 String statisticsName = this.generateStatisticsName(break1, break2, |
128 } | 135 } |
129 | 136 |
130 return statisticSets; | 137 return statisticSets; |
131 } | 138 } |
132 | 139 |
140 protected void clearStatistics(){} | |
141 | |
133 /** | 142 /** |
134 * | 143 * |
135 * @param break1 | 144 * @param break1 |
136 * @param break2 | 145 * @param break2 |
137 * @param break3 | 146 * @param break3 |
164 } | 173 } |
165 } | 174 } |
166 } | 175 } |
167 return ""; | 176 return ""; |
168 } | 177 } |
169 protected double calculateXOrdinateValue(Result row) throws SQLException { | 178 protected double calculateXOrdinateValue(Result previousRow, Result row) throws SQLException { |
170 return new Double((row.getDate("XORDINATE")).getTime() / 1000 / 3600); | 179 return new Double((row.getDate("XORDINATE")).getTime() / 1000 / 3600); |
171 } | 180 } |
172 | 181 |
173 /** | 182 /** |
174 * @param lStatistics | 183 * @param lStatistics |