From abf64342f949afc14f77cb5aed0151dacb48c985 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Tue, 2 Jun 2015 12:34:41 +0000 Subject: [PATCH 1/2] raise missing style message to MAPNIK_LOG_ERROR --- include/mapnik/feature_style_processor_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/feature_style_processor_impl.hpp b/include/mapnik/feature_style_processor_impl.hpp index 6e0094ba1..d20e6a501 100644 --- a/include/mapnik/feature_style_processor_impl.hpp +++ b/include/mapnik/feature_style_processor_impl.hpp @@ -361,7 +361,7 @@ void feature_style_processor::prepare_layer(layer_rendering_material boost::optional style=m_.find_style(style_name); if (!style) { - MAPNIK_LOG_DEBUG(feature_style_processor) + MAPNIK_LOG_ERROR(feature_style_processor) << "feature_style_processor: Style=" << style_name << " required for layer=" << lay.name() << " does not exist."; From 27ba7483beb0aaad88718825872a23b756a8bf92 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Wed, 3 Jun 2015 10:36:50 +0000 Subject: [PATCH 2/2] xml loader: throw on missing style for strict parsing --- src/load_map.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/load_map.cpp b/src/load_map.cpp index 75ab4eabf..5c2b4ac61 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -129,6 +129,7 @@ private: void find_unused_nodes_recursive(xml_node const& node, std::string & error_text); std::string ensure_relative_to_xml(boost::optional const& opt_path); void ensure_exists(std::string const& file_path); + void check_styles(Map const & map) const throw (config_error); boost::optional get_opt_color_attr(boost::property_tree::ptree const& node, std::string const& name); @@ -328,6 +329,10 @@ void map_parser::parse_map(Map & map, xml_node const& node, std::string const& b throw config_error("Not a map file. Node 'Map' not found."); } find_unused_nodes(node); + if (strict_) + { + check_styles(map); + } } void map_parser::parse_map_include(Map & map, xml_node const& node) @@ -1685,4 +1690,19 @@ void map_parser::find_unused_nodes_recursive(xml_node const& node, std::string & } } +void map_parser::check_styles(Map const & map) const throw (config_error) +{ + for (auto const & layer : map.layers()) + { + for (auto const & style : layer.styles()) + { + if (!map.find_style(style)) + { + throw config_error("Unable to process some data while parsing '" + filename_ + + "': Style '" + style + "' required for layer '" + layer.name() + "'."); + } + } + } +} + } // end of namespace mapnik