diff --git a/SConstruct b/SConstruct index 1e3d74e4e..ab8a8ac8f 100644 --- a/SConstruct +++ b/SConstruct @@ -501,7 +501,8 @@ elif HELP_REQUESTED: # need no-op for clean on fresh checkout # https://github.com/mapnik/mapnik/issues/2112 -if not os.path.exists(SCONS_LOCAL_LOG) and ('-c' in command_line_args or '--clean' in command_line_args): +if not os.path.exists(SCONS_LOCAL_LOG) and not os.path.exists(SCONS_CONFIGURE_CACHE) \ + and ('-c' in command_line_args or '--clean' in command_line_args): print 'all good: nothing to clean, but you might want to run "make distclean"' Exit(0) diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index f5c80c579..b12bd1570 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -30,11 +30,9 @@ #include #include #include - #include // mapnik - #include #include #include @@ -56,7 +54,7 @@ using mapnik::context_ptr; using mapnik::feature_kv_iterator; mapnik::geometry_type const& (mapnik::feature_impl::*get_geometry_by_const_ref)(std::size_t) const = &mapnik::feature_impl::get_geometry; -boost::ptr_vector const& (mapnik::feature_impl::*get_paths_by_const_ref)() const = &mapnik::feature_impl::paths; +mapnik::geometry_container const& (mapnik::feature_impl::*get_paths_by_const_ref)() const = &mapnik::feature_impl::paths; void feature_add_geometries_from_wkb(mapnik::feature_impl & feature, std::string wkb) { diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index 2084dd888..1594c86a7 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -28,12 +28,12 @@ #include #include #include -#include #include #include // mapnik #include +#include #include // from_wkt #include #include // from_geojson diff --git a/include/mapnik/box2d.hpp b/include/mapnik/box2d.hpp index 12906f847..b3bb22f10 100644 --- a/include/mapnik/box2d.hpp +++ b/include/mapnik/box2d.hpp @@ -30,9 +30,6 @@ // boost #include -// stl -#include - // agg // forward declare so that apps using mapnik do not need agg headers namespace agg { @@ -105,6 +102,7 @@ public: bool from_string(std::string const& str); bool valid() const; void move(T x, T y); + std::string to_string() const; // define some operators box2d_type& operator+=(box2d_type const& other); @@ -124,13 +122,7 @@ inline std::basic_ostream& operator << (std::basic_ostream& out, const box2d& e) { - std::basic_ostringstream s; - s.copyfmt(out); - s.width(0); - s << "box2d(" << std::fixed << std::setprecision(16) - << e.minx() << ',' << e.miny() << ',' - << e.maxx() << ',' << e.maxy() << ')'; - out << s.str(); + out << e.to_string(); return out; } } diff --git a/include/mapnik/cairo/cairo_context.hpp b/include/mapnik/cairo/cairo_context.hpp index b171985ad..d1f239626 100644 --- a/include/mapnik/cairo/cairo_context.hpp +++ b/include/mapnik/cairo/cairo_context.hpp @@ -51,7 +51,6 @@ namespace mapnik { -class text_path; template class box2d; using ErrorStatus = cairo_status_t; diff --git a/include/mapnik/evaluate_global_attributes.hpp b/include/mapnik/evaluate_global_attributes.hpp index d3e3626df..f131ee7c1 100644 --- a/include/mapnik/evaluate_global_attributes.hpp +++ b/include/mapnik/evaluate_global_attributes.hpp @@ -34,12 +34,6 @@ #include #include -#if defined(BOOST_REGEX_HAS_ICU) -#include -#else -#include -#endif - namespace mapnik { namespace { @@ -107,24 +101,13 @@ struct evaluate_expression : util::static_visitor value_type operator() (regex_match_node const& x) const { value_type v = util::apply_visitor(*this, x.expr); -#if defined(BOOST_REGEX_HAS_ICU) - return boost::u32regex_match(v.to_unicode(),x.pattern); -#else - return boost::regex_match(v.to_string(),x.pattern); -#endif - + return x.apply(v); } value_type operator() (regex_replace_node const& x) const { value_type v = util::apply_visitor(*this, x.expr); -#if defined(BOOST_REGEX_HAS_ICU) - return boost::u32regex_replace(v.to_unicode(),x.pattern,x.format); -#else - std::string repl = boost::regex_replace(v.to_string(),x.pattern,x.format); - mapnik::transcoder tr_("utf8"); - return tr_.transcode(repl.c_str()); -#endif + return x.apply(v); } value_type operator() (unary_function_call const& call) const @@ -206,24 +189,13 @@ struct evaluate_expression : util::static_visitor value_type operator() (regex_match_node const& x) const { value_type v = util::apply_visitor(*this, x.expr); -#if defined(BOOST_REGEX_HAS_ICU) - return boost::u32regex_match(v.to_unicode(),x.pattern); -#else - return boost::regex_match(v.to_string(),x.pattern); -#endif - + return x.apply(v); } value_type operator() (regex_replace_node const& x) const { value_type v = util::apply_visitor(*this, x.expr); -#if defined(BOOST_REGEX_HAS_ICU) - return boost::u32regex_replace(v.to_unicode(),x.pattern,x.format); -#else - std::string repl = boost::regex_replace(v.to_string(),x.pattern,x.format); - mapnik::transcoder tr_("utf8"); - return tr_.transcode(repl.c_str()); -#endif + return x.apply(v); } value_type operator() (unary_function_call const& call) const diff --git a/include/mapnik/expression_evaluator.hpp b/include/mapnik/expression_evaluator.hpp index 01f9d7815..c8b94a95e 100644 --- a/include/mapnik/expression_evaluator.hpp +++ b/include/mapnik/expression_evaluator.hpp @@ -29,12 +29,6 @@ #include #include #include -// boost -#if defined(BOOST_REGEX_HAS_ICU) -#include -#else -#include -#endif namespace mapnik { @@ -130,24 +124,13 @@ struct evaluate : util::static_visitor value_type operator() (regex_match_node const& x) const { value_type v = util::apply_visitor(*this, x.expr); -#if defined(BOOST_REGEX_HAS_ICU) - return boost::u32regex_match(v.to_unicode(),x.pattern); -#else - return boost::regex_match(v.to_string(),x.pattern); -#endif - + return x.apply(v); } value_type operator() (regex_replace_node const& x) const { value_type v = util::apply_visitor(*this, x.expr); -#if defined(BOOST_REGEX_HAS_ICU) - return boost::u32regex_replace(v.to_unicode(),x.pattern,x.format); -#else - std::string repl = boost::regex_replace(v.to_string(),x.pattern,x.format); - mapnik::transcoder tr_("utf8"); - return tr_.transcode(repl.c_str()); -#endif + return x.apply(v); } value_type operator() (unary_function_call const& call) const diff --git a/include/mapnik/expression_grammar.hpp b/include/mapnik/expression_grammar.hpp index 6342fe23a..fd8663bb8 100644 --- a/include/mapnik/expression_grammar.hpp +++ b/include/mapnik/expression_grammar.hpp @@ -126,6 +126,17 @@ struct integer_parser using type = qi::int_parser; }; +struct unary_function_types : qi::symbols +{ + unary_function_types(); +}; + +struct binary_function_types : qi::symbols +{ + binary_function_types(); +}; + + #ifdef __GNUC__ template struct MAPNIK_DECL expression_grammar : qi::grammar diff --git a/include/mapnik/expression_grammar_impl.hpp b/include/mapnik/expression_grammar_impl.hpp index 2a79b4fc3..b56c2cf79 100644 --- a/include/mapnik/expression_grammar_impl.hpp +++ b/include/mapnik/expression_grammar_impl.hpp @@ -28,6 +28,7 @@ #include #include #include +#include // boost #include @@ -43,24 +44,38 @@ namespace mapnik { namespace mapnik { +unary_function_types::unary_function_types() +{ + add + ("sin", sin_impl()) + ("cos", cos_impl()) + ("tan", tan_impl()) + ("atan", atan_impl()) + ("exp", exp_impl()) + ("abs", abs_impl()) + ("length",length_impl()) + ; +} + +binary_function_types::binary_function_types() +{ + add + ("min", binary_function_impl(min_impl)) + ("max", binary_function_impl(max_impl)) + ("pow", binary_function_impl(pow_impl)) + ; +} + template expr_node regex_match_impl::operator() (T0 & node, T1 const& pattern) const { -#if defined(BOOST_REGEX_HAS_ICU) - return regex_match_node(node,tr_.transcode(pattern.c_str())); -#else - return regex_match_node(node,pattern); -#endif + return regex_match_node(tr_,node,pattern); } template expr_node regex_replace_impl::operator() (T0 & node, T1 const& pattern, T2 const& format) const { -#if defined(BOOST_REGEX_HAS_ICU) - return regex_replace_node(node,tr_.transcode(pattern.c_str()),tr_.transcode(format.c_str())); -#else - return regex_replace_node(node,pattern,format); -#endif + return regex_replace_node(tr_,node,pattern,format); } template diff --git a/include/mapnik/expression_node.hpp b/include/mapnik/expression_node.hpp index ac3a8fe27..c46e852f0 100644 --- a/include/mapnik/expression_node.hpp +++ b/include/mapnik/expression_node.hpp @@ -26,16 +26,12 @@ // mapnik #include #include +#include +#include #include +#include #include -// boost -#if defined(BOOST_REGEX_HAS_ICU) -#include -#else -#include -#endif - namespace mapnik { @@ -86,46 +82,6 @@ struct binary_node expr_node left,right; }; -#if defined(BOOST_REGEX_HAS_ICU) - -struct regex_match_node -{ - regex_match_node (expr_node const& a, mapnik::value_unicode_string const& ustr); - expr_node expr; - boost::u32regex pattern; -}; - - -struct regex_replace_node -{ - regex_replace_node (expr_node const& a, mapnik::value_unicode_string const& ustr, mapnik::value_unicode_string const& f); - expr_node expr; - boost::u32regex pattern; - mapnik::value_unicode_string format; -}; - -#else - -struct regex_match_node -{ - regex_match_node (expr_node const& a, std::string const& str); - expr_node expr; - boost::regex pattern; -}; - - -struct regex_replace_node -{ - regex_replace_node (expr_node const& a, std::string const& str, std::string const& f); - expr_node expr; - boost::regex pattern; - std::string format; -}; -#endif - -using unary_function_impl = std::function; -using binary_function_impl = std::function; - struct unary_function_call { using argument_type = expr_node; @@ -148,6 +104,29 @@ struct binary_function_call argument_type arg2; }; +// pimpl +struct _regex_match_impl; +struct _regex_replace_impl; + +struct MAPNIK_DECL regex_match_node +{ + regex_match_node(transcoder const& tr, expr_node const& a, std::string const& ustr); + mapnik::value apply(mapnik::value const& v) const; + std::string to_string() const; + expr_node expr; + // TODO - use unique_ptr once https://github.com/mapnik/mapnik/issues/2457 is fixed + std::shared_ptr<_regex_match_impl> impl_; +}; + +struct MAPNIK_DECL regex_replace_node +{ + regex_replace_node(transcoder const& tr, expr_node const& a, std::string const& ustr, std::string const& f); + mapnik::value apply(mapnik::value const& v) const; + std::string to_string() const; + expr_node expr; + // TODO - use unique_ptr once https://github.com/mapnik/mapnik/issues/2457 is fixed + std::shared_ptr<_regex_replace_impl> impl_; +}; inline expr_node & operator- (expr_node& expr) { diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index 9547ba86b..9a600b0f4 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include diff --git a/include/mapnik/function_call.hpp b/include/mapnik/function_call.hpp index 236ad0361..5453d92af 100644 --- a/include/mapnik/function_call.hpp +++ b/include/mapnik/function_call.hpp @@ -24,28 +24,104 @@ #define MAPNIK_FUNCTION_CALL_HPP #include -#include #include -#include +#include +#include namespace mapnik { using value_type = mapnik::value; -namespace qi = boost::spirit::qi; -struct unary_function_types : qi::symbols -{ - unary_function_types(); -}; - -struct binary_function_types : qi::symbols -{ - binary_function_types(); -}; +using unary_function_impl = std::function; +using binary_function_impl = std::function; char const* unary_function_name(unary_function_impl const& fun); char const* binary_function_name(binary_function_impl const& fun); +// functions +// exp +struct exp_impl +{ + //using type = T; + value_type operator() (value_type const& val) const + { + return std::exp(val.to_double()); + } + +}; + +// sin +struct sin_impl +{ + value_type operator() (value_type const& val) const + { + return std::sin(val.to_double()); + } +}; + +// cos +struct cos_impl +{ + value_type operator() (value_type const& val) const + { + return std::cos(val.to_double()); + } +}; + +// tan +struct tan_impl +{ + value_type operator() (value_type const& val) const + { + return std::tan(val.to_double()); + } +}; + +// atan +struct atan_impl +{ + value_type operator()(value_type const& val) const + { + return std::atan(val.to_double()); + } +}; + +// abs +struct abs_impl +{ + value_type operator() (value_type const& val) const + { + return std::fabs(val.to_double()); + } +}; + +// length +struct length_impl +{ + value_type operator() (value_type const& val) const + { + return val.to_unicode().length(); + } +}; + +// min +inline value_type min_impl(value_type const& arg1, value_type const& arg2) +{ + return std::min(arg1.to_double(), arg2.to_double()); +} + +// max +inline value_type max_impl(value_type const& arg1, value_type const& arg2) +{ + return std::max(arg1.to_double(), arg2.to_double()); +} + +// pow +inline value_type pow_impl(value_type const& arg1, value_type const& arg2) +{ + return std::pow(arg1.to_double(), arg2.to_double()); +} + } // namespace mapnik -#endif //MAPNIK_FUNCTION_CALL_HPP +#endif // MAPNIK_FUNCTION_CALL_HPP diff --git a/include/mapnik/geom_util.hpp b/include/mapnik/geom_util.hpp index 3114e59cb..c8fe3220e 100644 --- a/include/mapnik/geom_util.hpp +++ b/include/mapnik/geom_util.hpp @@ -32,6 +32,7 @@ // stl #include #include +#include namespace mapnik { diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index b78f89aa3..471e043e8 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -28,10 +28,6 @@ #include #include -// boost -#include -#include - namespace mapnik { template class Container=vertex_vector> @@ -154,8 +150,6 @@ public: }; using geometry_type = geometry; -using geometry_ptr = std::shared_ptr; -using geometry_container = boost::ptr_vector; } diff --git a/include/mapnik/geometry_container.hpp b/include/mapnik/geometry_container.hpp new file mode 100644 index 000000000..c56eaa734 --- /dev/null +++ b/include/mapnik/geometry_container.hpp @@ -0,0 +1,35 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2011 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_GEOMETRY_CONTAINER_HPP +#define MAPNIK_GEOMETRY_CONTAINER_HPP + +// boost +#include + +namespace mapnik { + +using geometry_container = boost::ptr_vector; + +} + +#endif // MAPNIK_GEOMETRY_CONTAINER_HPP diff --git a/include/mapnik/json/feature_generator_grammar.hpp b/include/mapnik/json/feature_generator_grammar.hpp index d909f6a84..973c68243 100644 --- a/include/mapnik/json/feature_generator_grammar.hpp +++ b/include/mapnik/json/feature_generator_grammar.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp index 104c6b2e7..90f65b004 100644 --- a/include/mapnik/json/feature_grammar.hpp +++ b/include/mapnik/json/feature_grammar.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/include/mapnik/json/geometry_parser.hpp b/include/mapnik/json/geometry_parser.hpp index e40791fb9..57f5ac6c0 100644 --- a/include/mapnik/json/geometry_parser.hpp +++ b/include/mapnik/json/geometry_parser.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include #include // boost @@ -33,7 +34,7 @@ namespace mapnik { namespace json { -inline bool from_geojson(std::string const& json, boost::ptr_vector & paths) +inline bool from_geojson(std::string const& json, geometry_container & paths) { using namespace boost::spirit; static const geometry_grammar g; diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp index 76ce9992f..fd7462755 100644 --- a/include/mapnik/marker_helpers.hpp +++ b/include/mapnik/marker_helpers.hpp @@ -60,11 +60,14 @@ // stl #include #include // remove_reference +#include namespace mapnik { struct clip_poly_tag; +using svg_attribute_type = agg::pod_bvector; + template struct vector_markers_rasterizer_dispatch : mapnik::noncopyable { @@ -80,7 +83,7 @@ struct vector_markers_rasterizer_dispatch : mapnik::noncopyable attribute_source_type const& attrs, box2d const& bbox, agg::trans_affine const& marker_trans, - markers_symbolizer const& sym, + symbolizer_base const& sym, Detector & detector, double scale_factor, feature_impl & feature, @@ -145,7 +148,7 @@ private: RasterizerType & ras_; box2d const& bbox_; agg::trans_affine const& marker_trans_; - markers_symbolizer const& sym_; + symbolizer_base const& sym_; Detector & detector_; feature_impl & feature_; attributes const& vars_; @@ -168,7 +171,7 @@ struct raster_markers_rasterizer_dispatch : mapnik::noncopyable raster_markers_rasterizer_dispatch(image_data_32 const& src, agg::trans_affine const& marker_trans, - markers_symbolizer const& sym, + symbolizer_base const& sym, Detector & detector, double scale_factor, feature_impl & feature, @@ -299,7 +302,7 @@ private: RasterizerType & ras_; image_data_32 const& src_; agg::trans_affine const& marker_trans_; - markers_symbolizer const& sym_; + symbolizer_base const& sym_; Detector & detector_; feature_impl & feature_; attributes const& vars_; @@ -308,132 +311,24 @@ private: }; -template -void build_ellipse(T const& sym, mapnik::feature_impl & feature, attributes const& vars, svg_storage_type & marker_ellipse, svg::svg_path_adapter & svg_path) -{ - double width = 0.0; - double height = 0.0; - if (has_key(sym,keys::width) && has_key(sym,keys::height)) - { - width = get(sym, keys::width, feature, vars, 0.0); - height = get(sym, keys::height, feature, vars, 0.0); - } - else if (has_key(sym,keys::width)) - { - width = height = get(sym, keys::width, feature, vars, 0.0); - } - else if (has_key(sym,keys::height)) - { - width = height = get(sym, keys::height, feature, vars, 0.0); - } - svg::svg_converter_type styled_svg(svg_path, marker_ellipse.attributes()); - styled_svg.push_attr(); - styled_svg.begin_path(); - agg::ellipse c(0, 0, width/2.0, height/2.0); - styled_svg.storage().concat_path(c); - styled_svg.end_path(); - styled_svg.pop_attr(); - double lox,loy,hix,hiy; - styled_svg.bounding_rect(&lox, &loy, &hix, &hiy); - styled_svg.set_dimensions(width,height); - marker_ellipse.set_dimensions(width,height); - marker_ellipse.set_bounding_box(lox,loy,hix,hiy); -} +void build_ellipse(symbolizer_base const& sym, mapnik::feature_impl & feature, attributes const& vars, svg_storage_type & marker_ellipse, svg::svg_path_adapter & svg_path); -template -bool push_explicit_style(Attr const& src, Attr & dst, - markers_symbolizer const& sym, +bool push_explicit_style(svg_attribute_type const& src, + svg_attribute_type & dst, + symbolizer_base const& sym, feature_impl & feature, - attributes const& vars) -{ - auto fill_color = get_optional(sym, keys::fill, feature, vars); - auto fill_opacity = get_optional(sym, keys::fill_opacity, feature, vars); - auto stroke_color = get_optional(sym, keys::stroke, feature, vars); - auto stroke_width = get_optional(sym, keys::stroke_width, feature, vars); - auto stroke_opacity = get_optional(sym, keys::stroke_opacity, feature, vars); - if (fill_color || - fill_opacity || - stroke_color || - stroke_width || - stroke_opacity) - { - bool success = false; - for(unsigned i = 0; i < src.size(); ++i) - { - success = true; - dst.push_back(src[i]); - mapnik::svg::path_attributes & attr = dst.last(); - if (attr.stroke_flag) - { - if (stroke_width) - { - attr.stroke_width = *stroke_width; - } - if (stroke_color) - { - color const& s_color = *stroke_color; - attr.stroke_color = agg::rgba(s_color.red()/255.0, - s_color.green()/255.0, - s_color.blue()/255.0, - s_color.alpha()/255.0); - } - if (stroke_opacity) - { - attr.stroke_opacity = *stroke_opacity; - } - } - if (attr.fill_flag) - { - if (fill_color) - { - color const& f_color = *fill_color; - attr.fill_color = agg::rgba(f_color.red()/255.0, - f_color.green()/255.0, - f_color.blue()/255.0, - f_color.alpha()/255.0); - } - if (fill_opacity) - { - attr.fill_opacity = *fill_opacity; - } - } - } - return success; - } - return false; -} + attributes const& vars); -template void setup_transform_scaling(agg::trans_affine & tr, double svg_width, double svg_height, mapnik::feature_impl & feature, attributes const& vars, - T const& sym) -{ - double width = get(sym, keys::width, feature, vars, 0.0); - double height = get(sym, keys::height, feature, vars, 0.0); - if (width > 0 && height > 0) - { - double sx = width/svg_width; - double sy = height/svg_height; - tr *= agg::trans_affine_scaling(sx,sy); - } - else if (width > 0) - { - double sx = width/svg_width; - tr *= agg::trans_affine_scaling(sx); - } - else if (height > 0) - { - double sy = height/svg_height; - tr *= agg::trans_affine_scaling(sy); - } -} + symbolizer_base const& sym); // Apply markers to a feature with multiple geometries template -void apply_markers_multi(feature_impl const& feature, attributes const& vars, Converter & converter, markers_symbolizer const& sym) +void apply_markers_multi(feature_impl const& feature, attributes const& vars, Converter & converter, symbolizer_base const& sym) { std::size_t geom_count = feature.paths().size(); if (geom_count == 1) diff --git a/include/mapnik/markers_placement.hpp b/include/mapnik/markers_placement.hpp index 6db046a33..52aecc3d9 100644 --- a/include/mapnik/markers_placement.hpp +++ b/include/mapnik/markers_placement.hpp @@ -31,7 +31,9 @@ #include #include #include -#include + +// stl +#include namespace mapnik { @@ -86,7 +88,7 @@ private: Detector &detector, markers_placement_params const& params) { - static const std::map> factories = diff --git a/include/mapnik/offset_converter.hpp b/include/mapnik/offset_converter.hpp index 28f690276..e01c1d7e6 100644 --- a/include/mapnik/offset_converter.hpp +++ b/include/mapnik/offset_converter.hpp @@ -26,22 +26,18 @@ #ifdef MAPNIK_LOG #include #endif +#include #include -#include #include -#include - -// boost -#include // stl #include +#include +#include namespace mapnik { -const double pi = boost::math::constants::pi(); - template struct MAPNIK_DECL offset_converter { @@ -176,13 +172,13 @@ private: static double explement_reflex_angle(double angle) { - if (angle > pi) + if (angle > M_PI) { - return angle - 2 * pi; + return angle - 2 * M_PI; } - else if (angle < -pi) + else if (angle < -M_PI) { - return angle + 2 * pi; + return angle + 2 * M_PI; } else { @@ -320,22 +316,22 @@ private: { if (joint_angle > 0.0) { - joint_angle = joint_angle - 2 * pi; + joint_angle = joint_angle - 2 * M_PI; } else { - bulge_steps = 1 + static_cast(std::floor(half_turns / pi)); + bulge_steps = 1 + static_cast(std::floor(half_turns / M_PI)); } } else { if (joint_angle < 0.0) { - joint_angle = joint_angle + 2 * pi; + joint_angle = joint_angle + 2 * M_PI; } else { - bulge_steps = 1 + static_cast(std::floor(half_turns / pi)); + bulge_steps = 1 + static_cast(std::floor(half_turns / M_PI)); } } @@ -344,14 +340,14 @@ private: { // inside turn (sharp/obtuse angle) MAPNIK_LOG_DEBUG(ctrans) << "offset_converter:" - << " Sharp joint [<< inside turn " << int(joint_angle*180/pi) + << " Sharp joint [<< inside turn " << int(joint_angle*180/M_PI) << " degrees >>]"; } else { // outside turn (reflex angle) MAPNIK_LOG_DEBUG(ctrans) << "offset_converter:" - << " Bulge joint >)) outside turn " << int(joint_angle*180/pi) + << " Bulge joint >)) outside turn " << int(joint_angle*180/M_PI) << " degrees ((< with " << bulge_steps << " segments"; } #endif diff --git a/include/mapnik/renderer_common/process_markers_symbolizer.hpp b/include/mapnik/renderer_common/process_markers_symbolizer.hpp index afd93e250..3ef7a1f50 100644 --- a/include/mapnik/renderer_common/process_markers_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_markers_symbolizer.hpp @@ -26,14 +26,10 @@ #include #include #include -#include #include #include #include -// boost -#include - namespace mapnik { template @@ -49,14 +45,6 @@ void render_markers_symbolizer(markers_symbolizer const& sym, using raster_dispatch_type = T1; using renderer_context_type = T2; - using svg_attribute_type = agg::pod_bvector; - using conv_types = boost::mpl::vector; - std::string filename = get(sym, keys::file, feature, common.vars_, "shape://ellipse"); bool clip = get(sym, keys::clip, feature, common.vars_, false); double offset = get(sym, keys::offset, feature, common.vars_, 0.0); @@ -105,9 +93,13 @@ void render_markers_symbolizer(markers_symbolizer const& sym, snap_to_pixels, renderer_context); - vertex_converter, vector_dispatch_type, markers_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> - converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_); + using vertex_converter_type = vertex_converter; + vertex_converter_type converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_); if (clip && feature.paths().size() > 0) // optional clip (default: true) { geometry_type::types type = feature.paths()[0].type(); @@ -145,9 +137,13 @@ void render_markers_symbolizer(markers_symbolizer const& sym, snap_to_pixels, renderer_context); - vertex_converter, vector_dispatch_type, markers_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> - converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_); + using vertex_converter_type = vertex_converter; + vertex_converter_type converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_); if (clip && feature.paths().size() > 0) // optional clip (default: true) { geometry_type::types type = feature.paths()[0].type(); @@ -184,9 +180,13 @@ void render_markers_symbolizer(markers_symbolizer const& sym, common.vars_, renderer_context); - vertex_converter, raster_dispatch_type, markers_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> - converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_); + using vertex_converter_type = vertex_converter; + vertex_converter_type converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_); if (clip && feature.paths().size() > 0) // optional clip (default: true) { diff --git a/include/mapnik/renderer_common/process_polygon_symbolizer.hpp b/include/mapnik/renderer_common/process_polygon_symbolizer.hpp index 901158d5b..05a076c79 100644 --- a/include/mapnik/renderer_common/process_polygon_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_polygon_symbolizer.hpp @@ -23,7 +23,11 @@ #ifndef MAPNIK_RENDERER_COMMON_PROCESS_POLYGON_SYMBOLIZER_HPP #define MAPNIK_RENDERER_COMMON_PROCESS_POLYGON_SYMBOLIZER_HPP +#include #include +#include +#include +#include namespace mapnik { diff --git a/include/mapnik/symbolizer.hpp b/include/mapnik/symbolizer.hpp index c53b91417..649c47fcd 100644 --- a/include/mapnik/symbolizer.hpp +++ b/include/mapnik/symbolizer.hpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -52,6 +51,11 @@ #include #include #include +#include +#include + +// boost +#include namespace agg { struct trans_affine; } @@ -410,7 +414,7 @@ struct evaluate_expression_wrapper dash_array dash; std::vector buf; std::string str = val.to_string(); - if (util::parse_dasharray(str.begin(),str.end(),buf)) + if (util::parse_dasharray(str,buf)) { util::add_dashes(buf,dash); } diff --git a/include/mapnik/symbolizer_utils.hpp b/include/mapnik/symbolizer_utils.hpp index d6bdd8939..1d094c4c2 100644 --- a/include/mapnik/symbolizer_utils.hpp +++ b/include/mapnik/symbolizer_utils.hpp @@ -37,6 +37,7 @@ #include #include #include +#include #include namespace mapnik { @@ -395,7 +396,7 @@ struct set_symbolizer_property_impl { std::vector buf; dash_array dash; - if (util::parse_dasharray((*str).begin(),(*str).end(),buf) && util::add_dashes(buf,dash)) + if (util::parse_dasharray(*str,buf) && util::add_dashes(buf,dash)) { put(sym,key,dash); } diff --git a/include/mapnik/text/symbolizer_helpers.hpp b/include/mapnik/text/symbolizer_helpers.hpp index 96b61b854..b124aadc0 100644 --- a/include/mapnik/text/symbolizer_helpers.hpp +++ b/include/mapnik/text/symbolizer_helpers.hpp @@ -56,10 +56,7 @@ struct placement_finder_adapter }; -using conv_types = boost::mpl::vector; -using vertex_converter_type = vertex_converter, placement_finder_adapter , symbolizer_base, - view_transform, proj_transform, agg::trans_affine, - conv_types, feature_impl>; +using vertex_converter_type = vertex_converter,clip_line_tag , transform_tag, affine_transform_tag, simplify_tag, smooth_tag>; class base_symbolizer_helper { diff --git a/include/mapnik/text/text_path.hpp b/include/mapnik/text/text_path.hpp deleted file mode 100644 index 27991187b..000000000 --- a/include/mapnik/text/text_path.hpp +++ /dev/null @@ -1,203 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2013 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -#ifndef MAPNIK_TEXT_PATH_HPP -#define MAPNIK_TEXT_PATH_HPP - -// mapnik -#include -#include -#include -#include - -//stl -#include - -// boost -#include -#include - -namespace mapnik -{ - -class string_info : private mapnik::noncopyable -{ -protected: - using characters_t = std::vector; - characters_t characters_; - mapnik::value_unicode_string text_; - bool is_rtl; -public: - string_info(mapnik::value_unicode_string const& text) - : characters_(), - text_(text), - is_rtl(false) - { - - } - - string_info() - : characters_(), - text_(), - is_rtl(false) - { - - } - - void add_info(char_info const& info) - { - characters_.push_back(info); - } - - void add_text(mapnik::value_unicode_string const& text) - { - text_ += text; - } - - std::size_t num_characters() const - { - return characters_.size(); - } - - void set_rtl(bool value) - { - is_rtl = value; - } - - bool get_rtl() const - { - return is_rtl; - } - - char_info const& at(std::size_t i) const - { - return characters_[i]; - } - - char_info const& operator[](std::size_t i) const - { - return at(i); - } - - mapnik::value_unicode_string const& get_string() const - { - return text_; - } - - bool has_line_breaks() const - { - // uint16_t - UChar break_char = '\n'; - return (text_.indexOf(break_char) >= 0); - } - - // Resets object to initial state. - void clear() - { - text_.remove(); - characters_.clear(); - } -}; - -using char_info_ptr = char_info const *; - - -// List of all characters and their positions and formats for a placement. -class text_path : mapnik::noncopyable -{ - struct character_node - { - char_info_ptr c; - pixel_position pos; - double angle; - - character_node(char_info_ptr c_, double x_, double y_, double angle_) - : c(c_), - pos(x_, y_), - angle(angle_) - { - - } - - ~character_node() {} - - void vertex(char_info_ptr & c_, double & x_, double & y_, double & angle_) const - { - c_ = c; - x_ = pos.x; - y_ = pos.y; - angle_ = angle; - } - }; - - mutable int itr_; -public: - using character_nodes_t = std::vector; - pixel_position center; - character_nodes_t nodes_; - - text_path(double x, double y) - : itr_(0), - center(x,y), - nodes_() - { - - } - - ~text_path() {} - - /** Adds a new char to the list. */ - void add_node(char_info_ptr c, double x, double y, double angle) - { - nodes_.push_back(character_node(c, x, y, angle)); - } - - /** Return node. Always returns a new node. Has no way to report that there are no more nodes. */ - void vertex(char_info_ptr & c, double & x, double & y, double & angle) const - { - nodes_[itr_++].vertex(c, x, y, angle); - } - - /** Start again at first node. */ - void rewind() const - { - itr_ = 0; - } - - /** Number of nodes. */ - std::size_t num_nodes() const - { - return nodes_.size(); - } - - /** Delete all nodes. */ - void clear() - { - nodes_.clear(); - } -}; - -using text_path_ptr = std::shared_ptr; -using placements_type = boost::ptr_vector; -} - -#endif // MAPNIK_TEXT_PATH_HPP diff --git a/include/mapnik/transform_path_adapter.hpp b/include/mapnik/transform_path_adapter.hpp index 054a69c4f..0a8d759c5 100644 --- a/include/mapnik/transform_path_adapter.hpp +++ b/include/mapnik/transform_path_adapter.hpp @@ -24,6 +24,10 @@ #define MAPNIK_TRANSFORM_PATH_ADAPTER_HPP #include +#include +#include + +#include namespace mapnik { diff --git a/include/mapnik/unicode.hpp b/include/mapnik/unicode.hpp index 4522c3b8e..4f84c74e9 100644 --- a/include/mapnik/unicode.hpp +++ b/include/mapnik/unicode.hpp @@ -26,15 +26,14 @@ //mapnik #include #include - -// icu #include -#include // stl #include #include +struct UConverter; + namespace mapnik { class MAPNIK_DECL transcoder : private mapnik::noncopyable @@ -49,13 +48,4 @@ private: }; } -namespace U_ICU_NAMESPACE { - -inline std::size_t hash_value(mapnik::value_unicode_string const& val) -{ - return val.hashCode(); -} - -} - #endif // MAPNIK_UNICODE_HPP diff --git a/include/mapnik/util/container_adapter.hpp b/include/mapnik/util/container_adapter.hpp index cdd374bb5..8416e6093 100644 --- a/include/mapnik/util/container_adapter.hpp +++ b/include/mapnik/util/container_adapter.hpp @@ -25,11 +25,11 @@ // mapnik #include +#include #include // boost #include -#include namespace boost { namespace spirit { namespace traits { @@ -60,9 +60,8 @@ template <> struct end_container { static mapnik::util::path_iterator - call (mapnik::geometry_type const& g) + call (mapnik::geometry_type const&) { - boost::ignore_unused_variable_warning(g); return mapnik::util::path_iterator(); } }; diff --git a/include/mapnik/util/dasharray_parser.hpp b/include/mapnik/util/dasharray_parser.hpp index 0cf0081dc..f22b927e7 100644 --- a/include/mapnik/util/dasharray_parser.hpp +++ b/include/mapnik/util/dasharray_parser.hpp @@ -23,42 +23,12 @@ #ifndef MAPNIK_UTIL_DASHARRAY_PARSER_HPP #define MAPNIK_UTIL_DASHARRAY_PARSER_HPP -#include -#include -#include -#include -#include - #include #include namespace mapnik { namespace util { -template -bool parse_dasharray(Iterator first, Iterator last, std::vector& dasharray) -{ - using namespace boost::spirit; - qi::double_type double_; - qi::_1_type _1; - qi::lit_type lit; - qi::char_type char_; - qi::ascii::space_type space; - qi::no_skip_type no_skip; - // SVG - // dasharray ::= (length | percentage) (comma-wsp dasharray)? - // no support for 'percentage' as viewport is unknown at load_map - // - bool r = qi::phrase_parse(first, last, - (double_[boost::phoenix::push_back(boost::phoenix::ref(dasharray), _1)] % - no_skip[char_(", ")] - | lit("none")), - space); - if (first != last) - { - return false; - } - return r; -} +bool parse_dasharray(std::string const& value, std::vector& dasharray); inline bool add_dashes(std::vector & buf, std::vector > & dash) { diff --git a/include/mapnik/util/geometry_to_svg.hpp b/include/mapnik/util/geometry_to_svg.hpp index e18bc2ce7..6e207dbd8 100644 --- a/include/mapnik/util/geometry_to_svg.hpp +++ b/include/mapnik/util/geometry_to_svg.hpp @@ -26,6 +26,7 @@ // mapnik #include #include +#include #include // boost diff --git a/include/mapnik/util/geometry_to_wkb.hpp b/include/mapnik/util/geometry_to_wkb.hpp index 0f5ff9a13..bd90161b9 100644 --- a/include/mapnik/util/geometry_to_wkb.hpp +++ b/include/mapnik/util/geometry_to_wkb.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include // stl @@ -187,7 +188,7 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order) using point_type = std::pair; using linear_ring = std::vector; - boost::ptr_vector rings; + std::vector rings; double x = 0; double y = 0; @@ -197,8 +198,10 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order) unsigned command = g.vertex(i,&x,&y); if (command == SEG_MOVETO) { - rings.push_back(new linear_ring); // start new loop - rings.back().emplace_back(x,y); + linear_ring ring; + ring.reserve(1); + ring.emplace_back(x,y); + rings.push_back(std::move(ring)); // start new loop size += 4; // num_points size += 2 * 8; // point } diff --git a/include/mapnik/util/geometry_to_wkt.hpp b/include/mapnik/util/geometry_to_wkt.hpp index b861c1a33..5d4967fd0 100644 --- a/include/mapnik/util/geometry_to_wkt.hpp +++ b/include/mapnik/util/geometry_to_wkt.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include #include namespace mapnik { namespace util { diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index 0906db2ee..9a946233f 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -26,12 +26,9 @@ // mapnik #include #include -#include #include #include -// boost -#include // stl #include #include diff --git a/include/mapnik/value_hash.hpp b/include/mapnik/value_hash.hpp index e9667915e..1a72108b4 100644 --- a/include/mapnik/value_hash.hpp +++ b/include/mapnik/value_hash.hpp @@ -26,10 +26,13 @@ // mapnik #include #include -#include + // stl #include +// icu +#include + namespace mapnik { namespace detail { template @@ -48,7 +51,7 @@ struct value_hasher: public util::static_visitor std::size_t operator() (value_unicode_string const& val) const { - return hash_value(val); + return val.hashCode(); } template diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index d215854a0..a41fab982 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -38,24 +38,6 @@ #include #include -// boost -#include - -// mpl -#include -#include -#include -#include -#include -#include -#include - -// fusion -#include -#include - - - // agg #include "agg_math_stroke.h" #include "agg_trans_affine.h" @@ -68,6 +50,7 @@ #include "agg_conv_transform.h" // stl +#include #include #include @@ -91,11 +74,6 @@ struct converter_traits { using geometry_type = T0; using conv_type = geometry_type; - template - static void setup(geometry_type & , Args const& ) - { - throw std::runtime_error("invalid call to setup"); - } }; template @@ -107,10 +85,7 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - typename boost::mpl::at >::type sym = boost::fusion::at_c<2>(args); - auto const& feat = boost::fusion::at_c<6>(args); - auto const& vars = boost::fusion::at_c<7>(args); - geom.smooth_value(get(sym, keys::smooth, feat, vars)); + geom.smooth_value(get(args.sym, keys::smooth, args.feature, args.vars)); } }; @@ -123,11 +98,8 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - typename boost::mpl::at >::type sym = boost::fusion::at_c<2>(args); - auto const& feat = boost::fusion::at_c<6>(args); - auto const& vars = boost::fusion::at_c<7>(args); - geom.set_simplify_algorithm(static_cast(get(sym, keys::simplify_algorithm, feat, vars))); - geom.set_simplify_tolerance(get(sym, keys::simplify_tolerance, feat, vars)); + geom.set_simplify_algorithm(static_cast(get(args.sym, keys::simplify_algorithm, args.feature, args.vars))); + geom.set_simplify_tolerance(get(args.sym, keys::simplify_tolerance,args.feature, args.vars)); } }; @@ -140,7 +112,7 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - typename boost::mpl::at >::type box = boost::fusion::at_c<0>(args); + auto const& box = args.bbox; geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy()); } }; @@ -154,10 +126,10 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - typename boost::mpl::at >::type sym = boost::fusion::at_c<2>(args); - auto const& feat = boost::fusion::at_c<6>(args); - auto const& vars = boost::fusion::at_c<7>(args); - double scale_factor = boost::fusion::at_c<8>(args); + auto const& sym = args.sym; + auto const& feat = args.feature; + auto const& vars = args.vars; + double scale_factor = args.scale_factor; auto dash = get_optional(sym, keys::stroke_dasharray, feat, vars); if (dash) { @@ -213,13 +185,13 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - typename boost::mpl::at >::type sym = boost::fusion::at_c<2>(args); - auto const& feat = boost::fusion::at_c<6>(args); - auto const& vars = boost::fusion::at_c<7>(args); + auto const& sym = args.sym; + auto const& feat = args.feature; + auto const& vars = args.vars; set_join_caps(sym, geom, feat, vars); double miterlimit = get(sym, keys::stroke_miterlimit, feat, vars, 4.0); geom.generator().miter_limit(miterlimit); - double scale_factor = boost::fusion::at_c<8>(args); + double scale_factor = args.scale_factor; double width = get(sym, keys::stroke_width, feat, vars, 1.0); geom.generator().width(width * scale_factor); } @@ -233,9 +205,8 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - typename boost::mpl::at >::type box = boost::fusion::at_c<0>(args); + auto const& box = args.bbox; geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy()); - //geom.set_clip_box(box); } }; @@ -245,10 +216,7 @@ struct converter_traits using geometry_type = T; using conv_type = typename agg::conv_close_polygon; template - static void setup(geometry_type & , Args const&) - { - // no-op - } + static void setup(geometry_type & , Args const&) {} }; template @@ -260,8 +228,8 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - geom.set_proj_trans(boost::fusion::at_c<4>(args)); - geom.set_trans(boost::fusion::at_c<3>(args)); + geom.set_proj_trans(args.prj_trans); + geom.set_trans(args.tr); } }; @@ -279,7 +247,7 @@ struct converter_traits template static void setup(geometry_type & geom, Args & args) { - geom.transformer(boost::fusion::at_c<5>(args)); + geom.transformer(args.affine_trans); } }; @@ -292,118 +260,127 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - typename boost::mpl::at >::type sym = boost::fusion::at_c<2>(args); - auto const& feat = boost::fusion::at_c<6>(args); - auto const& vars = boost::fusion::at_c<7>(args); + auto const& sym = args.sym; + auto const& feat = args.feature; + auto const& vars = args.vars; double offset = get(sym, keys::offset, feat, vars); - double scale_factor = boost::fusion::at_c<8>(args); - geom.set_offset(offset * scale_factor); + geom.set_offset(offset * args.scale_factor); } }; -template -struct converter_fwd +template +struct converters_helper; + +template +struct converters_helper { - template - static void forward(Base& base, T0 & geom,T1 const& args) + template + static void set(Dispatcher & disp, int state) { - using geometry_type = T0; - using conv_tag = T2; - using conv_type = typename detail::converter_traits::conv_type; - conv_type conv(geom); - detail::converter_traits::setup(conv,args); - base.template dispatch(conv, typename boost::is_same::type()); - } -}; - -template <> -struct converter_fwd -{ - template - static void forward(Base& base, T0 & geom,T1 const& args) - { - base.template dispatch(geom, typename boost::is_same::type()); - } -}; - -template -struct dispatcher -{ - using this_type = dispatcher; - using args_type = A; - using conv_types = C; - - dispatcher(args_type const& args) - : args_(args) - { - //std::memset(&vec_[0], 0, sizeof(unsigned)*vec_.size()); - std::fill(vec_.begin(), vec_.end(), 0); - } - - template - void dispatch(Geometry & geom, boost::mpl::true_) - { - boost::fusion::at_c<1>(args_).add_path(geom); - } - - template - void dispatch(Geometry & geom, boost::mpl::false_) - { - using conv_tag = typename boost::mpl::deref::type; - using conv_type = typename detail::converter_traits::conv_type; - using Next = typename boost::mpl::next::type; - - std::size_t index = boost::mpl::distance::value - 1; - if (vec_[index] == 1) + if (std::is_same::value) { - converter_fwd::value>:: - template forward(*this,geom,args_); + constexpr std::size_t index = sizeof...(ConverterTypes) ; + disp.vec_[index] = state; } else { - converter_fwd:: - template forward(*this,geom,args_); + converters_helper:: template set(disp, state); } } template - void apply(Geometry & geom) + static void forward(Dispatcher & disp, Geometry & geom) { - using begin = typename boost::mpl::begin::type; - using end = typename boost::mpl::end ::type; - dispatch(geom, boost::false_type()); + constexpr std::size_t index = sizeof...(ConverterTypes); + if (disp.vec_[index] == 1) + { + using conv_type = typename detail::converter_traits::conv_type; + conv_type conv(geom); + detail::converter_traits::setup(conv,disp.args_); + converters_helper::forward(disp, conv); + } + else + { + converters_helper::forward(disp, geom); + } + } +}; + +template +struct converters_helper +{ + template + static void set(Dispatcher & disp, int state) {} + template + static void forward(Dispatcher & disp, Geometry & geom) + { + disp.args_.proc.add_path(geom); + } +}; + +template +struct dispatcher : mapnik::noncopyable +{ + using this_type = dispatcher; + using args_type = Args; + + dispatcher(typename Args::processor_type & proc, box2d const& bbox, symbolizer_base const& sym, view_transform const& tr, + proj_transform const& prj_trans, agg::trans_affine const& affine_trans, feature_impl const& feature, + attributes const& vars, double scale_factor) + : args_(proc,bbox,sym,tr,prj_trans,affine_trans,feature,vars,scale_factor) + { + std::fill(vec_.begin(), vec_.end(), 0); } - std::array::value> vec_; + std::array vec_; args_type args_; }; + +template +struct arguments : mapnik::noncopyable +{ + using processor_type = Processor; + arguments(Processor & proc, box2d const& bbox, symbolizer_base const& sym, view_transform const& tr, + proj_transform const& prj_trans, agg::trans_affine const& affine_trans, feature_impl const& feature, + attributes const& vars, double scale_factor) + : proc(proc), + bbox(bbox), + sym(sym), + tr(tr), + prj_trans(prj_trans), + affine_trans(affine_trans), + feature(feature), + vars(vars), + scale_factor(scale_factor) {} + + Processor & proc; + box2d const& bbox; + symbolizer_base const& sym; + view_transform const& tr; + proj_transform const& prj_trans; + agg::trans_affine const& affine_trans; + feature_impl const& feature; + attributes const& vars; + double scale_factor; +}; + } -template +template struct vertex_converter : private mapnik::noncopyable { - using conv_types = C; - using bbox_type = B; - using rasterizer_type = R; - using symbolizer_type = S; - using trans_type = T; - using proj_trans_type = P; - using affine_trans_type = A; - using feature_type = F; - using args_type = typename boost::fusion::vector< - bbox_type const&, - rasterizer_type&, - symbolizer_type const&, - trans_type const&, - proj_trans_type const&, - affine_trans_type const&, - feature_type const&, - attributes const&, - double //scale-factor - >; + using bbox_type = box2d; + using processor_type = Processor; + using symbolizer_type = symbolizer_base; + using trans_type = view_transform; + using proj_trans_type = proj_transform; + using affine_trans_type = agg::trans_affine; + using feature_type = feature_impl; + using args_type = detail::arguments; + using dispatcher_type = detail::dispatcher; - vertex_converter(bbox_type const& b, - rasterizer_type & ras, + vertex_converter(bbox_type const& bbox, + processor_type & proc, symbolizer_type const& sym, trans_type const& tr, proj_trans_type const& prj_trans, @@ -411,44 +388,27 @@ struct vertex_converter : private mapnik::noncopyable feature_type const& feature, attributes const& vars, double scale_factor) - : disp_(args_type(boost::cref(b), - boost::ref(ras), - boost::cref(sym), - boost::cref(tr), - boost::cref(prj_trans), - boost::cref(affine_trans), - boost::cref(feature), - boost::cref(vars), - scale_factor)) {} + : disp_(proc,bbox,sym,tr,prj_trans,affine_trans,feature,vars,scale_factor) {} template void apply(Geometry & geom) { - using geometry_type = Geometry; - disp_.template apply(geom); + detail::converters_helper:: template forward(disp_, geom); } - template + template void set() { - using iter = typename boost::mpl::find::type; - using end = typename boost::mpl::end::type; - std::size_t index = boost::mpl::distance::value - 1; - if (index < disp_.vec_.size()) - disp_.vec_[index]=1; + detail::converters_helper:: template set(disp_, 1); } - template + template void unset() { - using iter = typename boost::mpl::find::type; - using end = typename boost::mpl::end::type; - std::size_t index = boost::mpl::distance::value - 1; - if (index < disp_.vec_.size()) - disp_.vec_[index]=0; + detail::converters_helper:: template set(disp_, 0); } - detail::dispatcher disp_; + dispatcher_type disp_; }; } diff --git a/include/mapnik/view_transform.hpp b/include/mapnik/view_transform.hpp index 0c4e07d88..683e97947 100644 --- a/include/mapnik/view_transform.hpp +++ b/include/mapnik/view_transform.hpp @@ -24,15 +24,10 @@ #define MAPNIK_VIEW_TRANSFORM_HPP // mapnik -#include #include #include -#include #include -// stl -#include - namespace mapnik { diff --git a/include/mapnik/wkb.hpp b/include/mapnik/wkb.hpp index 7474a0182..2f3052c66 100644 --- a/include/mapnik/wkb.hpp +++ b/include/mapnik/wkb.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include #include namespace mapnik diff --git a/include/mapnik/wkt/wkt_factory.hpp b/include/mapnik/wkt/wkt_factory.hpp index 7fbbaf28d..c546d5953 100644 --- a/include/mapnik/wkt/wkt_factory.hpp +++ b/include/mapnik/wkt/wkt_factory.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include #include // stl diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index 370b83c78..badaa720f 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -29,6 +29,7 @@ // mapnik #include +#include #include namespace mapnik { namespace wkt { diff --git a/plugins/input/pgraster/pgraster_featureset.cpp b/plugins/input/pgraster/pgraster_featureset.cpp index 056d997cf..ee36cc4e6 100644 --- a/plugins/input/pgraster/pgraster_featureset.cpp +++ b/plugins/input/pgraster/pgraster_featureset.cpp @@ -41,7 +41,6 @@ #include #include #include // for int2net -#include // stl #include @@ -245,12 +244,12 @@ pgraster_featureset::~pgraster_featureset() std::string numeric2string(const char* buf) { - boost::int16_t ndigits = int2net(buf); - boost::int16_t weight = int2net(buf+2); - boost::int16_t sign = int2net(buf+4); - boost::int16_t dscale = int2net(buf+6); + std::int16_t ndigits = int2net(buf); + std::int16_t weight = int2net(buf+2); + std::int16_t sign = int2net(buf+4); + std::int16_t dscale = int2net(buf+6); - boost::scoped_array digits(new boost::int16_t[ndigits]); + std::unique_ptr digits(new std::int16_t[ndigits]); for (int n=0; n < ndigits ;++n) { digits[n] = int2net(buf+8+n*2); @@ -260,7 +259,7 @@ std::string numeric2string(const char* buf) if (sign == 0x4000) ss << "-"; - int i = std::max(weight,boost::int16_t(0)); + int i = std::max(weight,std::int16_t(0)); int d = 0; // Each numeric "digit" is actually a value between 0000 and 9999 stored in a 16 bit field. diff --git a/src/agg/process_line_pattern_symbolizer.cpp b/src/agg/process_line_pattern_symbolizer.cpp index 18a2aa005..0aec91a58 100644 --- a/src/agg/process_line_pattern_symbolizer.cpp +++ b/src/agg/process_line_pattern_symbolizer.cpp @@ -122,12 +122,10 @@ void agg_renderer::process(line_pattern_symbolizer const& sym, clip_box.pad(padding); } - using conv_types = boost::mpl::vector; - vertex_converter, rasterizer_type, line_pattern_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clip_box,ras,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set(); //optional clip (default: true) diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp index 110409484..1295e9fab 100644 --- a/src/agg/process_line_symbolizer.cpp +++ b/src/agg/process_line_symbolizer.cpp @@ -116,11 +116,6 @@ void agg_renderer::process(line_symbolizer const& sym, using blender_type = agg::comp_op_adaptor_rgba_pre; // comp blender using pixfmt_comp_type = agg::pixfmt_custom_blend_rgba; using renderer_base = agg::renderer_base; - using conv_types = boost::mpl::vector; pixfmt_comp_type pixf(buf); pixf.comp_op(static_cast(get(sym, keys::comp_op, feature, common_.vars_, src_over))); @@ -170,8 +165,11 @@ void agg_renderer::process(line_symbolizer const& sym, rasterizer_type ras(ren); set_join_caps_aa(sym, ras, feature, common_.vars_); - vertex_converter, rasterizer_type, line_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clip_box,ras,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) converter.set(); // always transform @@ -190,8 +188,11 @@ void agg_renderer::process(line_symbolizer const& sym, } else { - vertex_converter, rasterizer, line_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clip_box,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp index 0c6cdbdfe..c607dfa24 100644 --- a/src/agg/process_polygon_pattern_symbolizer.cpp +++ b/src/agg/process_polygon_pattern_symbolizer.cpp @@ -158,9 +158,7 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, auto transform = get_optional(sym, keys::geometry_transform); if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_); - using conv_types = boost::mpl::vector; - vertex_converter, rasterizer, polygon_pattern_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clip_box,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (prj_trans.equal() && clip) converter.set(); //optional clip (default: true) diff --git a/src/agg/process_polygon_symbolizer.cpp b/src/agg/process_polygon_symbolizer.cpp index 0af6c4f6b..5a5fb492e 100644 --- a/src/agg/process_polygon_symbolizer.cpp +++ b/src/agg/process_polygon_symbolizer.cpp @@ -49,10 +49,7 @@ void agg_renderer::process(polygon_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { - using conv_types = boost::mpl::vector; - using vertex_converter_type = vertex_converter, rasterizer, polygon_symbolizer, - view_transform, proj_transform, agg::trans_affine, - conv_types, feature_impl>; + using vertex_converter_type = vertex_converter; ras_ptr->reset(); double gamma = get(sym, keys::gamma, feature, common_.vars_, 1.0); diff --git a/src/box2d.cpp b/src/box2d.cpp index 167503783..ca73f5551 100644 --- a/src/box2d.cpp +++ b/src/box2d.cpp @@ -26,6 +26,8 @@ // stl #include +#include +#include // boost // fusion @@ -360,6 +362,17 @@ void box2d::move(T x, T y) maxy_ += y; } +template +std::string box2d::to_string() const +{ + std::ostringstream s; + s << "box2d(" << std::fixed << std::setprecision(16) + << minx_ << ',' << miny_ << ',' + << maxx_ << ',' << maxy_ << ')'; + return s.str(); +} + + template box2d& box2d::operator+=(box2d const& other) { diff --git a/src/build.py b/src/build.py index e1cfe37da..e28e9cf88 100644 --- a/src/build.py +++ b/src/build.py @@ -143,6 +143,8 @@ else: # unix, non-macos source = Split( """ font_library.cpp + marker_helpers.cpp + dasharray_parser.cpp expression_grammar.cpp fs.cpp request.cpp diff --git a/src/cairo/process_line_pattern_symbolizer.cpp b/src/cairo/process_line_pattern_symbolizer.cpp index b254573bc..c51c56f9c 100644 --- a/src/cairo/process_line_pattern_symbolizer.cpp +++ b/src/cairo/process_line_pattern_symbolizer.cpp @@ -41,13 +41,6 @@ void cairo_renderer::process(line_pattern_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { - - using conv_types = boost::mpl::vector; - std::string filename = get(sym, keys::file, feature, common_.vars_); composite_mode_e comp_op = get(sym, keys::comp_op, feature, common_.vars_, src_over); bool clip = get(sym, keys::clip, feature, common_.vars_, false); @@ -111,8 +104,11 @@ void cairo_renderer::process(line_pattern_symbolizer const& sym, using rasterizer_type = line_pattern_rasterizer; rasterizer_type ras(context_, *pattern, width, height); - vertex_converter, rasterizer_type, line_pattern_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clipping_extent, ras, sym, common_.t_, prj_trans, tr, feature, common_.vars_, common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) diff --git a/src/cairo/process_line_symbolizer.cpp b/src/cairo/process_line_symbolizer.cpp index b0cbbd9a2..5a18e81ca 100644 --- a/src/cairo/process_line_symbolizer.cpp +++ b/src/cairo/process_line_symbolizer.cpp @@ -36,12 +36,6 @@ void cairo_renderer::process(line_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { - using conv_types = boost::mpl::vector; - composite_mode_e comp_op = get(sym, keys::comp_op, feature, common_.vars_, src_over); bool clip = get(sym, keys::clip, feature, common_.vars_, false); double offset = get(sym, keys::offset, feature, common_.vars_, 0.0); @@ -84,8 +78,13 @@ void cairo_renderer::process(line_symbolizer const& sym, padding *= common_.scale_factor_; clipping_extent.pad(padding); } - vertex_converter, cairo_context, line_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clipping_extent,context_,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) diff --git a/src/cairo/process_polygon_pattern_symbolizer.cpp b/src/cairo/process_polygon_pattern_symbolizer.cpp index b8fe0cc1d..4911a40b3 100644 --- a/src/cairo/process_polygon_pattern_symbolizer.cpp +++ b/src/cairo/process_polygon_pattern_symbolizer.cpp @@ -102,9 +102,7 @@ void cairo_renderer::process(polygon_pattern_symbolizer const& sym, auto geom_transform = get_optional(sym, keys::geometry_transform); if (geom_transform) { evaluate_transform(tr, feature, common_.vars_, *geom_transform, common_.scale_factor_); } - using conv_types = boost::mpl::vector; - vertex_converter, cairo_context, polygon_pattern_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clip_box, context_,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (prj_trans.equal() && clip) converter.set(); //optional clip (default: true) diff --git a/src/cairo/process_polygon_symbolizer.cpp b/src/cairo/process_polygon_symbolizer.cpp index 9db05f60f..190b87e34 100644 --- a/src/cairo/process_polygon_symbolizer.cpp +++ b/src/cairo/process_polygon_symbolizer.cpp @@ -38,11 +38,7 @@ void cairo_renderer::process(polygon_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { - using conv_types = boost::mpl::vector; - using vertex_converter_type = vertex_converter, cairo_context, polygon_symbolizer, - view_transform, proj_transform, agg::trans_affine, - conv_types, feature_impl>; - + using vertex_converter_type = vertex_converter; cairo_save_restore guard(context_); composite_mode_e comp_op = get(sym, keys::comp_op, feature, common_.vars_, src_over); context_.set_operator(comp_op); diff --git a/src/dasharray_parser.cpp b/src/dasharray_parser.cpp new file mode 100644 index 000000000..47eeb8f99 --- /dev/null +++ b/src/dasharray_parser.cpp @@ -0,0 +1,64 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2014 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +// mapnik +#include +#include +#include +#include +#include +#include + +namespace mapnik { + +namespace util { + +bool parse_dasharray(std::string const& value, std::vector& dasharray) +{ + using namespace boost::spirit; + qi::double_type double_; + qi::_1_type _1; + qi::lit_type lit; + qi::char_type char_; + qi::ascii::space_type space; + qi::no_skip_type no_skip; + // SVG + // dasharray ::= (length | percentage) (comma-wsp dasharray)? + // no support for 'percentage' as viewport is unknown at load_map + // + auto first = value.begin(); + auto last = value.end(); + bool r = qi::phrase_parse(first, last, + (double_[boost::phoenix::push_back(boost::phoenix::ref(dasharray), _1)] % + no_skip[char_(", ")] + | lit("none")), + space); + if (first != last) + { + return false; + } + return r; +} + +} // end namespace util + +} // end namespace mapnik diff --git a/src/expression_node.cpp b/src/expression_node.cpp index aeae3d745..69cb53074 100644 --- a/src/expression_node.cpp +++ b/src/expression_node.cpp @@ -22,31 +22,135 @@ #include #include +#include + +#if defined(BOOST_REGEX_HAS_ICU) +#include +#else +#include +#endif namespace mapnik { +struct _regex_match_impl : noncopyable { #if defined(BOOST_REGEX_HAS_ICU) - -regex_match_node::regex_match_node (expr_node const& a, mapnik::value_unicode_string const& ustr) - : expr(a), - pattern(boost::make_u32regex(ustr)) {} - -regex_replace_node::regex_replace_node (expr_node const& a, mapnik::value_unicode_string const& ustr, mapnik::value_unicode_string const& f) - : expr(a), - pattern(boost::make_u32regex(ustr)), - format(f) {} - + _regex_match_impl(value_unicode_string const& ustr) : + pattern_(boost::make_u32regex(ustr)) {} + boost::u32regex pattern_; #else - -regex_match_node::regex_match_node (expr_node const& a, std::string const& str) - : expr(a), - pattern(str) {} - -regex_replace_node::regex_replace_node (expr_node const& a, std::string const& str, std::string const& f) - : expr(a), - pattern(str), - format(f) {} + _regex_match_impl(std::string const& ustr) : + pattern_(ustr) {} + boost::regex pattern_; #endif +}; +struct _regex_replace_impl : noncopyable { +#if defined(BOOST_REGEX_HAS_ICU) + _regex_replace_impl(value_unicode_string const& ustr, value_unicode_string const& f) : + pattern_(boost::make_u32regex(ustr)), + format_(f) {} + boost::u32regex pattern_; + value_unicode_string format_; +#else + _regex_replace_impl(std::string const& ustr,std::string const& f) : + pattern_(ustr), + format_(f) {} + boost::regex pattern_; + std::string format_; +#endif +}; + + +regex_match_node::regex_match_node(transcoder const& tr, + expr_node const& a, + std::string const& ustr) + : expr(a), + impl_(new _regex_match_impl( +#if defined(BOOST_REGEX_HAS_ICU) + tr.transcode(ustr.c_str()) +#else + ustr +#endif + )) {} + +value regex_match_node::apply(value const& v) const +{ + auto const& pattern = impl_.get()->pattern_; +#if defined(BOOST_REGEX_HAS_ICU) + return boost::u32regex_match(v.to_unicode(),pattern); +#else + return boost::regex_match(v.to_string(),pattern); +#endif } + +std::string regex_match_node::to_string() const +{ + std::string str_; + str_ +=".match('"; + auto const& pattern = impl_.get()->pattern_; +#if defined(BOOST_REGEX_HAS_ICU) + std::string utf8; + value_unicode_string ustr = value_unicode_string::fromUTF32( &pattern.str()[0], pattern.str().length()); + to_utf8(ustr,utf8); + str_ += utf8; +#else + str_ += pattern.str(); +#endif + str_ +="')"; + return str_; +} + +regex_replace_node::regex_replace_node(transcoder const& tr, + expr_node const& a, + std::string const& ustr, + std::string const& f) + : expr(a), + impl_(new _regex_replace_impl( +#if defined(BOOST_REGEX_HAS_ICU) + tr.transcode(ustr.c_str()), + tr.transcode(f.c_str()) +#else + ustr, + f +#endif + )) {} + +value regex_replace_node::apply(value const& v) const +{ + auto const& pattern = impl_.get()->pattern_; + auto const& format = impl_.get()->format_; +#if defined(BOOST_REGEX_HAS_ICU) + return boost::u32regex_replace(v.to_unicode(),pattern,format); +#else + std::string repl = boost::regex_replace(v.to_string(),pattern,format); + transcoder tr_("utf8"); + return tr_.transcode(repl.c_str()); +#endif +} + +std::string regex_replace_node::to_string() const +{ + std::string str_; + str_ +=".replace("; + str_ += "'"; + auto const& pattern = impl_.get()->pattern_; + auto const& format = impl_.get()->format_; +#if defined(BOOST_REGEX_HAS_ICU) + std::string utf8; + value_unicode_string ustr = value_unicode_string::fromUTF32( &pattern.str()[0], pattern.str().length()); + to_utf8(ustr,utf8); + str_ += utf8; + str_ +="','"; + to_utf8(format ,utf8); + str_ += utf8; +#else + str_ += pattern.str(); + str_ +="','"; + str_ += format; +#endif + str_ +="')"; + return str_; +} + +} \ No newline at end of file diff --git a/src/expression_string.cpp b/src/expression_string.cpp index 568c79ed4..a5d1386b7 100644 --- a/src/expression_string.cpp +++ b/src/expression_string.cpp @@ -29,10 +29,6 @@ #include #include #include -// boost -#if defined(BOOST_REGEX_HAS_ICU) -#include // for u32regex -#endif namespace mapnik { @@ -94,37 +90,13 @@ struct expression_string : util::static_visitor void operator() (regex_match_node const & x) const { util::apply_visitor(*this,x.expr); - str_ +=".match('"; -#if defined(BOOST_REGEX_HAS_ICU) - std::string utf8; - mapnik::value_unicode_string ustr = mapnik::value_unicode_string::fromUTF32( &x.pattern.str()[0] ,x.pattern.str().length()); - to_utf8(ustr,utf8); - str_ += utf8; -#else - str_ += x.pattern.str(); -#endif - str_ +="')"; + str_ += x.to_string(); } void operator() (regex_replace_node const & x) const { util::apply_visitor(*this,x.expr); - str_ +=".replace("; - str_ += "'"; -#if defined(BOOST_REGEX_HAS_ICU) - std::string utf8; - mapnik::value_unicode_string ustr = mapnik::value_unicode_string::fromUTF32( &x.pattern.str()[0] ,x.pattern.str().length()); - to_utf8(ustr,utf8); - str_ += utf8; - str_ +="','"; - to_utf8(x.format ,utf8); - str_ += utf8; -#else - str_ += x.pattern.str(); - str_ +="','"; - str_ += x.format; -#endif - str_ +="')"; + str_ += x.to_string(); } void operator() (unary_function_call const& call) const diff --git a/src/function_call.cpp b/src/function_call.cpp index 6febc0bfc..99b1435d7 100644 --- a/src/function_call.cpp +++ b/src/function_call.cpp @@ -24,87 +24,6 @@ namespace mapnik { - -// functions -// exp -//template -struct exp_impl -{ - //using type = T; - value_type operator() (value_type const& val) const - { - return std::exp(val.to_double()); - } - -}; - -// sin -struct sin_impl -{ - value_type operator() (value_type const& val) const - { - return std::sin(val.to_double()); - } -}; - -// cos -struct cos_impl -{ - value_type operator() (value_type const& val) const - { - return std::cos(val.to_double()); - } -}; - -// tan -struct tan_impl -{ - value_type operator() (value_type const& val) const - { - return std::tan(val.to_double()); - } -}; - -// atan -struct atan_impl -{ - value_type operator()(value_type const& val) const - { - return std::atan(val.to_double()); - } -}; - -// abs -struct abs_impl -{ - value_type operator() (value_type const& val) const - { - return std::fabs(val.to_double()); - } -}; - -// length -struct length_impl -{ - value_type operator() (value_type const& val) const - { - return val.to_unicode().length(); - } -}; - -unary_function_types::unary_function_types() -{ - add - ("sin", sin_impl()) - ("cos", cos_impl()) - ("tan", tan_impl()) - ("atan", atan_impl()) - ("exp", exp_impl()) - ("abs", abs_impl()) - ("length",length_impl()) - ; -} - char const* unary_function_name(unary_function_impl const& fun) { if (fun.target()) return "sin"; @@ -118,31 +37,6 @@ char const* unary_function_name(unary_function_impl const& fun) } // binary functions -// min -inline value_type min_impl(value_type const& arg1, value_type const& arg2) -{ - return std::min(arg1.to_double(), arg2.to_double()); -} -// max -inline value_type max_impl(value_type const& arg1, value_type const& arg2) -{ - return std::max(arg1.to_double(), arg2.to_double()); -} -// pow -inline value_type pow_impl(value_type const& arg1, value_type const& arg2) -{ - return std::pow(arg1.to_double(), arg2.to_double()); -} - -binary_function_types::binary_function_types() -{ - add - ("min", binary_function_impl(min_impl)) - ("max", binary_function_impl(max_impl)) - ("pow", binary_function_impl(pow_impl)) - ; -} - char const* binary_function_name(binary_function_impl const& fun) { value_type(*const* f_ptr)(value_type const&, value_type const&) = diff --git a/src/grid/process_line_pattern_symbolizer.cpp b/src/grid/process_line_pattern_symbolizer.cpp index e442e1466..64d3e70e9 100644 --- a/src/grid/process_line_pattern_symbolizer.cpp +++ b/src/grid/process_line_pattern_symbolizer.cpp @@ -73,9 +73,7 @@ void grid_renderer::process(line_pattern_symbolizer const& sym, using pixfmt_type = typename grid_renderer_base_type::pixfmt_type; using color_type = typename grid_renderer_base_type::pixfmt_type::color_type; using renderer_type = agg::renderer_scanline_bin_solid; - using conv_types = boost::mpl::vector; + agg::scanline_bin sl; grid_rendering_buffer buf(pixmap_.raw_data(), common_.width_, common_.height_, common_.width_); @@ -119,8 +117,10 @@ void grid_renderer::process(line_pattern_symbolizer const& sym, put(line, keys::simplify_tolerance, value_double(simplify_tolerance)); put(line, keys::smooth, value_double(smooth)); - vertex_converter, grid_rasterizer, line_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clipping_extent,*ras_ptr,line,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) converter.set(); // always transform diff --git a/src/grid/process_line_symbolizer.cpp b/src/grid/process_line_symbolizer.cpp index e9549894f..904322870 100644 --- a/src/grid/process_line_symbolizer.cpp +++ b/src/grid/process_line_symbolizer.cpp @@ -50,9 +50,7 @@ void grid_renderer::process(line_symbolizer const& sym, using pixfmt_type = typename grid_renderer_base_type::pixfmt_type; using color_type = typename grid_renderer_base_type::pixfmt_type::color_type; using renderer_type = agg::renderer_scanline_bin_solid; - using conv_types = boost::mpl::vector; + agg::scanline_bin sl; grid_rendering_buffer buf(pixmap_.raw_data(), common_.width_, common_.height_, common_.width_); @@ -91,8 +89,9 @@ void grid_renderer::process(line_symbolizer const& sym, clipping_extent.pad(padding); } - vertex_converter, grid_rasterizer, line_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clipping_extent,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) converter.set(); // always transform diff --git a/src/grid/process_markers_symbolizer.cpp b/src/grid/process_markers_symbolizer.cpp index 7b6e43eb5..bf0828cd4 100644 --- a/src/grid/process_markers_symbolizer.cpp +++ b/src/grid/process_markers_symbolizer.cpp @@ -53,7 +53,6 @@ porting notes --> #include #include -#include #include #include #include diff --git a/src/grid/process_polygon_pattern_symbolizer.cpp b/src/grid/process_polygon_pattern_symbolizer.cpp index 6d4e319d5..45492c1ec 100644 --- a/src/grid/process_polygon_pattern_symbolizer.cpp +++ b/src/grid/process_polygon_pattern_symbolizer.cpp @@ -77,9 +77,7 @@ void grid_renderer::process(polygon_pattern_symbolizer const& sym, evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_); } - using conv_types = boost::mpl::vector; - vertex_converter, grid_rasterizer, polygon_pattern_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(common_.query_extent_,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (prj_trans.equal() && clip) converter.set(); //optional clip (default: true) diff --git a/src/grid/process_polygon_symbolizer.cpp b/src/grid/process_polygon_symbolizer.cpp index 2155c6fc4..f06893e96 100644 --- a/src/grid/process_polygon_symbolizer.cpp +++ b/src/grid/process_polygon_symbolizer.cpp @@ -53,10 +53,7 @@ void grid_renderer::process(polygon_symbolizer const& sym, using renderer_type = agg::renderer_scanline_bin_solid; using pixfmt_type = typename grid_renderer_base_type::pixfmt_type; using color_type = typename grid_renderer_base_type::pixfmt_type::color_type; - using conv_types = boost::mpl::vector; - using vertex_converter_type = vertex_converter, grid_rasterizer, polygon_symbolizer, - view_transform, proj_transform, agg::trans_affine, - conv_types, feature_impl>; + using vertex_converter_type = vertex_converter; ras_ptr->reset(); diff --git a/src/marker_helpers.cpp b/src/marker_helpers.cpp new file mode 100644 index 000000000..dfc7e2f91 --- /dev/null +++ b/src/marker_helpers.cpp @@ -0,0 +1,150 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2014 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +// mapnik +#include + +namespace mapnik { + +void build_ellipse(symbolizer_base const& sym, mapnik::feature_impl & feature, attributes const& vars, svg_storage_type & marker_ellipse, svg::svg_path_adapter & svg_path) +{ + double width = 0.0; + double height = 0.0; + if (has_key(sym,keys::width) && has_key(sym,keys::height)) + { + width = get(sym, keys::width, feature, vars, 0.0); + height = get(sym, keys::height, feature, vars, 0.0); + } + else if (has_key(sym,keys::width)) + { + width = height = get(sym, keys::width, feature, vars, 0.0); + } + else if (has_key(sym,keys::height)) + { + width = height = get(sym, keys::height, feature, vars, 0.0); + } + svg::svg_converter_type styled_svg(svg_path, marker_ellipse.attributes()); + styled_svg.push_attr(); + styled_svg.begin_path(); + agg::ellipse c(0, 0, width/2.0, height/2.0); + styled_svg.storage().concat_path(c); + styled_svg.end_path(); + styled_svg.pop_attr(); + double lox,loy,hix,hiy; + styled_svg.bounding_rect(&lox, &loy, &hix, &hiy); + styled_svg.set_dimensions(width,height); + marker_ellipse.set_dimensions(width,height); + marker_ellipse.set_bounding_box(lox,loy,hix,hiy); +} + +bool push_explicit_style(svg_attribute_type const& src, + svg_attribute_type & dst, + symbolizer_base const& sym, + feature_impl & feature, + attributes const& vars) +{ + auto fill_color = get_optional(sym, keys::fill, feature, vars); + auto fill_opacity = get_optional(sym, keys::fill_opacity, feature, vars); + auto stroke_color = get_optional(sym, keys::stroke, feature, vars); + auto stroke_width = get_optional(sym, keys::stroke_width, feature, vars); + auto stroke_opacity = get_optional(sym, keys::stroke_opacity, feature, vars); + if (fill_color || + fill_opacity || + stroke_color || + stroke_width || + stroke_opacity) + { + bool success = false; + for(unsigned i = 0; i < src.size(); ++i) + { + success = true; + dst.push_back(src[i]); + mapnik::svg::path_attributes & attr = dst.last(); + if (attr.stroke_flag) + { + if (stroke_width) + { + attr.stroke_width = *stroke_width; + } + if (stroke_color) + { + color const& s_color = *stroke_color; + attr.stroke_color = agg::rgba(s_color.red()/255.0, + s_color.green()/255.0, + s_color.blue()/255.0, + s_color.alpha()/255.0); + } + if (stroke_opacity) + { + attr.stroke_opacity = *stroke_opacity; + } + } + if (attr.fill_flag) + { + if (fill_color) + { + color const& f_color = *fill_color; + attr.fill_color = agg::rgba(f_color.red()/255.0, + f_color.green()/255.0, + f_color.blue()/255.0, + f_color.alpha()/255.0); + } + if (fill_opacity) + { + attr.fill_opacity = *fill_opacity; + } + } + } + return success; + } + return false; +} + +void setup_transform_scaling(agg::trans_affine & tr, + double svg_width, + double svg_height, + mapnik::feature_impl & feature, + attributes const& vars, + symbolizer_base const& sym) +{ + double width = get(sym, keys::width, feature, vars, 0.0); + double height = get(sym, keys::height, feature, vars, 0.0); + if (width > 0 && height > 0) + { + double sx = width/svg_width; + double sy = height/svg_height; + tr *= agg::trans_affine_scaling(sx,sy); + } + else if (width > 0) + { + double sx = width/svg_width; + tr *= agg::trans_affine_scaling(sx); + } + else if (height > 0) + { + double sy = height/svg_height; + tr *= agg::trans_affine_scaling(sy); + } +} + + +} // end namespace mapnik diff --git a/src/text/font_feature_settings.cpp b/src/text/font_feature_settings.cpp index c4dce260a..0a985c20e 100644 --- a/src/text/font_feature_settings.cpp +++ b/src/text/font_feature_settings.cpp @@ -58,7 +58,7 @@ void font_feature_settings::from_string(std::string const& features) if (!qi::parse(features.begin(), features.end(), as_string[+(char_ - ',')][app] % ',')) { - throw config_error("failed to parse font-features: '" + features + "'"); + throw config_error("failed to parse font-feature-settings: '" + features + "'"); } } @@ -91,7 +91,7 @@ void font_feature_settings::append(std::string const& feature) if (!hb_feature_from_string(feature.c_str(), feature.length(), &*current_feature)) { features_.erase(current_feature); - throw config_error("failed to parse font-features: '" + feature + "'"); + throw config_error("failed to parse font-feature-settings: '" + feature + "'"); } } diff --git a/src/unicode.cpp b/src/unicode.cpp index 22114d156..4c703a2cb 100644 --- a/src/unicode.cpp +++ b/src/unicode.cpp @@ -28,6 +28,9 @@ #include #include +// icu +#include + namespace mapnik { transcoder::transcoder (std::string const& encoding) diff --git a/src/wkb.cpp b/src/wkb.cpp index b85d1532b..2f028a5c2 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -128,7 +128,7 @@ public: needSwap_ = byteOrder_ ? wkbXDR : wkbNDR; } - void read(boost::ptr_vector & paths) + void read(geometry_container & paths) { int type = read_integer(); @@ -307,7 +307,7 @@ private: } } - void read_point(boost::ptr_vector & paths) + void read_point(geometry_container & paths) { double x = read_double(); double y = read_double(); @@ -316,7 +316,7 @@ private: paths.push_back(pt.release()); } - void read_multipoint(boost::ptr_vector & paths) + void read_multipoint(geometry_container & paths) { int num_points = read_integer(); for (int i = 0; i < num_points; ++i) @@ -326,7 +326,7 @@ private: } } - void read_point_xyz(boost::ptr_vector & paths) + void read_point_xyz(geometry_container & paths) { double x = read_double(); double y = read_double(); @@ -336,7 +336,7 @@ private: paths.push_back(pt.release()); } - void read_point_xyzm(boost::ptr_vector & paths) + void read_point_xyzm(geometry_container & paths) { double x = read_double(); double y = read_double(); @@ -346,7 +346,7 @@ private: paths.push_back(pt.release()); } - void read_multipoint_xyz(boost::ptr_vector & paths) + void read_multipoint_xyz(geometry_container & paths) { int num_points = read_integer(); for (int i = 0; i < num_points; ++i) @@ -356,7 +356,7 @@ private: } } - void read_multipoint_xyzm(boost::ptr_vector & paths) + void read_multipoint_xyzm(geometry_container & paths) { int num_points = read_integer(); for (int i = 0; i < num_points; ++i) @@ -366,7 +366,7 @@ private: } } - void read_linestring(boost::ptr_vector & paths) + void read_linestring(geometry_container & paths) { int num_points = read_integer(); if (num_points > 0) @@ -383,7 +383,7 @@ private: } } - void read_multilinestring(boost::ptr_vector & paths) + void read_multilinestring(geometry_container & paths) { int num_lines = read_integer(); for (int i = 0; i < num_lines; ++i) @@ -393,7 +393,7 @@ private: } } - void read_linestring_xyz(boost::ptr_vector & paths) + void read_linestring_xyz(geometry_container & paths) { int num_points = read_integer(); if (num_points > 0) @@ -410,7 +410,7 @@ private: } } - void read_linestring_xyzm(boost::ptr_vector & paths) + void read_linestring_xyzm(geometry_container & paths) { int num_points = read_integer(); if (num_points > 0) @@ -427,7 +427,7 @@ private: } } - void read_multilinestring_xyz(boost::ptr_vector & paths) + void read_multilinestring_xyz(geometry_container & paths) { int num_lines = read_integer(); for (int i = 0; i < num_lines; ++i) @@ -437,7 +437,7 @@ private: } } - void read_multilinestring_xyzm(boost::ptr_vector & paths) + void read_multilinestring_xyzm(geometry_container & paths) { int num_lines = read_integer(); for (int i = 0; i < num_lines; ++i) @@ -447,7 +447,7 @@ private: } } - void read_polygon(boost::ptr_vector & paths) + void read_polygon(geometry_container & paths) { int num_rings = read_integer(); if (num_rings > 0) @@ -473,7 +473,7 @@ private: } } - void read_multipolygon(boost::ptr_vector & paths) + void read_multipolygon(geometry_container & paths) { int num_polys = read_integer(); for (int i = 0; i < num_polys; ++i) @@ -483,7 +483,7 @@ private: } } - void read_polygon_xyz(boost::ptr_vector & paths) + void read_polygon_xyz(geometry_container & paths) { int num_rings = read_integer(); if (num_rings > 0) @@ -509,7 +509,7 @@ private: } } - void read_polygon_xyzm(boost::ptr_vector & paths) + void read_polygon_xyzm(geometry_container & paths) { int num_rings = read_integer(); if (num_rings > 0) @@ -535,7 +535,7 @@ private: } } - void read_multipolygon_xyz(boost::ptr_vector & paths) + void read_multipolygon_xyz(geometry_container & paths) { int num_polys = read_integer(); for (int i = 0; i < num_polys; ++i) @@ -545,7 +545,7 @@ private: } } - void read_multipolygon_xyzm(boost::ptr_vector & paths) + void read_multipolygon_xyzm(geometry_container & paths) { int num_polys = read_integer(); for (int i = 0; i < num_polys; ++i) @@ -555,7 +555,7 @@ private: } } - void read_collection(boost::ptr_vector & paths) + void read_collection(geometry_container & paths) { int num_geometries = read_integer(); for (int i = 0; i < num_geometries; ++i) @@ -607,7 +607,7 @@ private: }; -bool geometry_utils::from_wkb(boost::ptr_vector& paths, +bool geometry_utils::from_wkb(geometry_container& paths, const char* wkb, unsigned size, wkbFormat format) diff --git a/tests/cpp_tests/geometry_converters_test.cpp b/tests/cpp_tests/geometry_converters_test.cpp index 618c67c6e..7545b4728 100644 --- a/tests/cpp_tests/geometry_converters_test.cpp +++ b/tests/cpp_tests/geometry_converters_test.cpp @@ -60,11 +60,9 @@ boost::optional linestring_bbox_clipping(mapnik::box2d bbox mapnik::geometry_container output_paths; output_geometry_backend backend(output_paths, mapnik::geometry_type::types::LineString); - using conv_types = boost::mpl::vector; mapnik::context_ptr ctx = std::make_shared(); mapnik::feature_impl f(ctx,0); - vertex_converter, output_geometry_backend, line_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(bbox, backend, sym, t, prj_trans, tr, f, attributes(), 1.0); converter.set(); @@ -104,11 +102,9 @@ boost::optional polygon_bbox_clipping(mapnik::box2d bbox, mapnik::geometry_container output_paths; output_geometry_backend backend(output_paths, mapnik::geometry_type::types::Polygon); - using conv_types = boost::mpl::vector; mapnik::context_ptr ctx = std::make_shared(); mapnik::feature_impl f(ctx,0); - vertex_converter, output_geometry_backend, polygon_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(bbox, backend, sym, t, prj_trans, tr, f, attributes(), 1.0); converter.set(); diff --git a/utils/geometry_to_wkb/main.cpp b/utils/geometry_to_wkb/main.cpp index b8048f283..76396ff24 100644 --- a/utils/geometry_to_wkb/main.cpp +++ b/utils/geometry_to_wkb/main.cpp @@ -81,7 +81,7 @@ int main (int argc, char ** argv ) while(f) { std::cerr << *f << std::endl; - boost::ptr_vector & paths = f->paths(); + mapnik::geometry_container const& paths = f->paths(); for (mapnik::geometry_type const& geom : paths) { // NDR