Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/CoordinateSelectionState.java @ 799:feeaf5aec552
ISSUE213: Wrong Geometrytype used for the generation of an Layer with Multipolygon-Geometries
gnv-artifacts/trunk@881 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 06 Apr 2010 11:56:53 +0000 |
parents | a5526908f92f |
children | 22c18083225e |
rev | line source |
---|---|
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.gnv.state; |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
2 |
779
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
3 import com.vividsolutions.jts.geom.Point; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
4 |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
5 import de.intevation.artifactdatabase.Config; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
6 |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
7 import de.intevation.gnv.geobackend.base.Result; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
8 |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
9 import de.intevation.gnv.state.describedata.DefaultKeyValueDescribeData; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
10 import de.intevation.gnv.state.describedata.KeyValueDescibeData; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
11 import de.intevation.gnv.state.describedata.NamedArrayList; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
12 import de.intevation.gnv.state.describedata.NamedCollection; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
13 |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
14 import de.intevation.gnv.utils.ArtifactXMLUtilities; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
15 import de.intevation.gnv.utils.InputValidator; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
16 import de.intevation.gnv.utils.WKTUtils; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
17 |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
18 import de.intevation.gnv.utils.exception.ValidationException; |
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
19 |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
20 import java.util.ArrayList; |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
21 import java.util.Collection; |
511
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
22 import java.util.HashMap; |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
23 import java.util.Iterator; |
470
b7bb66440cc8
Added mechanism for advancing to previous states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
461
diff
changeset
|
24 import java.util.List; |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
25 |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
26 import org.apache.log4j.Logger; |
779
b1f5f2a8840f
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
27 |
511
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
28 import org.w3c.dom.Element; |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
29 import org.w3c.dom.Node; |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
30 import org.w3c.dom.NodeList; |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
31 |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
32 /** |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
33 * This state handles coordinate input by the user. It searches database results |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
34 * for coordinates and turns them into a human readable form. |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
35 * |
780
c4156275c1e1
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
779
diff
changeset
|
36 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
37 * |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
38 */ |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
39 public class CoordinateSelectionState extends StateBase { |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
40 |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
41 /** |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
42 * the logger, used to log exceptions and additonaly information |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
43 */ |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
44 private static Logger log = Logger.getLogger(CoordinateSelectionState.class); |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
607
diff
changeset
|
45 |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
46 /** |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
47 * The UID of this Class |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
48 */ |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
49 private static final long serialVersionUID = 6318923553625195063L; |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
607
diff
changeset
|
50 |
511
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
51 /** |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
52 * XPATH Expressions for the setup. |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
53 */ |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
607
diff
changeset
|
54 |
511
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
55 private final static String MESH_WIDTH_XPATH = "mesh-width"; |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
56 private final static String XLINK_XPATH = "xlink:href"; |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
57 private final static String MESH_LIST_XPATH = "/mesh-widths/mesh"; |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
58 private final static String ID_XPATH = "id"; |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
59 private final static String WIDTH_VALUE_XPATH = "width"; |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
607
diff
changeset
|
60 |
511
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
61 /** |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
62 * Holds all given Widths between two MeshPoints for different Meshes. |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
63 */ |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
64 private HashMap<String, Double> meshWidths = null; |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
65 |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
66 /** |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
67 * Constructor |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
68 */ |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
69 public CoordinateSelectionState() { |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
70 super(); |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
71 } |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
72 |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
73 @Override |
607
292fbcd5e9ac
Parted the cache blob into pieces and changed the way how user input is stored on each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
511
diff
changeset
|
74 protected List<Object> purifyResult(Collection<Result> result, String uuid) { |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
75 log.debug("CoordinateSelectionState.purifyResult"); |
607
292fbcd5e9ac
Parted the cache blob into pieces and changed the way how user input is stored on each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
511
diff
changeset
|
76 List<Object> describeData = new ArrayList<Object>(); |
292fbcd5e9ac
Parted the cache blob into pieces and changed the way how user input is stored on each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
511
diff
changeset
|
77 |
292fbcd5e9ac
Parted the cache blob into pieces and changed the way how user input is stored on each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
511
diff
changeset
|
78 NamedCollection<KeyValueDescibeData> keyValueDescibeData = |
292fbcd5e9ac
Parted the cache blob into pieces and changed the way how user input is stored on each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
511
diff
changeset
|
79 extractKVP(result, "FEATUREID", "SHAPE"); |
292fbcd5e9ac
Parted the cache blob into pieces and changed the way how user input is stored on each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
511
diff
changeset
|
80 |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
81 describeData.add(keyValueDescibeData); |
607
292fbcd5e9ac
Parted the cache blob into pieces and changed the way how user input is stored on each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
511
diff
changeset
|
82 return describeData; |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
83 } |
607
292fbcd5e9ac
Parted the cache blob into pieces and changed the way how user input is stored on each state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
511
diff
changeset
|
84 |
511
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
85 /** |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
86 * @param value |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
87 * @return |
511
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
88 */ |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
89 @Override |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
90 protected String prepareInputData4RegionDBQuery(String value) { |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
91 log.debug("CoordinateSelectionState.prepareInputData4RegionDBQuery"); |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
92 double distance=0.; |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
93 String returnValue = null; |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
94 try { |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
95 @SuppressWarnings("static-access") |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
96 Point center = InputValidator.getPointValue(value); |
511
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
97 String meshId = super.inputData.get("meshid").getValue(); |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
98 int segments = 97; |
511
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
99 if (meshWidths != null){ |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
100 Double distanceValue = this.meshWidths.get(meshId); |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
101 if (distanceValue != null){ |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
102 log.debug("User "+distanceValue+" as Buffer around given Point"); |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
103 distance = distanceValue.doubleValue(); |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
104 }else{ |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
105 log.warn("No distance is configured for Mesh with id"+ meshId); |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
106 } |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
107 }else{ |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
108 log.warn("No MeshWidth configured. Check if this is correct."); |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
109 } |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
110 returnValue = center.buffer(distance,segments).toText(); |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
111 } catch (NumberFormatException e) { |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
112 log.error(e,e); |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
113 } catch (ValidationException e) { |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
114 log.error(e,e); |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
115 } |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
116 return returnValue; |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
607
diff
changeset
|
117 |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
118 } |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
607
diff
changeset
|
119 |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
120 /** |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
121 * @param valueid |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
122 * @param keyid |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
123 */ |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
124 @Override |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
125 protected NamedCollection<KeyValueDescibeData> extractKVP( |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
126 Collection<Result> result, |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
127 String keyid, |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
128 String valueid) { |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
129 Iterator<Result> rit = result.iterator(); |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
130 NamedCollection<KeyValueDescibeData> keyValueDescibeData = new NamedArrayList<KeyValueDescibeData>( |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
131 this.dataName, result.size()); |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
132 keyValueDescibeData.setMultiSelect(this.dataMultiSelect); |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
133 String prevKey = null; |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
134 while (rit.hasNext()) { |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
135 Result resultValue = rit.next(); |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
136 String key = resultValue.getString(keyid); |
461
3ddc22aab764
Removed Encodingerrors from listed Files. All Files are now UTF-8 compliant.
Tim Englich <tim.englich@intevation.de>
parents:
335
diff
changeset
|
137 if(prevKey == null || !prevKey.equals(key)){ // TODO: FIXME: We have to do that because the arcsde does not support a distinct Query on Layers |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
138 @SuppressWarnings("static-access") |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
139 String geomString = CoordinateSelectionState.convert2DisplayCoordinate(resultValue.getString(valueid)); |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
140 String value = geomString; |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
141 if (resultValue.getResultDescriptor().getColumnIndex("VALUE") > 0){ |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
142 value = resultValue.getString("VALUE") + " - "+value; |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
143 } |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
607
diff
changeset
|
144 |
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
607
diff
changeset
|
145 |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
146 keyValueDescibeData.add(new DefaultKeyValueDescribeData(key,value )); |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
147 } |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
148 prevKey = key; |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
149 } |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
150 return keyValueDescibeData; |
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
151 } |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
607
diff
changeset
|
152 |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
153 /** |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
154 * Turn coordinate into a human readable format. |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
155 * |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
156 * @param wkt Coordinate as wkt string. |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
157 * @return formatted coordinate. |
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
158 */ |
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:
470
diff
changeset
|
159 protected static String convert2DisplayCoordinate(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:
470
diff
changeset
|
160 return WKTUtils.toText(wkt); |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
161 } |
511
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
162 |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
163 /** |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
164 * @param configuration |
511
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
165 */ |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
166 @Override |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
167 public void setup(Node configuration) { |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
168 super.setup(configuration); |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
169 Element widthElement = (Element)Config.getNodeXPath(configuration, MESH_WIDTH_XPATH); |
778
9a828e5a2390
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
607
diff
changeset
|
170 |
511
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
171 if (widthElement != null){ |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
172 String fileName = widthElement.getAttribute(XLINK_XPATH); |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
173 fileName = Config.replaceConfigDir(fileName); |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
174 Node configurationNode = new ArtifactXMLUtilities().readConfiguration(fileName); |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
175 NodeList meshNodes = Config.getNodeSetXPath(configurationNode,MESH_LIST_XPATH ); |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
176 if (meshNodes != null){ |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
177 meshWidths = new HashMap<String, Double>(meshNodes.getLength()); |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
178 for (int i = 0; i < meshNodes.getLength(); i++){ |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
179 Element meshNode = (Element)meshNodes.item(i); |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
180 String id = meshNode.getAttribute(ID_XPATH); |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
181 Double value = Double.parseDouble(meshNode.getAttribute(WIDTH_VALUE_XPATH)); |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
182 meshWidths.put(id, value); |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
183 } |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
184 } |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
185 }else{ |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
186 log.warn("No Mesh Width defined."); |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
187 } |
c5ed4ea8fb64
Make the mean with of an Mesh configurable issue93
Tim Englich <tim.englich@intevation.de>
parents:
507
diff
changeset
|
188 } |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
189 } |
796
a5526908f92f
Added javadoc in state package.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
780
diff
changeset
|
190 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |