diff --git a/src/load_map.cpp b/src/load_map.cpp index 2ac531718..4495ee19a 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -899,60 +898,44 @@ void map_parser::parse_point_symbolizer(rule & rule, xml_node const & sym) if (file) { - try + if(base) { - if(base) + std::map::const_iterator itr = file_sources_.find(*base); + if (itr!=file_sources_.end()) { - std::map::const_iterator itr = file_sources_.find(*base); - if (itr!=file_sources_.end()) - { - *file = itr->second + "/" + *file; - } - } - - *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)) - { - throw mapnik::config_error("Failed to parse path_expression '" + *file + "'"); - } - - symbol.set_filename(expr); - - optional image_transform_wkt = sym.get_opt_attr("image-transform"); - if (image_transform_wkt) - { - mapnik::transform_list_ptr tl = boost::make_shared(); - if (!mapnik::parse_transform(*tl, *image_transform_wkt, sym.get_tree().transform_expr_grammar)) - { - std::stringstream ss; - ss << "Could not parse transform from '" << *image_transform_wkt - << "', expected SVG transform attribute"; - if (strict_) - { - throw config_error(ss.str()); // value_error here? - } - else - { - MAPNIK_LOG_WARN(load_map) << "map_parser: " << ss; - } - } - symbol.set_image_transform(tl); + *file = itr->second + "/" + *file; } } - catch (image_reader_exception const & ex) + + *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)) { - std::string msg("Failed to load image file '" + * file + - "': " + ex.what()); - if (strict_) + throw mapnik::config_error("Failed to parse path_expression '" + *file + "'"); + } + + symbol.set_filename(expr); + + optional image_transform_wkt = sym.get_opt_attr("image-transform"); + if (image_transform_wkt) + { + mapnik::transform_list_ptr tl = boost::make_shared(); + if (!mapnik::parse_transform(*tl, *image_transform_wkt, sym.get_tree().transform_expr_grammar)) { - throw config_error(msg); - } - else - { - MAPNIK_LOG_WARN(load_map) << "map_parser: " << msg; + std::stringstream ss; + ss << "Could not parse transform from '" << *image_transform_wkt + << "', expected SVG transform attribute"; + if (strict_) + { + throw config_error(ss.str()); // value_error here? + } + else + { + MAPNIK_LOG_WARN(load_map) << "map_parser: " << ss; + } } + symbol.set_image_transform(tl); } } parse_symbolizer_base(symbol, sym); @@ -1099,41 +1082,25 @@ void map_parser::parse_line_pattern_symbolizer(rule & rule, xml_node const & sym std::string file = sym.get_attr("file"); optional base = sym.get_opt_attr("base"); - try + if(base) { - if(base) + std::map::const_iterator itr = file_sources_.find(*base); + if (itr!=file_sources_.end()) { - std::map::const_iterator itr = file_sources_.find(*base); - if (itr!=file_sources_.end()) - { - file = itr->second + "/" + file; - } - } - - 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)) - { - throw mapnik::config_error("Failed to parse path_expression '" + file + "'"); - } - line_pattern_symbolizer symbol(expr); - - parse_symbolizer_base(symbol, sym); - rule.append(symbol); - } - catch (image_reader_exception const & ex) - { - std::string msg("Failed to load image file '" + file + - "': " + ex.what()); - if (strict_) - { - throw config_error(msg); - } - else - { - MAPNIK_LOG_WARN(load_map) << "map_parser: " << msg; + file = itr->second + "/" + file; } } + + 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)) + { + throw mapnik::config_error("Failed to parse path_expression '" + file + "'"); + } + line_pattern_symbolizer symbol(expr); + + parse_symbolizer_base(symbol, sym); + rule.append(symbol); } catch (const config_error & ex) { @@ -1150,58 +1117,42 @@ void map_parser::parse_polygon_pattern_symbolizer(rule & rule, std::string file = sym.get_attr("file"); optional base = sym.get_opt_attr("base"); - try + if(base) { - if(base) + std::map::iterator itr = file_sources_.find(*base); + if (itr!=file_sources_.end()) { - std::map::iterator itr = file_sources_.find(*base); - if (itr!=file_sources_.end()) - { - file = itr->second + "/" + file; - } - } - - 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)) - { - throw mapnik::config_error("Failed to parse path_expression '" + file + "'"); - } - polygon_pattern_symbolizer symbol(expr); - - // pattern alignment - pattern_alignment_e p_alignment = sym.get_attr("alignment",LOCAL_ALIGNMENT); - symbol.set_alignment(p_alignment); - - // opacity - optional opacity = sym.get_opt_attr("opacity"); - if (opacity) symbol.set_opacity(*opacity); - - // gamma - optional gamma = sym.get_opt_attr("gamma"); - if (gamma) symbol.set_gamma(*gamma); - - // gamma method - optional gamma_method = sym.get_opt_attr("gamma-method"); - if (gamma_method) symbol.set_gamma_method(*gamma_method); - - parse_symbolizer_base(symbol, sym); - rule.append(symbol); - } - catch (image_reader_exception const & ex) - { - std::string msg("Failed to load image file '" + file + - "': " + ex.what()); - if (strict_) - { - throw config_error(msg); - } - else - { - MAPNIK_LOG_WARN(load_map) << "map_parser: " << msg; + file = itr->second + "/" + file; } } + + 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)) + { + throw mapnik::config_error("Failed to parse path_expression '" + file + "'"); + } + polygon_pattern_symbolizer symbol(expr); + + // pattern alignment + pattern_alignment_e p_alignment = sym.get_attr("alignment",LOCAL_ALIGNMENT); + symbol.set_alignment(p_alignment); + + // opacity + optional opacity = sym.get_opt_attr("opacity"); + if (opacity) symbol.set_opacity(*opacity); + + // gamma + optional gamma = sym.get_opt_attr("gamma"); + if (gamma) symbol.set_gamma(*gamma); + + // gamma method + optional gamma_method = sym.get_opt_attr("gamma-method"); + if (gamma_method) symbol.set_gamma_method(*gamma_method); + + parse_symbolizer_base(symbol, sym); + rule.append(symbol); } catch (const config_error & ex) { @@ -1314,38 +1265,22 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym) std::string image_file = sym.get_attr("file"); optional base = sym.get_opt_attr("base"); - try + if(base) { - if(base) + std::map::const_iterator itr = file_sources_.find(*base); + if (itr!=file_sources_.end()) { - std::map::const_iterator itr = file_sources_.find(*base); - if (itr!=file_sources_.end()) - { - image_file = itr->second + "/" + image_file; - } + image_file = itr->second + "/" + image_file; } + } - image_file = ensure_relative_to_xml(image_file); - path_expression_ptr expr(boost::make_shared()); - if (!parse_path_from_string(expr, image_file, sym.get_tree().path_expr_grammar)) - { - throw mapnik::config_error("Failed to parse path_expression '" + image_file + "'"); - } - shield_symbol.set_filename(expr); - } - catch (image_reader_exception const & ex) + image_file = ensure_relative_to_xml(image_file); + path_expression_ptr expr(boost::make_shared()); + if (!parse_path_from_string(expr, image_file, sym.get_tree().path_expr_grammar)) { - std::string msg("Failed to load image file '" + image_file + - "': " + ex.what()); - if (strict_) - { - throw config_error(msg); - } - else - { - MAPNIK_LOG_WARN(load_map) << "map_parser: " << msg; - } + throw mapnik::config_error("Failed to parse path_expression '" + image_file + "'"); } + shield_symbol.set_filename(expr); rule.append(shield_symbol); } catch (const config_error & ex)