annotate gnv-artifacts/src/main/java/de/intevation/gnv/statistics/HorizontalProfileStatistics.java @ 1119:7c4f81f74c47

merged gnv-artifacts
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:00 +0200
parents f953c9a559d8
children
rev   line source
1115
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 835
diff changeset
1 /*
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 835
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 835
diff changeset
3 *
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 835
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 835
diff changeset
5 * Read the file LGPL.txt coming with the software for details
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 835
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 835
diff changeset
7 */
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 835
diff changeset
8
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 package de.intevation.gnv.statistics;
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10
823
499cfbbb61bc Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents: 814
diff changeset
11 import java.sql.SQLException;
499cfbbb61bc Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents: 814
diff changeset
12 import java.util.Collection;
499cfbbb61bc Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents: 814
diff changeset
13
499cfbbb61bc Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents: 814
diff changeset
14 import org.apache.log4j.Logger;
499cfbbb61bc Removed obsolet SuppressWarnings-Annotations.
Tim Englich <tim.englich@intevation.de>
parents: 814
diff changeset
15
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
16 import com.vividsolutions.jts.geom.Point;
255
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
17 import com.vividsolutions.jts.io.ParseException;
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
18 import com.vividsolutions.jts.io.WKTReader;
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
19
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 import de.intevation.gnv.geobackend.base.Result;
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents: 255
diff changeset
21 import de.intevation.gnv.state.describedata.KeyValueDescibeData;
255
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
22 import de.intevation.gnv.utils.DistanceCalculator;
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 /**
814
9d427dd2a96a Added Javadoc in statistic package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
25 * This class is used to create a statistic for 'Horizontalprofil' products.
835
2423cefe7d39 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 823
diff changeset
26 *
780
c4156275c1e1 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 779
diff changeset
27 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
28 *
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 */
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 public class HorizontalProfileStatistics extends TimeseriesStatistics {
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
31
255
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
32 private static Logger log = Logger.getLogger(HorizontalProfileStatistics.class);
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33
255
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
34 private WKTReader wktReader = new WKTReader();
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
35
255
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
36 private DistanceCalculator dc = new DistanceCalculator();
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
37
255
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
38 private double distance = 0;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
39
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 /**
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 * Constructor
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 */
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 public HorizontalProfileStatistics() {
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 super();
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 }
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
46
814
9d427dd2a96a Added Javadoc in statistic package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
47
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 @Override
255
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
49 protected double calculateXOrdinateValue(Result previousRow,Result row)
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
50 throws SQLException {
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
51 try {
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
52 Point start = (Point)this.wktReader.read(previousRow.getString("SHAPE"));
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
53 Point current = (Point)this.wktReader.read(row.getString("SHAPE"));
814
9d427dd2a96a Added Javadoc in statistic package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
54 double delta = DistanceCalculator.calculateDistance(start, current);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
55
255
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
56 if (!Double.isNaN(delta)){
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
57 this.distance = this.distance + delta;
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
58 }
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
59 } catch (ParseException e) {
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
60 log.error(e,e);
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
61 }
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
62 return this.distance;
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 }
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 222
diff changeset
64
814
9d427dd2a96a Added Javadoc in statistic package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
65
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 222
diff changeset
66 @Override
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 222
diff changeset
67 protected String generateStatisticsName(
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 222
diff changeset
68 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: 222
diff changeset
69 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: 222
diff changeset
70 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: 222
diff changeset
71 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: 222
diff changeset
72 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: 222
diff changeset
73 Collection<KeyValueDescibeData> dates) {
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
74 return (this.findValueTitle(parameters, break1)+ " "+
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 222
diff changeset
75 this.findValueTitle(measurements,break2)).trim()+" "+
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 222
diff changeset
76 this.findValueTitle(dates,break3);
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 222
diff changeset
77 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
78
814
9d427dd2a96a Added Javadoc in statistic package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
79
255
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
80 @Override
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
81 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
82 log.debug("HorizontalProfileStatistics.clearStatistics");
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
83 super.clearStatistics();
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
84 this.distance = 0;
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
85 }
253
07650fc6014c Put a name to each Statistic group which is similar to the name of the
Tim Englich <tim.englich@intevation.de>
parents: 222
diff changeset
86
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
87 }

http://dive4elements.wald.intevation.org