Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/utils/WKTUtils.java @ 852:b5f4b6073cde
Calculate the depth in an odv export of a 'Profilschnitt' properly (issue217).
gnv-artifacts/trunk@968 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 22 Apr 2010 08:54:36 +0000 |
parents | 05bf8534a35a |
children | f953c9a559d8 |
rev | line source |
---|---|
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.gnv.utils; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import com.vividsolutions.jts.geom.Coordinate; |
519
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
507
diff
changeset
|
4 import com.vividsolutions.jts.geom.LineString; |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import com.vividsolutions.jts.geom.Point; |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
6 import com.vividsolutions.jts.geom.Polygon; |
519
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
507
diff
changeset
|
7 |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import com.vividsolutions.jts.io.ParseException; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import com.vividsolutions.jts.io.WKTReader; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
519
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
507
diff
changeset
|
11 import de.intevation.gnv.artifacts.ressource.RessourceFactory; |
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
507
diff
changeset
|
12 |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.gnv.geobackend.base.Result; |
519
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
507
diff
changeset
|
14 |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.gnv.geobackend.base.query.QueryExecutor; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory; |
519
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
507
diff
changeset
|
17 |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.gnv.geobackend.base.query.exception.QueryException; |
440
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
19 |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.gnv.math.LinearFunction; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
507
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
22 import java.text.MessageFormat; |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
23 import java.text.NumberFormat; |
519
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
507
diff
changeset
|
24 |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 import java.util.ArrayList; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 import java.util.Collection; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 import java.util.List; |
507
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
28 import java.util.Locale; |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
519
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
507
diff
changeset
|
30 import org.apache.commons.math.FunctionEvaluationException; |
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
507
diff
changeset
|
31 |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 import org.apache.commons.math.optimization.OptimizationException; |
519
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
507
diff
changeset
|
33 |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 import org.apache.commons.math.optimization.fitting.CurveFitter; |
519
4e347624ee7c
Last part to fix gnv/issue153. Now 'Profilschnitte', 'Horizontalschnitte' and 'horizontale Schnittprofile'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
507
diff
changeset
|
35 |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 import org.apache.commons.math.optimization.general.GaussNewtonOptimizer; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 import org.apache.log4j.Logger; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
40 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
41 * A helper class which supports some useful methods to work with wkt strings. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
42 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
43 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
44 */ |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 public abstract class WKTUtils { |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 private static Logger log = Logger.getLogger(WKTUtils.class); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 public static final double NAUTICAL_MILE = 1852.216d; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 public static final double KILOMETER = 1000d; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
52 public static final String I_NAME = "MEDIAN.MESHPOINT.IPOSITION"; |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
53 public static final String J_NAME = "MEDIAN.MESHPOINT.JPOSITION"; |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
54 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
55 public static final String TRUE_EXPRESSION = "FEATUREID=FEATUREID"; |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
56 |
507
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
57 public static final String[] COORDINATE_OUT_FORMAT = { |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
58 "coordinate.template.northeast", |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
59 "coordinate.template.southeast", |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
60 "coordinate.template.northwest", |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
61 "coordinate.template.southwest" |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
62 }; |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
63 |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
64 public static final String DEFAULT_COORDINATE_TEMPLATE = |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
65 "{0}\u00b0N {1}'' {2}\u00b0E {3}''"; |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
66 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
67 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
68 * Checks the difference of two <code>Result</code>s. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
69 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
70 * @param a A Result. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
71 * @param b Another Result. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
72 * @param indices Indices to be checked. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
73 * @return true, if <i>a</i> and <i>b</i> are different - otherwise false. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
74 */ |
423
2402173a1490
Moved some methods back to old place.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
420
diff
changeset
|
75 public static boolean different(Result a, Result b, int [] indices) { |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 for (int i = 0; i < indices.length; ++i) { |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 String oa = a.getString(indices[i]); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 String ob = b.getString(indices[i]); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 if (oa == null && ob == null) { |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 continue; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 if (oa == null || ob == null) { |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 return true; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 if (!oa.equals(ob)) { |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 return true; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 return false; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
95 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
96 * Turns a wkt string into a coordinate. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
97 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
98 * @param shape A wkt string. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
99 * @return wkt string as coordinate. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
100 */ |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 public static Coordinate toCoordinate(String shape) { |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 try { |
482
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
480
diff
changeset
|
103 return shape != null |
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
480
diff
changeset
|
104 ? ((Point)(new WKTReader().read(shape))).getCoordinate() |
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
480
diff
changeset
|
105 : null; |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 catch (ParseException pe) { |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 log.error(pe); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 } |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
110 catch (ClassCastException cce) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
111 log.error("cannot read WKT point", cce); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
112 } |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 return null; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
116 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
117 * Turns a wkt string into a polygon. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
118 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
119 * @param shape A wkt string. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
120 * @return wkt string as polygon. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
121 */ |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
122 public static Polygon toPolygon(String shape) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
123 try { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
124 return (Polygon)new WKTReader().read(shape); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
125 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
126 catch (ParseException pe) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
127 log.error(pe); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
128 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
129 catch (ClassCastException cce) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
130 log.error("cannot read WKT polygon", cce); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
131 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
132 return null; |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
133 } |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
135 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
136 * Returns a distance in km. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
137 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
138 * @param distance A distance. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
139 * @return distance in km. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
140 */ |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 public static final double toKM(double distance) { |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 return (distance * NAUTICAL_MILE) / KILOMETER; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
143 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
144 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
146 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
147 * Turns a coordinate into a wkt string. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
148 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
149 * @param coordinate A coordinate. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
150 * @return the coordinate as wkt string. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
151 */ |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 public static String toWKT(Coordinate coordinate) { |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 StringBuilder sb = new StringBuilder("POINT("); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 sb.append(coordinate.x) |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 .append(' ') |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 .append(coordinate.y) |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 .append(')'); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 return sb.toString(); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
159 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
161 |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
162 public static final String indexBox( |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
740
diff
changeset
|
163 java.awt.Point a, |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
164 java.awt.Point b, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
165 String iName, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
166 String jName |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
167 ) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
168 int minI = Math.min(a.x, b.x) - 1; |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
169 int maxI = Math.max(a.x, b.x) + 1; |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
170 int minJ = Math.min(a.y, b.y) - 1; |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
171 int maxJ = Math.max(a.y, b.y) + 1; |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
172 StringBuilder sb = new StringBuilder("(") |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
173 .append(iName).append(" >= ").append(minI) |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
174 .append(" AND ").append(iName).append(" <= ").append(maxI) |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
175 .append(" AND ").append(jName).append(" >= ").append(minJ) |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
176 .append(" AND ").append(jName).append(" <= ").append(maxJ) |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
177 .append(')'); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
178 return sb.toString(); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
179 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
180 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
181 public static final String diagonalBox(List<java.awt.Point> points) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
182 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
183 if (points.get(0) != null && points.get(2) != null) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
184 return indexBox( |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
185 points.get(0), points.get(2), |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
186 I_NAME, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
187 J_NAME); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
188 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
189 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
190 if (points.get(1) != null && points.get(3) != null) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
191 return indexBox( |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
192 points.get(1), points.get(3), |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
193 I_NAME, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
194 J_NAME); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
195 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
196 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
197 return null; |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
198 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
199 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
200 public static String worldEnvelopeCoordinatesToIndex( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
201 Coordinate [] coords, |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
202 String meshid, |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
203 String ijkQueryID |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
204 ) |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
205 throws QueryException |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
206 { |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
207 List<java.awt.Point> points = |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
208 new ArrayList<java.awt.Point>(coords.length); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
209 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
210 ArrayList<Object []> missingPoints = |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
211 new ArrayList<Object []>(); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
212 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
213 createIJKPoints(coords, meshid, ijkQueryID, points, missingPoints); |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
740
diff
changeset
|
214 |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
215 String additionWhere = null; |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
216 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
217 if (missingPoints.size() == coords.length) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
218 log.debug("cannot create index buffer"); |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
219 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
220 else { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
221 additionWhere = diagonalBox(points); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
222 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
223 if (additionWhere == null) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
224 // 3 Points are missing or are on one side of the envelope |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
225 boolean remainsMissingPoints = calculateIJ4MissingPoints( |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
226 coords, points, missingPoints); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
227 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
228 if (!remainsMissingPoints) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
229 additionWhere = diagonalBox(points); |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
230 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
231 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
232 } |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
233 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
234 return additionWhere != null |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
235 ? additionWhere |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
236 : TRUE_EXPRESSION; |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
237 } |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
238 |
423
2402173a1490
Moved some methods back to old place.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
420
diff
changeset
|
239 public static String worldCoordinatesToIndex( |
440
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
240 Coordinate [] coords, |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
241 Collection<Result> result, |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
242 String meshid, |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
243 String ijkQueryID |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
244 ) |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
245 throws QueryException |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
246 { |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
247 List<java.awt.Point> points = new ArrayList<java.awt.Point>(coords.length); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
248 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
249 ArrayList<Object []> missingPoints = new ArrayList<Object []>(); |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
250 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
251 createIJKPoints(coords, meshid, ijkQueryID, points, missingPoints); |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
740
diff
changeset
|
252 |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
253 String additionWhere = TRUE_EXPRESSION; |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
254 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
255 if (missingPoints.size() == coords.length) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
256 log.debug("cannot create index buffer"); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
257 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
258 else { // generate index filter |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
259 boolean remainsMissingPoints = calculateIJ4MissingPoints( |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
260 coords, points, missingPoints); |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
261 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
262 if (!remainsMissingPoints) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
263 // TODO: Make Tablenames and Columns Configurable |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
264 IndexBuffer ib = new IndexBuffer( |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
740
diff
changeset
|
265 points, |
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
740
diff
changeset
|
266 I_NAME, |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
267 J_NAME ); |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
268 additionWhere = ib.toWhereClause(); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
269 log.debug("Additional Where Clause = "+additionWhere); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
270 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
271 } // if generate index filter |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
272 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
273 return additionWhere; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
274 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
275 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
276 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
277 /** |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
278 * @param coords |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
279 * @param points |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
280 * @param missingPoints |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
281 * @return |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
282 */ |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
283 private static boolean calculateIJ4MissingPoints( |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
284 Coordinate [] coords, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
285 List<java.awt.Point> points, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
286 ArrayList<Object[]> missingPoints |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
287 ) { |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
288 boolean remainsMissingPoints = !missingPoints.isEmpty(); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
289 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
290 if (remainsMissingPoints) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
291 // try to guess the missing (i, j) |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
292 CurveFitter iFitter = new CurveFitter(new GaussNewtonOptimizer(true)); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
293 CurveFitter jFitter = new CurveFitter(new GaussNewtonOptimizer(true)); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
294 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
295 for (int i = 0, N = points.size(); i < N; ++i) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
296 java.awt.Point p = (java.awt.Point)points.get(i); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
297 if (p != null) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
298 Coordinate coord = coords[i]; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
299 iFitter.addObservedPoint(coord.x, p.x); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
300 jFitter.addObservedPoint(coord.y, p.y); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
301 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
302 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
303 try { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
304 // XXX: Assumption: (i, j) are created by componentwise linear function. |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
305 // This is surely not correct because (x, y) are in a ellipsoid projection. |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
306 // TODO: use ellipsoid functions and fit with Levenberg Marquardt. |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
307 double [] iParams = iFitter.fit( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
308 LinearFunction.INSTANCE, new double [] { 1d, 1d }); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
309 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
310 double [] jParams = jFitter.fit( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
311 LinearFunction.INSTANCE, new double [] { 1d, 1d }); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
312 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
313 for (int i = missingPoints.size()-1; i >= 0; --i) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
314 Object [] a = (Object [])missingPoints.get(i); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
315 Coordinate coord = (Coordinate)a[1]; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
316 int pi = (int)Math.round(iParams[0]*coord.x + iParams[1]); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
317 int pj = (int)Math.round(jParams[0]*coord.y + jParams[1]); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
318 points.set( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
319 ((Integer)a[0]).intValue(), |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
320 new java.awt.Point(pi, pj)); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
321 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
322 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
323 remainsMissingPoints = false; // we filled the gaps |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
324 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
325 catch (FunctionEvaluationException fee) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
326 log.error(fee); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
327 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
328 catch (OptimizationException oe) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
329 log.error(oe); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
330 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
331 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
332 return remainsMissingPoints; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
333 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
334 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
335 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
336 /** |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
337 * @param coords |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
338 * @param meshid |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
339 * @param ijkQueryID |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
340 * @param points |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
341 * @param missingPoints |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
342 * @throws QueryException |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
343 */ |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
344 private static void createIJKPoints( |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
345 Coordinate[] coords, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
346 String meshid, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
347 String ijkQueryID, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
348 List<java.awt.Point> points, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
349 ArrayList<Object []> missingPoints |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
350 ) |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
740
diff
changeset
|
351 throws QueryException |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
352 { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
353 boolean debug = log.isDebugEnabled(); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
354 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
355 QueryExecutor queryExecutor = QueryExecutorFactory |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
356 .getInstance() |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
357 .getQueryExecutor(); |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
740
diff
changeset
|
358 |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
359 for (int i = 0; i < coords.length; i++) { |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
360 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
361 String wkt = toWKT(coords[i]); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
362 |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
363 Collection<Result> result = queryExecutor.executeQuery( |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
364 ijkQueryID, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
365 new String [] {meshid, wkt}); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
366 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
367 if (!result.isEmpty()) { |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
368 Result resultValue = result.iterator().next(); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
369 int iPos = resultValue.getInteger(1); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
370 int jPos = resultValue.getInteger(0); |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
371 if (debug) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
372 log.debug("Found Pos "+iPos+"/"+jPos +" for "+wkt); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
373 } |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
374 points.add(i, new java.awt.Point(iPos,jPos)); |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
375 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
376 else { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
377 if (debug) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
378 log.debug("No i/j Pos found for "+wkt); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
379 } |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
380 missingPoints.add(new Object [] { Integer.valueOf(i), coords[i] }); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
381 points.add(i, null); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
382 // Special Case no i,j found for Coordinate |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
383 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
384 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
385 } |
440
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
386 |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
387 public static Coordinate [] toCoordinates(String wkt) { |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
388 try { |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
389 LineString ls = (LineString)new WKTReader().read(wkt); |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
390 return ls.getCoordinates(); |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
391 } |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
392 catch (ParseException pe) { |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
393 log.error("cannot read WKT line string", pe); |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
394 } |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
395 catch (ClassCastException cce) { |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
396 log.error("cannot read WKT line string", cce); |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
397 } |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
398 return null; |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
399 } |
507
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
400 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
401 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
402 * Turns a wkt coordinate into a string format using the default locale of |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
403 * the virtual machine. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
404 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
405 * @param wkt A wkt coordinate. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
406 * @return A formatted coordinate. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
407 */ |
507
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
408 public static String toText(String wkt) { |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
409 return toText(Locale.getDefault(), wkt); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
410 } |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
411 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
412 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
413 * Turns a point into a string format using the default locale of the |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
414 * virtual machine. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
415 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
416 * @param p A point. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
417 * @return A point formatted as string. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
418 */ |
740
0563389138bb
Changed source of displayed coordinate in 'HorizontalProfil'-charts' subtitle (issue120).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
519
diff
changeset
|
419 public static String toText(Point p) { |
0563389138bb
Changed source of displayed coordinate in 'HorizontalProfil'-charts' subtitle (issue120).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
519
diff
changeset
|
420 return toText(Locale.getDefault(), toWKT(p.getCoordinate())); |
0563389138bb
Changed source of displayed coordinate in 'HorizontalProfil'-charts' subtitle (issue120).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
519
diff
changeset
|
421 } |
0563389138bb
Changed source of displayed coordinate in 'HorizontalProfil'-charts' subtitle (issue120).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
519
diff
changeset
|
422 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
423 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
424 * Turns a point into a string format using a given locale. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
425 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
426 * @param locale A locale. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
427 * @param p A point. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
428 * @return a point formatted as string. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
429 */ |
740
0563389138bb
Changed source of displayed coordinate in 'HorizontalProfil'-charts' subtitle (issue120).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
519
diff
changeset
|
430 public static String toText(Locale locale, Point p) { |
0563389138bb
Changed source of displayed coordinate in 'HorizontalProfil'-charts' subtitle (issue120).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
519
diff
changeset
|
431 return toText(locale, toWKT(p.getCoordinate())); |
0563389138bb
Changed source of displayed coordinate in 'HorizontalProfil'-charts' subtitle (issue120).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
519
diff
changeset
|
432 } |
0563389138bb
Changed source of displayed coordinate in 'HorizontalProfil'-charts' subtitle (issue120).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
519
diff
changeset
|
433 |
806
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
434 /** |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
435 * Turns a wkt coordiante into a formatted text using a given locale. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
436 * |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
437 * @param locale A locale. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
438 * @param wkt A wkt coordinate. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
439 * @return a formatted coordinate. |
2cea76f1112e
Added Javadoc in utils package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
778
diff
changeset
|
440 */ |
507
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
441 public static String toText(Locale locale, String wkt) { |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
442 String formattedCoordinate = null; |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
443 try { |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
444 Point p = (Point)new WKTReader().read(wkt); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
445 double lat = p.getY(); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
446 double lon =p.getX(); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
447 |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
448 int choice = 0; |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
449 |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
450 if (lat <0 ) { |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
451 choice += 1; |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
452 lat=-lat; |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
453 } |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
454 |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
455 if (lon <0 ) { |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
456 choice += 2; |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
457 lon=-lon; |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
458 } |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
459 |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
460 RessourceFactory factory = RessourceFactory.getInstance(); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
461 String template = factory.getRessource( |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
462 locale, |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
463 COORDINATE_OUT_FORMAT[choice], |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
464 DEFAULT_COORDINATE_TEMPLATE |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
465 ); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
466 |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
467 NumberFormat minFormatter = NumberFormat.getInstance(locale); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
468 minFormatter.setMaximumFractionDigits(3); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
469 minFormatter.setMinimumFractionDigits(3); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
470 |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
471 String minLat = minFormatter.format(60.*(lat-((int)lat))); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
472 String minLon = minFormatter.format(60.*(lon-((int)lon))); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
473 |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
474 NumberFormat degFormatter = NumberFormat.getInstance(locale); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
475 degFormatter.setMinimumIntegerDigits(2); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
476 |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
477 String formLat = degFormatter.format((int)lat); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
478 String formLon = degFormatter.format((int)lon); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
479 |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
480 MessageFormat formatter = new MessageFormat(template); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
481 |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
482 Object[] args = { |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
483 formLat, minLat, |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
484 formLon, minLon |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
485 }; |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
486 |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
487 return formatter.format(args); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
488 |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
489 } |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
490 catch (ParseException e) { |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
491 log.warn(e,e); |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
492 } |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
493 |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
494 return null; |
45be952a3215
Solved some issues. Removed encoding problems while formatting coordinates (issue137) and use this format as subtitle in charts (issue136).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
482
diff
changeset
|
495 } |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
496 } |
836
05bf8534a35a
Using unix line endings only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
806
diff
changeset
|
497 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |