Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java @ 176:bff7bbb7c6f0
Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart.
gnv-artifacts/trunk@219 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Wed, 14 Oct 2009 10:49:35 +0000 |
parents | 7fb9441dd8af |
children | f2c76f35da5a |
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 * Title: ChartFactory, $Header: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/output/chart/ChartFactory.java,v 1.8 2007/12/21 12:31:15 blume Exp $ |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
3 * Source: $Source: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/output/chart/ChartFactory.java,v $ |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
4 * created by: Stefan Blume (blume) |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
5 * erstellt am: 06.12.2007 |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
6 * Copyright: con terra GmbH, 2005 |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
7 * |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
8 * modified by: $Author: blume $ |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
9 * modified on: $Date: 2007/12/21 12:31:15 $ |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
10 * Version: $Revision: 1.8 $ |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
11 * TAG: $Name: $ |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
12 * locked from: $Locker: $ |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
13 * CVS State: $State: Exp $ |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
14 * Project: $ProjectName$ |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
15 */ |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
16 package de.intevation.gnv.chart; |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
17 |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
18 import java.util.Collection; |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
19 import java.util.Iterator; |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
20 |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
21 import org.apache.log4j.Logger; |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
22 import org.jfree.chart.plot.PlotOrientation; |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
23 import org.jfree.data.xy.XYSeries; |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
24 |
176
bff7bbb7c6f0
Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart.
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
25 import com.vividsolutions.jts.geom.Point; |
bff7bbb7c6f0
Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart.
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
26 import com.vividsolutions.jts.io.WKTReader; |
bff7bbb7c6f0
Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart.
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
27 |
113
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
28 import de.intevation.gnv.chart.exception.TechnicalChartException; |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
29 import de.intevation.gnv.geobackend.base.Result; |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
30 |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
31 /** |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
32 * |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
33 * @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:
116
diff
changeset
|
34 * |
113
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 class HorizontalProfileChartFactory extends VerticalProfileChartFactory { |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
37 |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
38 /** |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
39 * Default Logging instance |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
40 */ |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
41 private static Logger sLogger = Logger |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
42 .getLogger(HorizontalProfileChartFactory.class); |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
43 private static boolean sDebug = sLogger.isDebugEnabled(); |
176
bff7bbb7c6f0
Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart.
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
44 |
bff7bbb7c6f0
Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart.
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
45 private WKTReader wktReader = new WKTReader(); |
113
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
46 |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
47 public HorizontalProfileChartFactory() { |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
48 super(); |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
49 super.plotOrientation = PlotOrientation.VERTICAL; |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
50 } |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
51 |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
52 /** |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
53 * |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
54 * @param seriesName |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
55 * @param resultSet |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
56 * @param lUpperCut |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
57 * @param lLowerCut |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
58 * @param pStart |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
59 * @param pEnd |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
60 * @return |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
61 * @throws TechnicalChartException |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
62 */ |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
63 @Override |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
64 protected XYSeries createXYSeries(String seriesName, |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
65 Collection<Result> resultSet, |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
66 int lUpperCut, int lLowerCut, int pStart, |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
67 int pEnd) throws TechnicalChartException { |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
68 if (sDebug) |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
69 sLogger.debug("createXYSeries()"); |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
70 XYSeries series = new XYSeries(seriesName); |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
71 try { |
176
bff7bbb7c6f0
Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart.
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
72 Point lastPoint = null; |
bff7bbb7c6f0
Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart.
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
73 double distance = 0; |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
74 int i = 0; |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
75 Iterator<Result> resultIterator = resultSet.iterator(); |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
76 while (resultIterator.hasNext()) { |
113
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
77 Result lRow = resultIterator.next(); |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
78 if (i >= pStart && i <= pEnd) { |
176
bff7bbb7c6f0
Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart.
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
79 Point p = (Point)wktReader.read(lRow.getString("SHAPE")); |
bff7bbb7c6f0
Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart.
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
80 if (lastPoint != null) { |
bff7bbb7c6f0
Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart.
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
81 distance = distance +p.distance(lastPoint); // TODO in Meter umrechnen |
113
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
82 } |
176
bff7bbb7c6f0
Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart.
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
83 lastPoint = p; |
bff7bbb7c6f0
Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart.
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
84 double yValue = lRow.getDouble("YORDINATE"); |
bff7bbb7c6f0
Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart.
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
85 series.add(distance, yValue); |
bff7bbb7c6f0
Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart.
Tim Englich <tim.englich@intevation.de>
parents:
171
diff
changeset
|
86 sLogger.debug(seriesName + " Added Value " + distance + " / " |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
87 + yValue); |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
88 } else if (i > pEnd) { |
113
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
89 return series; |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
90 } |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
91 i++; |
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
92 } |
171
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
93 } catch (OutOfMemoryError e) { |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
94 sLogger.error(e.getMessage(), e); |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
95 return series; |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
96 |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
97 } catch (Exception e) { // TechnicalChartException |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
98 sLogger.error(e.getMessage(), e); |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
99 } finally { |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
100 } |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
101 return series; |
7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
Tim Englich <tim.englich@intevation.de>
parents:
116
diff
changeset
|
102 } |
113
a16f5267803e
Added Basic-Support for HorizontalProfiles
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
103 } |