Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/CoordinateSelectionState.java @ 796:a5526908f92f
Added javadoc in state package.
gnv-artifacts/trunk@878 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 01 Apr 2010 09:15:36 +0000 |
parents | c4156275c1e1 |
children | 22c18083225e |
comparison
equal
deleted
inserted
replaced
795:cdade5005cba | 796:a5526908f92f |
---|---|
28 import org.w3c.dom.Element; | 28 import org.w3c.dom.Element; |
29 import org.w3c.dom.Node; | 29 import org.w3c.dom.Node; |
30 import org.w3c.dom.NodeList; | 30 import org.w3c.dom.NodeList; |
31 | 31 |
32 /** | 32 /** |
33 * This state handles coordinate input by the user. It searches database results | |
34 * for coordinates and turns them into a human readable form. | |
35 * | |
33 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> | 36 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> |
34 * | 37 * |
35 */ | 38 */ |
36 public class CoordinateSelectionState extends StateBase { | 39 public class CoordinateSelectionState extends StateBase { |
37 | 40 |
78 describeData.add(keyValueDescibeData); | 81 describeData.add(keyValueDescibeData); |
79 return describeData; | 82 return describeData; |
80 } | 83 } |
81 | 84 |
82 /** | 85 /** |
83 * @see de.intevation.gnv.state.StateBase#prepareInputData4RegionDBQuery(java.lang.String) | 86 * @param value |
87 * @return | |
84 */ | 88 */ |
85 @Override | 89 @Override |
86 protected String prepareInputData4RegionDBQuery(String value) { | 90 protected String prepareInputData4RegionDBQuery(String value) { |
87 log.debug("CoordinateSelectionState.prepareInputData4RegionDBQuery"); | 91 log.debug("CoordinateSelectionState.prepareInputData4RegionDBQuery"); |
88 double distance=0.; | 92 double distance=0.; |
89 String returnValue = null; | 93 String returnValue = null; |
90 try { | 94 try { |
91 Point center = new InputValidator().getPointValue(value); | 95 @SuppressWarnings("static-access") |
96 Point center = InputValidator.getPointValue(value); | |
92 String meshId = super.inputData.get("meshid").getValue(); | 97 String meshId = super.inputData.get("meshid").getValue(); |
93 int segments = 97; | 98 int segments = 97; |
94 if (meshWidths != null){ | 99 if (meshWidths != null){ |
95 Double distanceValue = this.meshWidths.get(meshId); | 100 Double distanceValue = this.meshWidths.get(meshId); |
96 if (distanceValue != null){ | 101 if (distanceValue != null){ |
111 return returnValue; | 116 return returnValue; |
112 | 117 |
113 } | 118 } |
114 | 119 |
115 /** | 120 /** |
116 * @see de.intevation.gnv.state.StateBase#extractKVP(java.util.Collection, java.lang.String, java.lang.String) | 121 * @param valueid |
122 * @param keyid | |
117 */ | 123 */ |
118 @Override | 124 @Override |
119 protected NamedCollection<KeyValueDescibeData> extractKVP( | 125 protected NamedCollection<KeyValueDescibeData> extractKVP( |
120 Collection<Result> result, | 126 Collection<Result> result, |
121 String keyid, | 127 String keyid, |
127 String prevKey = null; | 133 String prevKey = null; |
128 while (rit.hasNext()) { | 134 while (rit.hasNext()) { |
129 Result resultValue = rit.next(); | 135 Result resultValue = rit.next(); |
130 String key = resultValue.getString(keyid); | 136 String key = resultValue.getString(keyid); |
131 if(prevKey == null || !prevKey.equals(key)){ // TODO: FIXME: We have to do that because the arcsde does not support a distinct Query on Layers | 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 |
132 String geomString = this.convert2DisplayCoordinate(resultValue.getString(valueid)); | 138 @SuppressWarnings("static-access") |
139 String geomString = CoordinateSelectionState.convert2DisplayCoordinate(resultValue.getString(valueid)); | |
133 String value = geomString; | 140 String value = geomString; |
134 if (resultValue.getResultDescriptor().getColumnIndex("VALUE") > 0){ | 141 if (resultValue.getResultDescriptor().getColumnIndex("VALUE") > 0){ |
135 value = resultValue.getString("VALUE") + " - "+value; | 142 value = resultValue.getString("VALUE") + " - "+value; |
136 } | 143 } |
137 | 144 |
141 prevKey = key; | 148 prevKey = key; |
142 } | 149 } |
143 return keyValueDescibeData; | 150 return keyValueDescibeData; |
144 } | 151 } |
145 | 152 |
153 /** | |
154 * Turn coordinate into a human readable format. | |
155 * | |
156 * @param wkt Coordinate as wkt string. | |
157 * @return formatted coordinate. | |
158 */ | |
146 protected static String convert2DisplayCoordinate(String wkt){ | 159 protected static String convert2DisplayCoordinate(String wkt){ |
147 return WKTUtils.toText(wkt); | 160 return WKTUtils.toText(wkt); |
148 } | 161 } |
149 | 162 |
150 /** | 163 /** |
151 * @see de.intevation.gnv.state.StateBase#setup(org.w3c.dom.Node) | 164 * @param configuration |
152 */ | 165 */ |
153 @Override | 166 @Override |
154 public void setup(Node configuration) { | 167 public void setup(Node configuration) { |
155 super.setup(configuration); | 168 super.setup(configuration); |
156 Element widthElement = (Element)Config.getNodeXPath(configuration, MESH_WIDTH_XPATH); | 169 Element widthElement = (Element)Config.getNodeXPath(configuration, MESH_WIDTH_XPATH); |
172 }else{ | 185 }else{ |
173 log.warn("No Mesh Width defined."); | 186 log.warn("No Mesh Width defined."); |
174 } | 187 } |
175 } | 188 } |
176 } | 189 } |
190 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |