Mercurial > mxd2map
changeset 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 |
files | ChangeLog src/java/de/intevation/mxd/writer/MapScriptWriter.java |
diffstat | 2 files changed, 30 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Jul 20 12:40:11 2011 +0200 +++ b/ChangeLog Wed Jul 20 15:55:43 2011 +0200 @@ -1,3 +1,10 @@ +2011-07-20 Raimund Renkert <raimund.renkert@intevation.de> + + * src/java/de/intevation/mxd/writer/MapScriptWriter.java: + Added string manipulator that replaces german umlauts and trims a + string. + Use this validator for mapserver relevant names and strings. + 2011-07-20 Raimund Renkert <raimund.renkert@intevation.de> * src/java/de/intevation/mxd/reader/MapScriptWriter.java:
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java Wed Jul 20 12:40:11 2011 +0200 +++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java Wed Jul 20 15:55:43 2011 +0200 @@ -194,11 +194,12 @@ //The layer name. String lname = layerElement.getAttribute("name"); lname = lname.replaceAll(" ", ""); - layer.setName(lname); + layer.setName(validateString(lname)); layer.setUnits(units.swigValue()); - layer.setMetaData("wms_title", layerElement.getAttribute("name")); + layer.setMetaData("wms_title", validateString(lname)); if(layerElement.hasAttribute("group")) { - layer.setGroup(layerElement.getAttribute("group")); + String group = layerElement.getAttribute("group"); + layer.setGroup(validateString(group)); } //The layer status. @@ -332,8 +333,10 @@ Element classElement = (Element)list.item(i); classObj co = new classObj(layer); String name = classElement.getAttribute("label"); + name = validateString(name); if (name.equals("")) { name = layerElement.getAttribute("name"); + name = validateString(name); if (list.getLength() > 1) { name += "-" + i; } @@ -558,4 +561,21 @@ } return expression; } + + /** + * Replaces german umlauts and removes leading and trailing whitespaces. + * + * @param s String + */ + private String validateString (String s) { + if (s.equals("")) { + return ""; + } + String tmp = s.trim(); + tmp = tmp.replace ("ö", "oe"); + tmp = tmp.replace ("ä", "ae"); + tmp = tmp.replace ("ü", "ue"); + tmp = tmp.replace ("ß", "ss"); + return tmp; + } }