comparison src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 127:5ba8bf865dc7

Write expressions for string values to the mapfile.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 20 Jun 2011 11:35:40 +0200
parents ff0354265a7d
children 1616622a8c8d
comparison
equal deleted inserted replaced
126:ff0354265a7d 127:5ba8bf865dc7
224 Double.parseDouble(classElement.getAttribute("value")); 224 Double.parseDouble(classElement.getAttribute("value"));
225 type = 1; 225 type = 1;
226 } 226 }
227 catch(Exception e) { 227 catch(Exception e) {
228 type = 2; 228 type = 2;
229 logger.info("not a double");
230 } 229 }
231 if (type == 1) { 230 if (type == 1) {
232 co.setExpression(createDoubleExpression(classElement, count)); 231 co.setExpression(createDoubleExpression(classElement, count));
233 } 232 }
233 else if (type == 2) {
234 co.setExpression(createStringExpression(classElement, count));
235 }
236
234 } 237 }
235 //Write symbols and styles. 238 //Write symbols and styles.
236 NodeList l = classElement.getChildNodes(); 239 NodeList l = classElement.getChildNodes();
237 for (int j = 0; j < l.getLength(); j++) { 240 for (int j = 0; j < l.getLength(); j++) {
238 Element elem = (Element)l.item(j); 241 Element elem = (Element)l.item(j);
284 exp += classElement.getAttribute("value"); 287 exp += classElement.getAttribute("value");
285 exp += ")"; 288 exp += ")";
286 } 289 }
287 } 290 }
288 } 291 }
289 else if (op.equals("==")) { 292 else if (op.equals("=")) {
290 op1 = op; 293 op1 = op;
291 for(int j = 0; j < count; j++) { 294 for(int j = 0; j < count; j++) {
292 exp = "([" + 295 exp = "([" +
293 classElement.getAttribute("expression_field_" + j) + 296 classElement.getAttribute("expression_field_" + j) +
294 "] == " + 297 "] == " +
295 classElement.getAttribute("value") + ")"; 298 classElement.getAttribute("value") + ")";
296 } 299 }
297 } 300 }
298 return exp; 301 return exp;
299 } 302 }
303
304 private String createStringExpression (Element classElement, int count) {
305 String exp = "";
306 String op = classElement.getAttribute("expression_operator");
307 if (op.equals("=")) {
308 for(int j = 0; j < count; j++) {
309 exp = "(\"[";
310 exp += classElement.getAttribute(
311 "expression_field_" + j);
312 exp += "]\" " + op;
313 exp += " \"" + classElement.getAttribute("value");
314 exp += "\")";
315 }
316 }
317 return exp;
318 }
300 } 319 }
301 320
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)