annotate gnv-artifacts/src/main/java/de/intevation/gnv/math/QueriedXYDepth.java @ 804:9058c08eac3a

Added more Javadoc in some classes of state.profile. gnv-artifacts/trunk@886 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 08 Apr 2010 10:10:04 +0000
parents d766fe2d917a
children bb7afd783321
rev   line source
455
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.math;
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
3 import com.vividsolutions.jts.geom.Coordinate;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
4
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
5 import de.intevation.gnv.geobackend.base.Result;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
6
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
7 import de.intevation.gnv.geobackend.base.query.QueryExecutor;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
8 import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
9
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
10 import de.intevation.gnv.geobackend.base.query.exception.QueryException;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
11
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
12 import de.intevation.gnv.geobackend.sde.datasources.RasterObject;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
13
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
14 import de.intevation.gnv.utils.WKTUtils;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
15
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
16 import java.lang.ref.SoftReference;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
17
457
47ad9721e692 Added RasterObject for caching the Rastertiles to get a better performance.
Tim Englich <tim.englich@intevation.de>
parents: 455
diff changeset
18 import java.util.ArrayList;
455
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 import java.util.Collection;
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 import org.apache.log4j.Logger;
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 /**
780
c4156275c1e1 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 779
diff changeset
24 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
c4156275c1e1 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 779
diff changeset
25 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
455
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26 */
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 public class QueriedXYDepth implements XYDepth {
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 /**
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 * the logger, used to log exceptions and additonaly information
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 */
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 private static Logger log = Logger.getLogger(QueriedXYDepth.class);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 465
diff changeset
33
458
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
34 private static final String queryID = "rasterQuery";
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 465
diff changeset
35
458
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
36 private QueryExecutor queryExecutor;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 465
diff changeset
37
458
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
38 private ArrayList<SoftReference<RasterObject>> rasterData;
462
912797826099 Use new raster access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 458
diff changeset
39
912797826099 Use new raster access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 458
diff changeset
40 private RasterObject last;
463
07672838fa5f Make ground interpolation for vertical cross section configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 462
diff changeset
41
07672838fa5f Make ground interpolation for vertical cross section configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 462
diff changeset
42 private int interpolation;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 465
diff changeset
43
455
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 public QueriedXYDepth() {
463
07672838fa5f Make ground interpolation for vertical cross section configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 462
diff changeset
45 this(RasterObject.BILINEAR);
07672838fa5f Make ground interpolation for vertical cross section configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 462
diff changeset
46 }
07672838fa5f Make ground interpolation for vertical cross section configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 462
diff changeset
47
07672838fa5f Make ground interpolation for vertical cross section configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 462
diff changeset
48 public QueriedXYDepth(int interpolation) {
07672838fa5f Make ground interpolation for vertical cross section configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 462
diff changeset
49 this.interpolation = interpolation;
458
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
50 rasterData = new ArrayList<SoftReference<RasterObject>>();
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
51 queryExecutor = QueryExecutorFactory.getInstance().getQueryExecutor();
455
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 }
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 /**
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 * @see de.intevation.gnv.math.XYDepth#depth(com.vividsolutions.jts.geom.Coordinate)
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 */
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 public double depth(Coordinate coordinate) {
457
47ad9721e692 Added RasterObject for caching the Rastertiles to get a better performance.
Tim Englich <tim.englich@intevation.de>
parents: 455
diff changeset
58 double resultValue = Double.NaN;
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 465
diff changeset
59
458
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
60 RasterObject ro = getRasterObject(coordinate);
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 465
diff changeset
61
458
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
62 if (ro == null) {
457
47ad9721e692 Added RasterObject for caching the Rastertiles to get a better performance.
Tim Englich <tim.englich@intevation.de>
parents: 455
diff changeset
63 try {
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
64 String[] filterValues =
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
65 new String[] { WKTUtils.toWKT(coordinate) };
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
66 Collection<Result> result = queryExecutor.executeQuery(
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
67 queryID, filterValues);
458
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
68 for (Result row: result) {
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
69 if ((ro = (RasterObject)row.getObject(0)) != null) {
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
70 rasterData.add(
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
71 new SoftReference<RasterObject>(last = ro));
458
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
72 }
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
73 break;
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
74 }
457
47ad9721e692 Added RasterObject for caching the Rastertiles to get a better performance.
Tim Englich <tim.englich@intevation.de>
parents: 455
diff changeset
75 } catch (QueryException e) {
458
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
76 log.error(e, e);
457
47ad9721e692 Added RasterObject for caching the Rastertiles to get a better performance.
Tim Englich <tim.englich@intevation.de>
parents: 455
diff changeset
77 }
47ad9721e692 Added RasterObject for caching the Rastertiles to get a better performance.
Tim Englich <tim.englich@intevation.de>
parents: 455
diff changeset
78 }
458
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
79 return ro != null
463
07672838fa5f Make ground interpolation for vertical cross section configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 462
diff changeset
80 ? ro.getValue(coordinate, interpolation)
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 465
diff changeset
81 : Double.NaN;
455
363236fc462d Added Rasterdatasupport to VerticalCrossSections
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
82 }
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 465
diff changeset
83
463
07672838fa5f Make ground interpolation for vertical cross section configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 462
diff changeset
84 private RasterObject getRasterObject(Coordinate coordinate) {
462
912797826099 Use new raster access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 458
diff changeset
85 if (last != null && last.contains(coordinate)) {
912797826099 Use new raster access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 458
diff changeset
86 return last;
912797826099 Use new raster access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 458
diff changeset
87 }
458
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
88 for (int i = rasterData.size()-1; i >= 0; --i) {
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
89 SoftReference<RasterObject> ref = rasterData.get(i);
92d6cf448598 Improved raster tile based height evaluation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 457
diff changeset
90 RasterObject ro = ref.get();
462
912797826099 Use new raster access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 458
diff changeset
91 if (ro != null && ro.contains(coordinate)) {
912797826099 Use new raster access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 458
diff changeset
92 return last = ro;
457
47ad9721e692 Added RasterObject for caching the Rastertiles to get a better performance.
Tim Englich <tim.englich@intevation.de>
parents: 455
diff changeset
93 }
47ad9721e692 Added RasterObject for caching the Rastertiles to get a better performance.
Tim Englich <tim.englich@intevation.de>
parents: 455
diff changeset
94 }
47ad9721e692 Added RasterObject for caching the Rastertiles to get a better performance.
Tim Englich <tim.englich@intevation.de>
parents: 455
diff changeset
95 return null;
47ad9721e692 Added RasterObject for caching the Rastertiles to get a better performance.
Tim Englich <tim.englich@intevation.de>
parents: 455
diff changeset
96 }
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
97 }

http://dive4elements.wald.intevation.org