Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/utils/WKTUtils.java @ 738:40c9a48f51ea
Modified the Workflow of TimeSeries on TimeSeriespoints that the Data that was sent by the Mapviewer-Interface take effect.
gnv-artifacts/trunk@777 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Mon, 15 Mar 2010 15:15:56 +0000 |
parents | 4e347624ee7c |
children | 0563389138bb |
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 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 public abstract class WKTUtils { |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 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
|
43 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 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
|
45 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
|
46 |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
47 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
|
48 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
|
49 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
50 public static final String TRUE_EXPRESSION = "FEATUREID=FEATUREID"; |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
51 |
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
|
52 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
|
53 "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
|
54 "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
|
55 "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
|
56 "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
|
57 }; |
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 |
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 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
|
60 "{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
|
61 |
423
2402173a1490
Moved some methods back to old place.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
420
diff
changeset
|
62 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
|
63 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
|
64 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
|
65 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
|
66 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 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
|
68 continue; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 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
|
72 return true; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 if (!oa.equals(ob)) { |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 return true; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 return false; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 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
|
83 try { |
482
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
480
diff
changeset
|
84 return shape != null |
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
480
diff
changeset
|
85 ? ((Point)(new WKTReader().read(shape))).getCoordinate() |
64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
480
diff
changeset
|
86 : null; |
420
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 catch (ParseException pe) { |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 log.error(pe); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 } |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
91 catch (ClassCastException cce) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
92 log.error("cannot read WKT point", cce); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
93 } |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 return null; |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
97 public static Polygon toPolygon(String shape) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
98 try { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
99 return (Polygon)new WKTReader().read(shape); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
100 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
101 catch (ParseException pe) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
102 log.error(pe); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
103 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
104 catch (ClassCastException cce) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
105 log.error("cannot read WKT polygon", cce); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
106 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
107 return null; |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
108 } |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 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
|
111 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
|
112 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 |
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 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
|
116 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
|
117 sb.append(coordinate.x) |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 .append(' ') |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 .append(coordinate.y) |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 .append(')'); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 return sb.toString(); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
124 public static final String indexBox( |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
125 java.awt.Point a, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
126 java.awt.Point b, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
127 String iName, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
128 String jName |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
129 ) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
130 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
|
131 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
|
132 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
|
133 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
|
134 StringBuilder sb = new StringBuilder("(") |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
135 .append(iName).append(" >= ").append(minI) |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
136 .append(" AND ").append(iName).append(" <= ").append(maxI) |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
137 .append(" AND ").append(jName).append(" >= ").append(minJ) |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
138 .append(" AND ").append(jName).append(" <= ").append(maxJ) |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
139 .append(')'); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
140 return sb.toString(); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
141 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
142 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
143 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
|
144 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
145 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
|
146 return indexBox( |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
147 points.get(0), points.get(2), |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
148 I_NAME, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
149 J_NAME); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
150 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
151 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
152 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
|
153 return indexBox( |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
154 points.get(1), points.get(3), |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
155 I_NAME, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
156 J_NAME); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
157 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
158 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
159 return null; |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
160 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
161 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
162 public static String worldEnvelopeCoordinatesToIndex( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
163 Coordinate [] coords, |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
164 String meshid, |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
165 String ijkQueryID |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
166 ) |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
167 throws QueryException |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
168 { |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
169 List<java.awt.Point> points = |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
170 new ArrayList<java.awt.Point>(coords.length); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
171 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
172 ArrayList<Object []> missingPoints = |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
173 new ArrayList<Object []>(); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
174 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
175 createIJKPoints(coords, meshid, ijkQueryID, points, missingPoints); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
176 |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
177 String additionWhere = null; |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
178 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
179 if (missingPoints.size() == coords.length) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
180 log.debug("cannot create index buffer"); |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
181 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
182 else { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
183 additionWhere = diagonalBox(points); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
184 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
185 if (additionWhere == null) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
186 // 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
|
187 boolean remainsMissingPoints = calculateIJ4MissingPoints( |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
188 coords, points, missingPoints); |
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 (!remainsMissingPoints) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
191 additionWhere = diagonalBox(points); |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
192 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
193 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
194 } |
471
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 return additionWhere != null |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
197 ? additionWhere |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
198 : TRUE_EXPRESSION; |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
199 } |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
200 |
423
2402173a1490
Moved some methods back to old place.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
420
diff
changeset
|
201 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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 ) |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
207 throws QueryException |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
208 { |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
209 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
|
210 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
211 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
|
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); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
214 |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
215 String additionWhere = TRUE_EXPRESSION; |
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"); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
219 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
220 else { // generate index filter |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
221 boolean remainsMissingPoints = calculateIJ4MissingPoints( |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
222 coords, points, missingPoints); |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
223 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
224 if (!remainsMissingPoints) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
225 // 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
|
226 IndexBuffer ib = new IndexBuffer( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
227 points, |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
228 I_NAME, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
229 J_NAME ); |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
230 additionWhere = ib.toWhereClause(); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
231 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
|
232 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
233 } // 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
|
234 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
235 return additionWhere; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
236 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
237 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
238 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
239 /** |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
240 * @param coords |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
241 * @param points |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
242 * @param missingPoints |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
243 * @return |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
244 */ |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
245 private static boolean calculateIJ4MissingPoints( |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
246 Coordinate [] coords, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
247 List<java.awt.Point> points, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
248 ArrayList<Object[]> missingPoints |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
249 ) { |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
250 boolean remainsMissingPoints = !missingPoints.isEmpty(); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
251 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
252 if (remainsMissingPoints) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
253 // 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
|
254 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
|
255 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
|
256 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
257 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
|
258 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
|
259 if (p != null) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
260 Coordinate coord = coords[i]; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
261 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
|
262 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
|
263 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
264 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
265 try { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
266 // 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
|
267 // 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
|
268 // 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
|
269 double [] iParams = iFitter.fit( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
270 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
|
271 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
272 double [] jParams = jFitter.fit( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
273 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
|
274 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
275 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
|
276 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
|
277 Coordinate coord = (Coordinate)a[1]; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
278 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
|
279 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
|
280 points.set( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
281 ((Integer)a[0]).intValue(), |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
282 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
|
283 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
284 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
285 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
|
286 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
287 catch (FunctionEvaluationException fee) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
288 log.error(fee); |
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 catch (OptimizationException oe) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
291 log.error(oe); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
292 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
293 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
294 return remainsMissingPoints; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
295 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
296 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
297 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
298 /** |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
299 * @param coords |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
300 * @param meshid |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
301 * @param ijkQueryID |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
302 * @param points |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
303 * @param missingPoints |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
304 * @throws QueryException |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
305 */ |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
306 private static void createIJKPoints( |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
307 Coordinate[] coords, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
308 String meshid, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
309 String ijkQueryID, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
310 List<java.awt.Point> points, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
311 ArrayList<Object []> missingPoints |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
312 ) |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
313 throws QueryException |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
314 { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
315 boolean debug = log.isDebugEnabled(); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
316 |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
317 QueryExecutor queryExecutor = QueryExecutorFactory |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
318 .getInstance() |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
319 .getQueryExecutor(); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
440
diff
changeset
|
320 |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
321 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
|
322 |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
323 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
|
324 |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
325 Collection<Result> result = queryExecutor.executeQuery( |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
326 ijkQueryID, |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
327 new String [] {meshid, wkt}); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
328 |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
329 if (!result.isEmpty()) { |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
330 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
|
331 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
|
332 int jPos = resultValue.getInteger(0); |
471
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
333 if (debug) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
334 log.debug("Found Pos "+iPos+"/"+jPos +" for "+wkt); |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
335 } |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
336 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
|
337 } |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
338 else { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
339 if (debug) { |
06887e2e3f7a
Some minor code cleanup
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
468
diff
changeset
|
340 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
|
341 } |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
342 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
|
343 points.add(i, null); |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
344 // 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
|
345 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
346 } |
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
347 } |
440
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
348 |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
349 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
|
350 try { |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
351 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
|
352 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
|
353 } |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
354 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
|
355 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
|
356 } |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
357 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
|
358 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
|
359 } |
eb2ac62e853a
Cleaned up messy code a bit in "Horizontales Schnittprofil" and "Profilschnitt".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
423
diff
changeset
|
360 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
|
361 } |
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
|
362 |
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
|
363 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
|
364 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
|
365 } |
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
|
366 |
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
|
367 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
|
368 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
|
369 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
|
370 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
|
371 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
|
372 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
|
373 |
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
|
374 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
|
375 |
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
|
376 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
|
377 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
|
378 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
|
379 } |
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
|
380 |
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
|
381 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
|
382 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
|
383 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
|
384 } |
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
|
385 |
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
|
386 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
|
387 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
|
388 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
|
389 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
|
390 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
|
391 ); |
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
|
392 |
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
|
393 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
|
394 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
|
395 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
|
396 |
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
|
397 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
|
398 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
|
399 |
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 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
|
401 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
|
402 |
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
|
403 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
|
404 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
|
405 |
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
|
406 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
|
407 |
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 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
|
409 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
|
410 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
|
411 }; |
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
|
412 |
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
|
413 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
|
414 |
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
|
415 } |
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
|
416 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
|
417 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
|
418 } |
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
|
419 |
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
|
420 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
|
421 } |
420
c6a287398379
Outsourcing of some methods for preparing results for chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
422 } |