Mercurial > mxd2map
comparison src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 126:ff0354265a7d
Write the correct expression for double values.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 17 Jun 2011 18:22:40 +0200 |
parents | 0f5819732288 |
children | 5ba8bf865dc7 |
comparison
equal
deleted
inserted
replaced
125:69a346c45836 | 126:ff0354265a7d |
---|---|
217 } | 217 } |
218 co.setName (name); | 218 co.setName (name); |
219 if(classElement.hasAttribute("field_count")) { | 219 if(classElement.hasAttribute("field_count")) { |
220 int count = | 220 int count = |
221 Integer.parseInt(classElement.getAttribute("field_count")); | 221 Integer.parseInt(classElement.getAttribute("field_count")); |
222 String exp = ""; | 222 int type = 0; |
223 for(int j = 0; j < count; j++) { | 223 try { |
224 //TODO Find a way to create Expressions. | 224 Double.parseDouble(classElement.getAttribute("value")); |
225 exp = "([" + classElement.getAttribute("expression_field_" + j); | 225 type = 1; |
226 exp += "] " + classElement.getAttribute("expression_operator"); | 226 } |
227 exp += " " + classElement.getAttribute("value") + ")"; | 227 catch(Exception e) { |
228 } | 228 type = 2; |
229 co.setExpression(exp); | 229 logger.info("not a double"); |
230 } | |
231 if (type == 1) { | |
232 co.setExpression(createDoubleExpression(classElement, count)); | |
233 } | |
230 } | 234 } |
231 //Write symbols and styles. | 235 //Write symbols and styles. |
232 NodeList l = classElement.getChildNodes(); | 236 NodeList l = classElement.getChildNodes(); |
233 for (int j = 0; j < l.getLength(); j++) { | 237 for (int j = 0; j < l.getLength(); j++) { |
234 Element elem = (Element)l.item(j); | 238 Element elem = (Element)l.item(j); |
247 swriter.write (elem); | 251 swriter.write (elem); |
248 } | 252 } |
249 } | 253 } |
250 } | 254 } |
251 } | 255 } |
256 | |
257 private String createDoubleExpression (Element classElement, int count) { | |
258 String exp = ""; | |
259 String op = classElement.getAttribute("expression_operator"); | |
260 String op1 = ""; | |
261 String op2 = ""; | |
262 if (op.equals("<=")) { | |
263 op1 = ">="; | |
264 op2 = op; | |
265 for(int j = 0; j < count; j++) { | |
266 if (classElement.getAttribute("min_value").equals( | |
267 classElement.getAttribute("value"))) { | |
268 exp = "([" + | |
269 classElement.getAttribute( | |
270 "expression_field_" + j) + | |
271 "] == " + | |
272 classElement.getAttribute("value") + | |
273 ")"; | |
274 } | |
275 else { | |
276 exp = "(["; | |
277 exp += classElement.getAttribute( | |
278 "expression_field_" + j); | |
279 exp += "] " + op1; | |
280 exp += " " + classElement.getAttribute("min_value"); | |
281 exp += " AND [" + classElement.getAttribute( | |
282 "expression_field_" + j); | |
283 exp += "] " + op2 + " "; | |
284 exp += classElement.getAttribute("value"); | |
285 exp += ")"; | |
286 } | |
287 } | |
288 } | |
289 else if (op.equals("==")) { | |
290 op1 = op; | |
291 for(int j = 0; j < count; j++) { | |
292 exp = "([" + | |
293 classElement.getAttribute("expression_field_" + j) + | |
294 "] == " + | |
295 classElement.getAttribute("value") + ")"; | |
296 } | |
297 } | |
298 return exp; | |
299 } | |
252 } | 300 } |
253 | 301 |