From 2f65a7612d7f58f353f9f450f1707dc2b6130ba8 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 18 Apr 2012 07:09:12 -0700 Subject: [PATCH 1/4] allow cairo compile --- include/mapnik/cairo_renderer.hpp | 2 ++ src/cairo_renderer.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/mapnik/cairo_renderer.hpp b/include/mapnik/cairo_renderer.hpp index dd37ac906..e0a3d53b5 100644 --- a/include/mapnik/cairo_renderer.hpp +++ b/include/mapnik/cairo_renderer.hpp @@ -80,6 +80,8 @@ public: void start_map_processing(Map const& map); void start_layer_processing(layer const& lay, box2d const& query_extent); void end_layer_processing(layer const& lay); + void start_style_processing(feature_type_style const& st); + void end_style_processing(feature_type_style const& st); void process(point_symbolizer const& sym, mapnik::feature_ptr const& feature, proj_transform const& prj_trans); diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index 589247e0f..47e59eb4d 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -721,6 +721,20 @@ void cairo_renderer_base::start_map_processing(Map const& map) #endif } + void cairo_renderer_base::start_style_processing(feature_type_style const& st) + { + #ifdef MAPNIK_DEBUG + std::clog << "start style processing\n"; + #endif + } + + void cairo_renderer_base::end_style_processing(feature_type_style const& st) + { + #ifdef MAPNIK_DEBUG + std::clog << "end style processing\n"; + #endif + } + void cairo_renderer_base::process(polygon_symbolizer const& sym, mapnik::feature_ptr const& feature, proj_transform const& prj_trans) From b3c618e764bd76d52481ae357b4b730516340a8d Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 18 Apr 2012 07:09:23 -0700 Subject: [PATCH 2/4] avoid warnings --- src/feature_type_style.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/feature_type_style.cpp b/src/feature_type_style.cpp index 528b6c930..c1711335e 100644 --- a/src/feature_type_style.cpp +++ b/src/feature_type_style.cpp @@ -36,16 +36,16 @@ IMPLEMENT_ENUM( filter_mode_e, filter_mode_strings ) feature_type_style::feature_type_style() : filter_mode_(FILTER_ALL), - scale_denom_validity_(-1), filters_(), - comp_op_(clear) + comp_op_(clear), + scale_denom_validity_(-1) {} feature_type_style::feature_type_style(feature_type_style const& rhs, bool deep_copy) : filter_mode_(rhs.filter_mode_), - scale_denom_validity_(-1), filters_(rhs.filters_), - comp_op_(rhs.comp_op_) + comp_op_(rhs.comp_op_), + scale_denom_validity_(-1) { if (!deep_copy) { rules_ = rhs.rules_; @@ -62,9 +62,9 @@ feature_type_style& feature_type_style::operator=(feature_type_style const& rhs) { if (this == &rhs) return *this; rules_=rhs.rules_; - scale_denom_validity_ = -1; filters_ = rhs.filters_; comp_op_ = rhs.comp_op_; + scale_denom_validity_ = -1; return *this; } From cfa2ffc52e58a8de02c4acb33d298f9bcc41b33b Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 18 Apr 2012 07:37:14 -0700 Subject: [PATCH 3/4] better error output when we fail to parse comp-op or image-filters --- src/image_compositing.cpp | 7 ++++--- src/load_map.cpp | 33 ++++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/image_compositing.cpp b/src/image_compositing.cpp index 722c92936..f12b38fa4 100644 --- a/src/image_compositing.cpp +++ b/src/image_compositing.cpp @@ -69,14 +69,15 @@ static const comp_op_lookup_type comp_lookup = boost::assign::list_of comp_op_from_string(std::string const& name) { + boost::optional mode; comp_op_lookup_type::right_const_iterator right_iter = comp_lookup.right.find(name); if (right_iter != comp_lookup.right.end()) { - return right_iter->second; + mode.reset(right_iter->second); } - return clear; + return mode; } template diff --git a/src/load_map.cpp b/src/load_map.cpp index a0f86bae0..0e776ff73 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -418,22 +418,34 @@ void map_parser::parse_style(Map & map, xml_node const& sty) optional comp_op_name = sty.get_opt_attr("comp-op"); if (comp_op_name) { - composite_mode_e comp_op = comp_op_from_string(*comp_op_name); - style.set_comp_op(comp_op); + optional comp_op = comp_op_from_string(*comp_op_name); + if (comp_op) + { + style.set_comp_op(*comp_op); + } + else + { + throw config_error("failed to parse comp-op: '" + *comp_op_name + "'"); + } } // image filters optional filters = sty.get_opt_attr("image-filters"); if (filters) { - std::string::const_iterator itr = (*filters).begin(); - std::string::const_iterator end = (*filters).end(); + std::string filter_mode = *filters; + if (filter_mode.empty()) + { + throw config_error("failed to parse empty image-filter"); + } + std::string::const_iterator itr = filter_mode.begin(); + std::string::const_iterator end = filter_mode.end(); mapnik::image_filter_grammar > g; bool result = boost::spirit::qi::phrase_parse(itr,end, g, boost::spirit::qi::ascii::space, style.image_filters()); if (!result || itr!=end) { - throw config_error("failed to parse:" + std::string(itr,end)); + throw config_error("failed to parse image-filter: '" + std::string(itr,end) + "'"); } } @@ -764,8 +776,15 @@ void map_parser::parse_metawriter_in_symbolizer(symbolizer_base &sym, xml_node c optional comp_op_name = pt.get_opt_attr("comp-op"); if (comp_op_name) { - composite_mode_e comp_op = comp_op_from_string(*comp_op_name); - sym.set_comp_op(comp_op); + optional comp_op = comp_op_from_string(*comp_op_name); + if (comp_op) + { + sym.set_comp_op(*comp_op); + } + else + { + throw config_error("failed to parse comp-op: '" + *comp_op_name + "'"); + } } optional transform_wkt = pt.get_opt_attr("transform"); From dab6936f0541bbffa9677f2ea01a9e7d6d7cdba0 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 18 Apr 2012 07:37:46 -0700 Subject: [PATCH 4/4] embose -> emboss --- include/mapnik/image_compositing.hpp | 4 +++- include/mapnik/image_filter.hpp | 12 ++++++------ include/mapnik/image_filter_parser.hpp | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/mapnik/image_compositing.hpp b/include/mapnik/image_compositing.hpp index a11cc3464..c62f53328 100644 --- a/include/mapnik/image_compositing.hpp +++ b/include/mapnik/image_compositing.hpp @@ -26,6 +26,8 @@ // stl #include +#include + namespace mapnik { @@ -64,7 +66,7 @@ enum composite_mode_e invert_rgb }; -composite_mode_e comp_op_from_string(std::string const& name); +boost::optional comp_op_from_string(std::string const& name); template void composite(T1 & im, T2 & im2, composite_mode_e mode); diff --git a/include/mapnik/image_filter.hpp b/include/mapnik/image_filter.hpp index 7e34a19dd..65bc06124 100644 --- a/include/mapnik/image_filter.hpp +++ b/include/mapnik/image_filter.hpp @@ -71,7 +71,7 @@ //if (out_value < 0) out_value = 0; //if (out_value > 255) out_value = 255; -// embose +// emboss // -2 -1 0 // -1 1 1 // 0 1 2 @@ -121,14 +121,14 @@ using namespace boost::gil; namespace mapnik { namespace filter { namespace detail { static const float blur_matrix[] = {0.1111,0.1111,0.1111,0.1111,0.1111,0.1111,0.1111,0.1111,0.1111}; -static const float embose_matrix[] = {-2,-1,0,-1,1,1,0,1,2}; +static const float emboss_matrix[] = {-2,-1,0,-1,1,1,0,1,2}; static const float sharpen_matrix[] = {0,-1,0,-1,5,-1,0,-1,0 }; static const float edge_detect_matrix[] = {0,1,0,1,-4,1,0,1,0 }; } struct blur {}; -struct embose {}; +struct emboss {}; struct sharpen {}; struct edge_detect {}; struct sobel {}; @@ -172,9 +172,9 @@ void process_channel (Src const& src, Dst & dst, mapnik::filter::blur) } template -void process_channel (Src const& src, Dst & dst, mapnik::filter::embose) +void process_channel (Src const& src, Dst & dst, mapnik::filter::emboss) { - process_channel_impl(src,dst,mapnik::filter::detail::embose_matrix); + process_channel_impl(src,dst,mapnik::filter::detail::emboss_matrix); } template @@ -385,7 +385,7 @@ void apply_filter(Src & src, invert) typedef boost::variant())] + lit("emboss")[push_back(_val,construct())] | lit("blur")[push_back(_val,construct())] |