comparison gnv-artifacts/src/main/java/de/intevation/gnv/statistics/HorizontalProfileStatistics.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
4 package de.intevation.gnv.statistics; 4 package de.intevation.gnv.statistics;
5 5
6 import java.sql.SQLException; 6 import java.sql.SQLException;
7 import java.util.Collection; 7 import java.util.Collection;
8 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
9 import de.intevation.gnv.geobackend.base.Result; 15 import de.intevation.gnv.geobackend.base.Result;
10 import de.intevation.gnv.transition.describedata.KeyValueDescibeData; 16 import de.intevation.gnv.transition.describedata.KeyValueDescibeData;
17 import de.intevation.gnv.utils.DistanceCalculator;
11 18
12 /** 19 /**
13 * @author Tim Englich <tim.englich@intevation.de> 20 * @author Tim Englich <tim.englich@intevation.de>
14 * 21 *
15 */ 22 */
16 public class HorizontalProfileStatistics extends TimeseriesStatistics { 23 public class HorizontalProfileStatistics extends TimeseriesStatistics {
24
25 private static Logger log = Logger.getLogger(HorizontalProfileStatistics.class);
17 26
27 private WKTReader wktReader = new WKTReader();
28
29 private DistanceCalculator dc = new DistanceCalculator();
30
31 private double distance = 0;
32
18 /** 33 /**
19 * Constructor 34 * Constructor
20 */ 35 */
21 public HorizontalProfileStatistics() { 36 public HorizontalProfileStatistics() {
22 super(); 37 super();
23 } 38 }
24 39
40 /**
41 * @see de.intevation.gnv.statistics.TimeseriesStatistics#calculateXOrdinateValue(de.intevation.gnv.geobackend.base.Result, de.intevation.gnv.geobackend.base.Result)
42 */
25 @Override 43 @Override
26 protected double calculateXOrdinateValue(Result row) throws SQLException { 44 protected double calculateXOrdinateValue(Result previousRow,Result row)
27 return 0; // TODO FIXME 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;
28 } 58 }
29 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 */
30 @Override 63 @Override
31 protected String generateStatisticsName( 64 protected String generateStatisticsName(
32 String break1, 65 String break1,
33 String break2, 66 String break2,
34 String break3, 67 String break3,
37 Collection<KeyValueDescibeData> dates) { 70 Collection<KeyValueDescibeData> dates) {
38 return (this.findValueTitle(parameters, break1)+ " "+ 71 return (this.findValueTitle(parameters, break1)+ " "+
39 this.findValueTitle(measurements,break2)).trim()+" "+ 72 this.findValueTitle(measurements,break2)).trim()+" "+
40 this.findValueTitle(dates,break3); 73 this.findValueTitle(dates,break3);
41 } 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 }
42 85
43 } 86 }

http://dive4elements.wald.intevation.org