comparison gnv-artifacts/src/main/java/de/intevation/gnv/statistics/HorizontalProfileStatistics.java @ 657:af3f56758f59

merged gnv-artifacts/0.5
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:13:53 +0200
parents e964a3d8f7bc
children 9a828e5a2390
comparison
equal deleted inserted replaced
590:5f5f273c8566 657:af3f56758f59
1 /**
2 *
3 */
4 package de.intevation.gnv.statistics;
5
6 import java.sql.SQLException;
7 import java.util.Collection;
8
9 import org.apache.log4j.Logger;
10
11 import com.vividsolutions.jts.geom.Point;
12 import com.vividsolutions.jts.io.ParseException;
13 import com.vividsolutions.jts.io.WKTReader;
14
15 import de.intevation.gnv.geobackend.base.Result;
16 import de.intevation.gnv.state.describedata.KeyValueDescibeData;
17 import de.intevation.gnv.utils.DistanceCalculator;
18
19 /**
20 * @author Tim Englich <tim.englich@intevation.de>
21 *
22 */
23 public class HorizontalProfileStatistics extends TimeseriesStatistics {
24
25 private static Logger log = Logger.getLogger(HorizontalProfileStatistics.class);
26
27 private WKTReader wktReader = new WKTReader();
28
29 private DistanceCalculator dc = new DistanceCalculator();
30
31 private double distance = 0;
32
33 /**
34 * Constructor
35 */
36 public HorizontalProfileStatistics() {
37 super();
38 }
39
40 /**
41 * @see de.intevation.gnv.statistics.TimeseriesStatistics#calculateXOrdinateValue(de.intevation.gnv.geobackend.base.Result, de.intevation.gnv.geobackend.base.Result)
42 */
43 @Override
44 protected double calculateXOrdinateValue(Result previousRow,Result row)
45 throws SQLException {
46 try {
47 Point start = (Point)this.wktReader.read(previousRow.getString("SHAPE"));
48 Point current = (Point)this.wktReader.read(row.getString("SHAPE"));
49 double delta = this.dc.calculateDistance(start, current);
50
51 if (!Double.isNaN(delta)){
52 this.distance = this.distance + delta;
53 }
54 } catch (ParseException e) {
55 log.error(e,e);
56 }
57 return this.distance;
58 }
59
60 /**
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)
62 */
63 @Override
64 protected String generateStatisticsName(
65 String break1,
66 String break2,
67 String break3,
68 Collection<KeyValueDescibeData> parameters,
69 Collection<KeyValueDescibeData> measurements,
70 Collection<KeyValueDescibeData> dates) {
71 return (this.findValueTitle(parameters, break1)+ " "+
72 this.findValueTitle(measurements,break2)).trim()+" "+
73 this.findValueTitle(dates,break3);
74 }
75
76 /**
77 * @see de.intevation.gnv.statistics.TimeseriesStatistics#clearStatistics()
78 */
79 @Override
80 protected void clearStatistics() {
81 log.debug("HorizontalProfileStatistics.clearStatistics");
82 super.clearStatistics();
83 this.distance = 0;
84 }
85
86 }

http://dive4elements.wald.intevation.org