comparison src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 244:276f63c86f1c

Refactored group layer handling and "wms_title" metadata.
author raimund renkert <raimund.renkert@intevation.de>
date Tue, 09 Aug 2011 17:27:18 +0200
parents df4e0946ef02
children 2eeeae07aaa2
comparison
equal deleted inserted replaced
243:df4e0946ef02 244:276f63c86f1c
219 219
220 //The layer name. 220 //The layer name.
221 String group = ""; 221 String group = "";
222 if(layerElement.hasAttribute("group")) { 222 if(layerElement.hasAttribute("group")) {
223 group = layerElement.getAttribute("group"); 223 group = layerElement.getAttribute("group");
224 group = validateString(group); 224 String[] splitted = group.split("/");
225 group = group.replaceAll (" ", ""); 225 String cleangroup = "";
226 layer.setGroup(group); 226 for(int j = 0; j < splitted.length; j++) {
227 group = group + "."; 227 if(!splitted[j].equals("")) {
228 cleangroup += "/" + validateLayerName(splitted[j]);
229 }
230 }
231 group = cleangroup;
228 } 232 }
229 String lname = layerElement.getAttribute("name"); 233 String lname = layerElement.getAttribute("name");
230 lname = lname.replaceAll(" ", ""); 234 lname = validateLayerName(lname);
231 lname = group + lname; 235 String ulname = group.replaceAll("/", ".") + "." + lname;
232 layer.setName(validateString(lname)); 236 if(ulname.startsWith(".")) {
237 ulname = ulname.substring(1);
238 }
239 layer.setName(ulname);
233 layer.setUnits(units.swigValue()); 240 layer.setUnits(units.swigValue());
234 layer.setMetaData("wms_title", validateString(lname)); 241 if(!group.equals("")) {
235 242 layer.setMetaData("wms_title", group + "/" + lname);
243 }
244 else {
245 layer.setMetaData("wms_title", lname);
246 }
236 247
237 //The layer status. 248 //The layer status.
238 String stat = layerElement.getAttribute("status"); 249 String stat = layerElement.getAttribute("status");
239 if (stat.equals("on")) { 250 if (stat.equals("on")) {
240 layer.setStatus(1); 251 layer.setStatus(1);
628 String tmp = s.trim(); 639 String tmp = s.trim();
629 tmp = tmp.replace ("ö", "oe"); 640 tmp = tmp.replace ("ö", "oe");
630 tmp = tmp.replace ("ä", "ae"); 641 tmp = tmp.replace ("ä", "ae");
631 tmp = tmp.replace ("ü", "ue"); 642 tmp = tmp.replace ("ü", "ue");
632 tmp = tmp.replace ("ß", "ss"); 643 tmp = tmp.replace ("ß", "ss");
633 tmp = tmp.replace ("/", "");
634 tmp = tmp.replace (",", "");
635 if(!s.equals(tmp)) { 644 if(!s.equals(tmp)) {
636 logger.info("Renamed \"" + s + "\" to \"" + tmp + "\"."); 645 logger.info("Renamed \"" + s + "\" to \"" + tmp + "\".");
637 } 646 }
638 return tmp; 647 return tmp;
639 } 648 }
649
650
651 /**
652 * Replaces special characters and removes leading and trailing whitespaces.
653 *
654 * @param s String
655 *
656 * @return the input string without special chars.
657 */
658 private String validateLayerName (String s) {
659 if(s.equals("")) {
660 return "";
661 }
662
663 String tmp = s.trim();
664 tmp = tmp.replace(" ", "");
665 tmp = tmp.replace("/", "");
666 tmp = tmp.replace(",", "");
667 tmp = tmp.replace("#", "");
668 tmp = tmp.replace("+", "");
669 tmp = tmp.replace("~", "");
670 tmp = tmp.replace("(", "");
671 tmp = tmp.replace(")", "");
672 tmp = tmp.replace("{", "");
673 tmp = tmp.replace("}", "");
674 tmp = tmp.replace("[", "");
675 tmp = tmp.replace("]", "");
676 tmp = tmp.replace("<", "");
677 tmp = tmp.replace(">", "");
678 tmp = tmp.replace("*", "");
679 tmp = tmp.replace("\\\\", "");
680 tmp = tmp.replace("^", "");
681 if(!s.equals(tmp)) {
682 logger.info("Renamed \"" + s +"\" to \"" + tmp +"\".");
683 }
684 return tmp;
685 }
640 } 686 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)