Mercurial > mxd2map
comparison src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 189:0965f8af70fa
Replace german umlauts and trim strings.
author | raimund renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 20 Jul 2011 15:55:43 +0200 |
parents | 1391f911ee39 |
children | c640fb351f66 |
comparison
equal
deleted
inserted
replaced
186:1391f911ee39 | 189:0965f8af70fa |
---|---|
192 layerObj layer = new layerObj(map); | 192 layerObj layer = new layerObj(map); |
193 | 193 |
194 //The layer name. | 194 //The layer name. |
195 String lname = layerElement.getAttribute("name"); | 195 String lname = layerElement.getAttribute("name"); |
196 lname = lname.replaceAll(" ", ""); | 196 lname = lname.replaceAll(" ", ""); |
197 layer.setName(lname); | 197 layer.setName(validateString(lname)); |
198 layer.setUnits(units.swigValue()); | 198 layer.setUnits(units.swigValue()); |
199 layer.setMetaData("wms_title", layerElement.getAttribute("name")); | 199 layer.setMetaData("wms_title", validateString(lname)); |
200 if(layerElement.hasAttribute("group")) { | 200 if(layerElement.hasAttribute("group")) { |
201 layer.setGroup(layerElement.getAttribute("group")); | 201 String group = layerElement.getAttribute("group"); |
202 layer.setGroup(validateString(group)); | |
202 } | 203 } |
203 | 204 |
204 //The layer status. | 205 //The layer status. |
205 String stat = layerElement.getAttribute("status"); | 206 String stat = layerElement.getAttribute("status"); |
206 if (stat.equals("on")) { | 207 if (stat.equals("on")) { |
330 //each class. | 331 //each class. |
331 for(int i = 0; i < list.getLength(); i++) { | 332 for(int i = 0; i < list.getLength(); i++) { |
332 Element classElement = (Element)list.item(i); | 333 Element classElement = (Element)list.item(i); |
333 classObj co = new classObj(layer); | 334 classObj co = new classObj(layer); |
334 String name = classElement.getAttribute("label"); | 335 String name = classElement.getAttribute("label"); |
336 name = validateString(name); | |
335 if (name.equals("")) { | 337 if (name.equals("")) { |
336 name = layerElement.getAttribute("name"); | 338 name = layerElement.getAttribute("name"); |
339 name = validateString(name); | |
337 if (list.getLength() > 1) { | 340 if (list.getLength() > 1) { |
338 name += "-" + i; | 341 name += "-" + i; |
339 } | 342 } |
340 } | 343 } |
341 co.setName (name); | 344 co.setName (name); |
556 } | 559 } |
557 } | 560 } |
558 } | 561 } |
559 return expression; | 562 return expression; |
560 } | 563 } |
564 | |
565 /** | |
566 * Replaces german umlauts and removes leading and trailing whitespaces. | |
567 * | |
568 * @param s String | |
569 */ | |
570 private String validateString (String s) { | |
571 if (s.equals("")) { | |
572 return ""; | |
573 } | |
574 String tmp = s.trim(); | |
575 tmp = tmp.replace ("ö", "oe"); | |
576 tmp = tmp.replace ("ä", "ae"); | |
577 tmp = tmp.replace ("ü", "ue"); | |
578 tmp = tmp.replace ("ß", "ss"); | |
579 return tmp; | |
580 } | |
561 } | 581 } |