diff --git a/src/load_map.cpp b/src/load_map.cpp index 87095ceba..c2fcaeec6 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -894,7 +894,16 @@ void map_parser::parse_text_symbolizer( rule_type & rule, ptree const & sym ) { try { - std::string name = get_attr(sym, "name"); + std::string name; + // mapnik2 forward compatibility + optional old_name = get_opt_attr(sym, "name"); + if (old_name) { + //std::clog << ": ### WARNING: Using 'name' in TextSymbolizer is deprecated (http://trac.mapnik.org/wiki/TextSymbolizer)\n"; + name = *old_name; + } else { + name = get_own(sym, "TextSymbolizer"); + if (name.empty()) throw config_error(std::string("TextSymbolizer needs a non-empty text")); + } // mapnik2 forward compatibility if (boost::algorithm::istarts_with(name,"[") && boost::algorithm::iends_with(name,"]")) @@ -1118,7 +1127,18 @@ void map_parser::parse_shield_symbolizer( rule_type & rule, ptree const & sym ) { try { - std::string name = get_attr(sym, "name"); + // mapnik2 forward compatibility + std::string name; + optional old_name = get_opt_attr(sym, "name"); + optional no_text = get_opt_attr(sym, "no-text"); + if (old_name) { + //std::clog << ": ### WARNING: Using 'name' in ShieldSymbolizer is deprecated (http://trac.mapnik.org/wiki/TextSymbolizer)\n"; + name = *old_name; + } else { + name = get_own(sym, "ShieldSymbolizer"); + if (name.empty() && (!no_text || !*no_text) ) throw config_error(std::string("ShieldSymbolizer needs a non-empty text")); + if (name.empty()) throw config_error(std::string("ShieldSymbolizer needs a non-empty text")); + } // mapnik2 forward compatibility if (boost::algorithm::istarts_with(name,"[") && boost::algorithm::iends_with(name,"]")) @@ -1341,8 +1361,6 @@ void map_parser::parse_shield_symbolizer( rule_type & rule, ptree const & sym ) } // no text - optional no_text = - get_opt_attr(sym, "no_text", "no-text"); if (no_text) { shield_symbol.set_no_text( * no_text ); diff --git a/src/save_map.cpp b/src/save_map.cpp index e08352a53..f5ffef046 100644 --- a/src/save_map.cpp +++ b/src/save_map.cpp @@ -249,7 +249,10 @@ namespace mapnik { const std::string & name = sym.get_name(); if ( ! name.empty() ) { - set_attr( node, "name", name ); + //set_attr( node, "name", name ); + // mapnik2 forward compatibility + ptree& text_node = node.push_back(ptree::value_type("", ptree()))->second; + text_node.put_own(name); } const std::string & face_name = sym.get_face_name(); if ( ! face_name.empty() ) {