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