annotate gnv-artifacts/src/main/java/de/intevation/gnv/statistics/HorizontalProfileStatistics.java @ 429:bed9735adf84

Finished preprocessing data for interpolation in verticalcrosssection charts.ß gnv-artifacts/trunk@477 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 22 Dec 2009 17:19:10 +0000
parents e964a3d8f7bc
children 9a828e5a2390
rev   line source
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 *
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 */
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 package de.intevation.gnv.statistics;
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6 import java.sql.SQLException;
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
7 import java.util.Collection;
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8
255
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
9 import org.apache.log4j.Logger;
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
10
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
11 import com.vividsolutions.jts.geom.Point;
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
12 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
13 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
14
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 import de.intevation.gnv.geobackend.base.Result;
335
e964a3d8f7bc Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents: 255
diff changeset
16 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
17 import de.intevation.gnv.utils.DistanceCalculator;
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 /**
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 * @author Tim Englich <tim.englich@intevation.de>
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
21 *
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 */
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 public class HorizontalProfileStatistics extends TimeseriesStatistics {
255
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
24
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
25 private static Logger log = Logger.getLogger(HorizontalProfileStatistics.class);
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26
255
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
27 private WKTReader wktReader = new WKTReader();
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
28
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
29 private DistanceCalculator dc = new DistanceCalculator();
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
30
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
31 private double 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
32
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 /**
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 * Constructor
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 */
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36 public HorizontalProfileStatistics() {
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 super();
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 }
171
7fb9441dd8af Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents: 113
diff changeset
39
255
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
40 /**
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
41 * @see de.intevation.gnv.statistics.TimeseriesStatistics#calculateXOrdinateValue(de.intevation.gnv.geobackend.base.Result, de.intevation.gnv.geobackend.base.Result)
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
42 */
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 @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
44 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
45 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
46 try {
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
47 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
48 Point current = (Point)this.wktReader.read(row.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
49 double delta = this.dc.calculateDistance(start, current);
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
50
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
51 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
52 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
53 }
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
54 } 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
55 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
56 }
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
57 return this.distance;
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
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: 222
diff changeset
59
255
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
60 /**
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
61 * @see de.intevation.gnv.statistics.TimeseriesStatistics#generateStatisticsName(java.lang.String, java.lang.String, java.lang.String, java.util.Collection, java.util.Collection, java.util.Collection)
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
62 */
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
63 @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
64 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
65 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
66 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
67 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
68 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
69 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
70 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: 222
diff changeset
71 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: 222
diff changeset
72 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
73 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
74 }
255
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
75
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
76 /**
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
77 * @see de.intevation.gnv.statistics.TimeseriesStatistics#clearStatistics()
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
78 */
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
79 @Override
5403452c06fc Added proper values for calculating the Statistics of VerticalProfiles and HorizontalProfiles issue86
Tim Englich <tim.englich@intevation.de>
parents: 253
diff changeset
80 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
81 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
82 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
83 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
84 }
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
85
113
a16f5267803e Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
86 }

http://dive4elements.wald.intevation.org