Merge pull request #2883 from mapycz/missing-style

better handling of missing styles
This commit is contained in:
Artem Pavlenko 2015-06-03 11:54:06 +01:00
commit a235316573
2 changed files with 21 additions and 1 deletions

View File

@ -361,7 +361,7 @@ void feature_style_processor<Processor>::prepare_layer(layer_rendering_material
boost::optional<feature_type_style const&> 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.";

View File

@ -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<std::string> const& opt_path);
void ensure_exists(std::string const& file_path);
void check_styles(Map const & map) const throw (config_error);
boost::optional<color> get_opt_color_attr(boost::property_tree::ptree const& node,
std::string const& name);
@ -327,6 +328,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)
@ -1684,4 +1689,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