diff --git a/bindings/python/mapnik_style.cpp b/bindings/python/mapnik_style.cpp index 9b1945fcd..7eb9e449b 100644 --- a/bindings/python/mapnik_style.cpp +++ b/bindings/python/mapnik_style.cpp @@ -28,7 +28,6 @@ #include #include "mapnik_enumeration.hpp" #include -#include // image_filter_grammar #include // generate_image_filters using mapnik::feature_type_style; @@ -45,18 +44,12 @@ std::string get_image_filters(feature_type_style & style) void set_image_filters(feature_type_style & style, std::string const& filters) { - std::string::const_iterator itr = filters.begin(); - std::string::const_iterator end = filters.end(); - mapnik::image_filter_grammar > filter_grammar; std::vector new_filters; - bool result = boost::spirit::qi::phrase_parse(itr,end, - filter_grammar, - boost::spirit::qi::ascii::space, - new_filters); - if (!result || itr!=end) + + bool result = parse_image_filters(filters, new_filters); + if (!result) { - throw mapnik::value_error("failed to parse image-filters: '" + std::string(itr,end) + "'"); + throw mapnik::value_error("failed to parse image-filters: '" + filters + "'"); } style.image_filters().swap(new_filters); } diff --git a/include/mapnik/image_filter_types.hpp b/include/mapnik/image_filter_types.hpp index c8f5ea11b..d651e9c68 100644 --- a/include/mapnik/image_filter_types.hpp +++ b/include/mapnik/image_filter_types.hpp @@ -23,6 +23,9 @@ #ifndef MAPNIK_IMAGE_FILTER_TYPES_HPP #define MAPNIK_IMAGE_FILTER_TYPES_HPP +// mapnik +#include + // boost #include @@ -125,7 +128,9 @@ inline std::ostream& operator<< (std::ostream& os, invert) inline std::ostream& operator<< (std::ostream& os, filter_type const& filter); -bool generate_image_filters(std::back_insert_iterator & sink, std::vector const& v); +MAPNIK_DECL bool generate_image_filters(std::back_insert_iterator & sink, std::vector const& v); + +MAPNIK_DECL bool parse_image_filters(std::string const& filters, std::vector& image_filters); }} diff --git a/src/image_filter_types.cpp b/src/image_filter_types.cpp index cfb8cc0dc..a9bc4c3ce 100644 --- a/src/image_filter_types.cpp +++ b/src/image_filter_types.cpp @@ -21,6 +21,7 @@ *****************************************************************************/ // mapnik #include +#include // image_filter_grammar // boost #include @@ -63,4 +64,17 @@ bool generate_image_filters(std::back_insert_iterator& sink, std::v return r; } +bool parse_image_filters(std::string const& filters, std::vector& image_filters) +{ + std::string::const_iterator itr = filters.begin(); + std::string::const_iterator end = filters.end(); + mapnik::image_filter_grammar > filter_grammar; + bool r = boost::spirit::qi::phrase_parse(itr,end, + filter_grammar, + boost::spirit::qi::ascii::space, + image_filters); + return r && itr==end; +} + }} diff --git a/src/load_map.cpp b/src/load_map.cpp index 053eea13e..8dc5a44d5 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -425,15 +425,10 @@ void map_parser::parse_style(Map & map, xml_node const& sty) if (filters) { std::string filter_str = *filters; - std::string::const_iterator itr = filter_str.begin(); - std::string::const_iterator end = filter_str.end(); - bool result = boost::spirit::qi::phrase_parse(itr,end, - sty.get_tree().image_filters_grammar, - boost::spirit::qi::ascii::space, - style.image_filters()); - if (!result || itr!=end) + bool result = filter::parse_image_filters(filter_str, style.image_filters()); + if (!result) { - throw config_error("failed to parse image-filters: '" + std::string(itr,end) + "'"); + throw config_error("failed to parse image-filters: '" + filter_str + "'"); } }