From ad2250a4b511f169d85ec86d792f39f2d02cb968 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Thu, 16 Aug 2012 19:20:29 -0700 Subject: [PATCH] back compatibility for raster-mode values using _ and shield-no-text --- bindings/python/python_grid_utils.cpp | 65 --------------------------- src/load_map.cpp | 22 ++++++++- tests/data/good_maps/raster-alpha.xml | 2 +- 3 files changed, 22 insertions(+), 67 deletions(-) diff --git a/bindings/python/python_grid_utils.cpp b/bindings/python/python_grid_utils.cpp index b1b5fa393..9652a4bce 100644 --- a/bindings/python/python_grid_utils.cpp +++ b/bindings/python/python_grid_utils.cpp @@ -275,71 +275,6 @@ void write_features(T const& grid_type, feature_data[feat_itr->first] = feat; } } -/* std::string const& key = grid_type.get_key(); - std::set const& attributes = grid_type.property_names(); - typename T::feature_type::const_iterator feat_itr = g_features.begin(); - typename T::feature_type::const_iterator feat_end = g_features.end(); - bool include_key = (attributes.find(key) != attributes.end()); - for (; feat_itr != feat_end; ++feat_itr) - { - mapnik::feature_ptr feature = feat_itr->second; - boost::optional join_value; - if (key == grid_type.key_name()) - { - join_value = feat_itr->first; - } - else if (feature->has_key(key)) - { - join_value = feature->get(key).to_string(); - } - - if (join_value) - { - // only serialize features visible in the grid - if(std::find(key_order.begin(), key_order.end(), *join_value) != key_order.end()) { - boost::python::dict feat; - bool found = false; - if (key == grid_type.key_name()) - { - // drop key unless requested - if (include_key) { - found = true; - //TODO - add __id__ as data key? - //feat[key] = *join_value; - } - } - - feature_kv_iterator itr = feature->begin(); - feature_kv_iterator end = feature->end(); - for ( ;itr!=end; ++itr) - { - std::string const& key_name = boost::get<0>(*itr); - if (key_name == key) { - // drop key unless requested - if (include_key) { - found = true; - feat[key_name] = boost::get<1>(*itr); - } - } - else if ( (attributes.find(key_name) != attributes.end()) ) - { - found = true; - feat[key_name] = boost::get<1>(*itr); - } - } - - if (found) - { - feature_data[feat_itr->first] = feat; - } - } - } - else - { - MAPNIK_LOG_DEBUG(bindings) << "write_features: Should not get here: key " << key << " not found in grid feature properties"; - } - } -*/ } template diff --git a/src/load_map.cpp b/src/load_map.cpp index b00b1564f..a0288ad87 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -1242,6 +1242,17 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym) } } + // no_text - removed property in 2.1.x that used to have a purpose + // before you could provide an expression with an empty string + optional no_text = + sym.get_opt_attr("no-text"); + if (no_text) + { + MAPNIK_LOG_ERROR(raster_symbolizer) << "'no-text' is deprecated and will be removed in Mapnik 3.x, to create a ShieldSymbolizer without text just provide an element like: \"' '\""; + if (*no_text) + shield_symbol.set_name(parse_expression("' '")); + } + file = ensure_relative_to_xml(file); path_expression_ptr expr(boost::make_shared()); if (!parse_path_from_string(expr, file, sym.get_tree().path_expr_grammar)) @@ -1431,7 +1442,16 @@ void map_parser::parse_raster_symbolizer(rule & rule, xml_node const & sym) // mode optional mode = sym.get_opt_attr("mode"); - if (mode) raster_sym.set_mode(*mode); + if (mode) + { + std::string mode_string = *mode; + if (boost::algorithm::find_first(mode_string,"_")) + { + MAPNIK_LOG_ERROR(raster_symbolizer) << "'mode' values using \"_\" are deprecated and will be removed in Mapnik 3.x, use \"-\"instead"; + boost::algorithm::replace_all(mode_string,"_","-"); + } + raster_sym.set_mode(mode_string); + } // scaling optional scaling = sym.get_opt_attr("scaling"); diff --git a/tests/data/good_maps/raster-alpha.xml b/tests/data/good_maps/raster-alpha.xml index 9ac1422ca..46fa472e9 100644 --- a/tests/data/good_maps/raster-alpha.xml +++ b/tests/data/good_maps/raster-alpha.xml @@ -4,7 +4,7 @@