From 9c0046fb61e60895f4ddded21865426b0f6a3e73 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 30 Sep 2014 14:44:02 +0100 Subject: [PATCH 1/8] reduce compile time by minimizing template instantiaions --- include/mapnik/marker_helpers.hpp | 6 +++--- include/mapnik/vertex_converters.hpp | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp index 76ce9992f..c06e6aab4 100644 --- a/include/mapnik/marker_helpers.hpp +++ b/include/mapnik/marker_helpers.hpp @@ -438,7 +438,7 @@ void apply_markers_multi(feature_impl const& feature, attributes const& vars, Co std::size_t geom_count = feature.paths().size(); if (geom_count == 1) { - converter.apply(feature.paths()[0]); + converter.apply(const_cast(feature.paths()[0])); } else if (geom_count > 1) { @@ -477,7 +477,7 @@ void apply_markers_multi(feature_impl const& feature, attributes const& vars, Co } if (largest) { - converter.apply(*largest); + converter.apply(const_cast(*largest)); } } else @@ -488,7 +488,7 @@ void apply_markers_multi(feature_impl const& feature, attributes const& vars, Co } for (geometry_type const& path : feature.paths()) { - converter.apply(path); + converter.apply(const_cast(path)); } } } diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index a41fab982..0e191c277 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -37,7 +37,7 @@ #include #include #include - +#include // agg #include "agg_math_stroke.h" #include "agg_trans_affine.h" @@ -390,10 +390,9 @@ struct vertex_converter : private mapnik::noncopyable double scale_factor) : disp_(proc,bbox,sym,tr,prj_trans,affine_trans,feature,vars,scale_factor) {} - template - void apply(Geometry & geom) + void apply(geometry_type & geom) { - detail::converters_helper:: template forward(disp_, geom); + detail::converters_helper:: template forward(disp_, geom); } template From da2c0a6949a2327721d68142ac4e9a13a776d75a Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Tue, 30 Sep 2014 15:58:29 +0200 Subject: [PATCH 2/8] Use std uint8_t instead of boost::uint8_t Broke compilation --- plugins/input/pgraster/pgraster_wkb_reader.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/input/pgraster/pgraster_wkb_reader.cpp b/plugins/input/pgraster/pgraster_wkb_reader.cpp index f67950a98..586f3f0ed 100644 --- a/plugins/input/pgraster/pgraster_wkb_reader.cpp +++ b/plugins/input/pgraster/pgraster_wkb_reader.cpp @@ -40,6 +40,8 @@ // boost #include +#include + namespace { uint8_t @@ -48,7 +50,7 @@ read_uint8(const uint8_t** from) { } uint16_t -read_uint16(const boost::uint8_t** from, boost::uint8_t littleEndian) { +read_uint16(const uint8_t** from, uint8_t littleEndian) { uint16_t ret = 0; if (littleEndian) { @@ -71,7 +73,7 @@ read_int16(const uint8_t** from, uint8_t littleEndian) { } double -read_float64(const boost::uint8_t** from, boost::uint8_t littleEndian) { +read_float64(const uint8_t** from, uint8_t littleEndian) { union { double d; @@ -104,7 +106,7 @@ read_float64(const boost::uint8_t** from, boost::uint8_t littleEndian) { } uint32_t -read_uint32(const boost::uint8_t** from, boost::uint8_t littleEndian) { +read_uint32(const uint8_t** from, uint8_t littleEndian) { uint32_t ret = 0; if (littleEndian) { @@ -125,7 +127,7 @@ read_uint32(const boost::uint8_t** from, boost::uint8_t littleEndian) { } int32_t -read_int32(const boost::uint8_t** from, boost::uint8_t littleEndian) { +read_int32(const uint8_t** from, uint8_t littleEndian) { return read_uint32(from, littleEndian); } From c4ee28cf1b708df1fe1d74dc8c0f051b755f899f Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 30 Sep 2014 08:57:54 -0700 Subject: [PATCH 3/8] install doc: note minimum harfbuzz version for font-feature-settings - refs #2456 --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index fa95edc69..c75eccbe0 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -69,7 +69,7 @@ Mapnik Core depends on: * libz - Zlib compression * libfreetype - Freetype2 for font support (Install requires freetype-config) * libxml2 - XML parsing (Install requires xml2-config) - * libharfbuzz - an OpenType text shaping engine + * libharfbuzz - an OpenType text shaping engine (>=0.9.34 needed for CSS font-feature-settings support) Mapnik Core optionally depends on: From 092e2c091360abc6d272e7a8c691cf1882ff79d9 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 30 Sep 2014 08:58:33 -0700 Subject: [PATCH 4/8] travis: use harfbuzz v0.9.35 --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ca242bc0b..3cb0c6bb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,9 +37,9 @@ before_script: - psql -U postgres -c 'create extension postgis' -d template_postgis - if [[ "${CXX}" == 'g++' ]]; then sudo apt-get install gcc-4.8 g++-4.8; export CXX="$(which g++-4.8)"; export CC="$(which gcc-4.8)"; fi; - if [[ "${CXX}" == 'clang++' ]]; then export CXX="$(which clang++)"; export CC="$(which clang)"; fi; - - wget http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-0.9.34.tar.bz2 - - tar xf harfbuzz-0.9.34.tar.bz2 - - cd harfbuzz-0.9.34 + - wget http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-0.9.35.tar.bz2 + - tar xf harfbuzz-0.9.35.tar.bz2 + - cd harfbuzz-0.9.35 - ./configure --prefix=/usr --with-icu --with-cairo=no --with-glib=no --with-gobject=no --with-graphite2=no --with-freetype --with-uniscribe=no --with-coretext=no && make -j2 && sudo make -j2 install - cd ../ From 6be1eb94c2f5fe3ea46e9239dff047e716a0d6b7 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 30 Sep 2014 10:19:25 -0700 Subject: [PATCH 5/8] Revert "ditch boost/function" - refs #2465 This reverts commit 24052580b951f1d58a5a0edaf81572b3e8267836. --- include/mapnik/markers_placement.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/mapnik/markers_placement.hpp b/include/mapnik/markers_placement.hpp index 52aecc3d9..6db046a33 100644 --- a/include/mapnik/markers_placement.hpp +++ b/include/mapnik/markers_placement.hpp @@ -31,9 +31,7 @@ #include #include #include - -// stl -#include +#include namespace mapnik { @@ -88,7 +86,7 @@ private: Detector &detector, markers_placement_params const& params) { - static const std::map> factories = From 985ddb3aebf9498af73ef2ecc5e129c23f161fa3 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 30 Sep 2014 12:12:58 -0700 Subject: [PATCH 6/8] fix compile of (currently unsed) symbolizer_grammar.hpp --- include/mapnik/json/symbolizer_grammar.hpp | 30 ++++++++++------------ 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/include/mapnik/json/symbolizer_grammar.hpp b/include/mapnik/json/symbolizer_grammar.hpp index 5f5ebe7c6..5f1a7c32e 100644 --- a/include/mapnik/json/symbolizer_grammar.hpp +++ b/include/mapnik/json/symbolizer_grammar.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_SYMBOLIZER_GRAMMAR_HPP #define MAPNIK_SYMBOLIZER_GRAMMAR_HPP +#include + // boost #include #include @@ -122,21 +124,15 @@ struct symbolizer_grammar : qi::grammar : symbolizer_grammar::base_type(sym, "symbolizer"), json_() { - using qi::lit; - using qi::double_; - using qi::int_; - using qi::no_skip; - using qi::omit; - using qi::_val; - using qi::_a; - using qi::_r1; - using qi::_1; - using qi::_2; - using qi::_3; - using qi::_4; - using qi::fail; - using qi::on_error; - using standard_wide::char_; + qi::lit_type lit; + qi::double_type double_; + qi::int_type int_; + qi::no_skip_type no_skip; + qi::_val_type _val; + qi::_a_type _a; + qi::_r1_type _r1; + qi::_1_type _1; + standard_wide::char_type char_; using phoenix::construct; // generic json types @@ -197,7 +193,7 @@ struct symbolizer_grammar : qi::grammar property = (json_.string_ [_a = _1] >> lit(':') >> property_value [put_property_(_r1,_a,_1)]) % lit(',') ; - property_value %= json.number | json.string_ ; + property_value %= json_.number | json_.string_ ; } @@ -211,7 +207,7 @@ struct symbolizer_grammar : qi::grammar phoenix::function put_property_; // error - on_error(sym, error_handler(_1, _2, _3, _4)); + //qi::on_error(sym, error_handler(_1, _2, _3, _4)); }; From 822d3a5bce70d85857fb5a91a7f1056f0a2f4377 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 30 Sep 2014 12:50:08 -0700 Subject: [PATCH 7/8] break apart symbolizer.hpp + fwd declars + svg output grammar impl --- demo/c++/rundemo.cpp | 1 + include/mapnik/cairo/cairo_context.hpp | 3 +- include/mapnik/expression_evaluator.hpp | 1 + include/mapnik/group/group_rule.hpp | 6 +- include/mapnik/parse_transform.hpp | 2 +- .../process_point_symbolizer.hpp | 1 + .../process_raster_symbolizer.hpp | 1 + include/mapnik/request.hpp | 3 - include/mapnik/rule.hpp | 2 +- .../svg/output/svg_output_attributes.hpp | 3 +- .../mapnik/svg/output/svg_output_grammars.hpp | 97 +++----------- include/mapnik/symbolizer.hpp | 124 +----------------- include/mapnik/symbolizer_hash.hpp | 2 +- include/mapnik/symbolizer_utils.hpp | 4 +- include/mapnik/text/formatting/format.hpp | 8 +- include/mapnik/text/formatting/list.hpp | 7 +- include/mapnik/text/formatting/text.hpp | 5 +- include/mapnik/text/placement_finder.hpp | 3 +- include/mapnik/text/placements_list.hpp | 1 - include/mapnik/text/properties_util.hpp | 6 +- include/mapnik/text/renderer.hpp | 2 +- include/mapnik/text/symbolizer_helpers.hpp | 11 +- include/mapnik/text/text_properties.hpp | 16 ++- src/agg/process_building_symbolizer.cpp | 1 + src/agg/process_debug_symbolizer.cpp | 1 + src/build.py | 1 + src/cairo/process_building_symbolizer.cpp | 1 + src/cairo/process_debug_symbolizer.cpp | 1 + src/cairo/process_raster_symbolizer.cpp | 1 + src/cairo/process_text_symbolizer.cpp | 2 +- src/grid/process_building_symbolizer.cpp | 4 +- .../process_group_symbolizer.cpp | 2 + src/rule.cpp | 1 + src/svg/output/process_line_symbolizer.cpp | 2 + src/svg/output/process_polygon_symbolizer.cpp | 2 + src/svg/output/process_symbolizers.cpp | 1 + src/text/formatting/format.cpp | 1 + src/text/formatting/list.cpp | 2 +- src/text/formatting/text.cpp | 1 + src/text/placement_finder.cpp | 1 + src/text/properties_util.cpp | 2 + src/text/symbolizer_helpers.cpp | 3 + src/text/text_layout.cpp | 2 + src/text/text_properties.cpp | 1 + 44 files changed, 103 insertions(+), 239 deletions(-) diff --git a/demo/c++/rundemo.cpp b/demo/c++/rundemo.cpp index ad04146e8..217a0c3e2 100644 --- a/demo/c++/rundemo.cpp +++ b/demo/c++/rundemo.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/include/mapnik/cairo/cairo_context.hpp b/include/mapnik/cairo/cairo_context.hpp index 78ee4bd86..bff4e7baa 100644 --- a/include/mapnik/cairo/cairo_context.hpp +++ b/include/mapnik/cairo/cairo_context.hpp @@ -34,7 +34,8 @@ #include #include #include -#include +#include +#include // stl #include diff --git a/include/mapnik/expression_evaluator.hpp b/include/mapnik/expression_evaluator.hpp index c8b94a95e..e766a4ecd 100644 --- a/include/mapnik/expression_evaluator.hpp +++ b/include/mapnik/expression_evaluator.hpp @@ -29,6 +29,7 @@ #include #include #include +#include namespace mapnik { diff --git a/include/mapnik/group/group_rule.hpp b/include/mapnik/group/group_rule.hpp index 267093b78..71dd7df79 100644 --- a/include/mapnik/group/group_rule.hpp +++ b/include/mapnik/group/group_rule.hpp @@ -25,9 +25,13 @@ // mapnik #include -#include +#include +#include #include +#include +#include + namespace mapnik { diff --git a/include/mapnik/parse_transform.hpp b/include/mapnik/parse_transform.hpp index 79c462ef8..b19c448bc 100644 --- a/include/mapnik/parse_transform.hpp +++ b/include/mapnik/parse_transform.hpp @@ -25,7 +25,7 @@ // mapnik #include -#include // for transform_list_ptr +#include // for transform_list_ptr namespace mapnik { diff --git a/include/mapnik/renderer_common/process_point_symbolizer.hpp b/include/mapnik/renderer_common/process_point_symbolizer.hpp index b9c728144..22778a312 100644 --- a/include/mapnik/renderer_common/process_point_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_point_symbolizer.hpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/include/mapnik/renderer_common/process_raster_symbolizer.hpp b/include/mapnik/renderer_common/process_raster_symbolizer.hpp index 08d900088..2fdeca64f 100644 --- a/include/mapnik/renderer_common/process_raster_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_raster_symbolizer.hpp @@ -26,6 +26,7 @@ // mapnik #include #include +#include #include #include #include diff --git a/include/mapnik/request.hpp b/include/mapnik/request.hpp index 9a4b99cf0..8f5272b31 100644 --- a/include/mapnik/request.hpp +++ b/include/mapnik/request.hpp @@ -27,9 +27,6 @@ #include #include -// boost -#include - namespace mapnik { diff --git a/include/mapnik/rule.hpp b/include/mapnik/rule.hpp index 7fd5dd98b..bc3168598 100644 --- a/include/mapnik/rule.hpp +++ b/include/mapnik/rule.hpp @@ -25,7 +25,7 @@ // mapnik #include -#include +#include #include // stl diff --git a/include/mapnik/svg/output/svg_output_attributes.hpp b/include/mapnik/svg/output/svg_output_attributes.hpp index eb1e8b6b6..8bdf6a358 100644 --- a/include/mapnik/svg/output/svg_output_attributes.hpp +++ b/include/mapnik/svg/output/svg_output_attributes.hpp @@ -25,7 +25,8 @@ // mapnik #include -#include +#include +#include // stl #include diff --git a/include/mapnik/svg/output/svg_output_grammars.hpp b/include/mapnik/svg/output/svg_output_grammars.hpp index e607e67da..2f59b1d92 100644 --- a/include/mapnik/svg/output/svg_output_grammars.hpp +++ b/include/mapnik/svg/output/svg_output_grammars.hpp @@ -25,24 +25,21 @@ // mapnik #include -#include +#include + +#include // fwd declare namespace mapnik { namespace svg { - struct path_output_attributes; - struct rect_output_attributes; - struct root_output_attributes; -} } + struct path_output_attributes; + struct rect_output_attributes; + struct root_output_attributes; +}} // boost -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include /*! * mapnik::svg::path_output_attributes is adapted as a fusion sequence @@ -61,7 +58,7 @@ BOOST_FUSION_ADAPT_STRUCT( (std::string, stroke_linecap_) (std::string, stroke_linejoin_) (double, stroke_dashoffset_) - ) + ); /*! * mapnik::svg::rect_output_attributes is adapted as a fusion sequence @@ -74,7 +71,7 @@ BOOST_FUSION_ADAPT_STRUCT( (unsigned, width_) (unsigned, height_) (std::string, fill_color_) - ) + ); /*! * mapnik::svg::root_output_attributes is adapted as a fusion sequence @@ -86,98 +83,38 @@ BOOST_FUSION_ADAPT_STRUCT( (unsigned, height_) (double, svg_version_) (std::string, svg_namespace_url_) - ) + ); namespace mapnik { namespace svg { using namespace boost::spirit; - using namespace boost::phoenix; template struct svg_path_attributes_grammar : karma::grammar { - explicit svg_path_attributes_grammar() - : svg_path_attributes_grammar::base_type(svg_path_attributes) - { - karma::lit_type lit; - karma::double_type double_; - karma::string_type kstring; - - svg_path_attributes = - lit("fill=\"") - << kstring - << lit("\" fill-opacity=\"") << double_ - << lit("\" stroke=\"") << kstring - << lit("\" stroke-opacity=\"") << double_ - << lit("\" stroke-width=\"") << double_ << lit("px") - << lit("\" stroke-linecap=\"") << kstring - << lit("\" stroke-linejoin=\"") << kstring - << lit("\" stroke-dashoffset=\"") << double_ << lit("px") << lit('"'); - } - + explicit svg_path_attributes_grammar(); karma::rule svg_path_attributes; }; template struct svg_path_dash_array_grammar : karma::grammar { - explicit svg_path_dash_array_grammar() - : svg_path_dash_array_grammar::base_type(svg_path_dash_array) - { - karma::double_type double_; - karma::lit_type lit; - - svg_path_dash_array = lit("stroke-dasharray=\"") << - -((double_ << lit(',') << double_) % lit(',')) << lit('"'); - } - + explicit svg_path_dash_array_grammar(); karma::rule svg_path_dash_array; }; template struct svg_rect_attributes_grammar : karma::grammar { - explicit svg_rect_attributes_grammar() - : svg_rect_attributes_grammar::base_type(svg_rect_attributes) - { - karma::lit_type lit; - karma::int_type int_; - karma::string_type kstring; - - svg_rect_attributes = - lit("x=\"") - << int_ - << lit("\" y=\"") << int_ - << lit("\" width=\"") << int_ << lit("px") - << lit("\" height=\"") << int_ << lit("px") - << lit("\" fill=\"") << kstring << lit('"'); - } - + explicit svg_rect_attributes_grammar(); karma::rule svg_rect_attributes; }; template struct svg_root_attributes_grammar : karma::grammar { - explicit svg_root_attributes_grammar() - : svg_root_attributes_grammar::base_type(svg_root_attributes) - { - karma::lit_type lit; - karma::int_type int_; - karma::string_type kstring; - karma::double_type double_; - - svg_root_attributes = - lit("width=\"") - << int_ - << lit("px") - << lit("\" height=\"") << int_ << lit("px") - << lit("\" version=\"") << double_ - << lit("\" xmlns=\"") << kstring - << lit("\" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\""); - } - + explicit svg_root_attributes_grammar(); karma::rule svg_root_attributes; }; } diff --git a/include/mapnik/symbolizer.hpp b/include/mapnik/symbolizer.hpp index 649c47fcd..f67d5aef6 100644 --- a/include/mapnik/symbolizer.hpp +++ b/include/mapnik/symbolizer.hpp @@ -25,7 +25,6 @@ // mapnik #include -#include #include #include #include @@ -36,9 +35,8 @@ #include #include #include -#include -#include #include +#include #include #include #include @@ -46,7 +44,6 @@ // stl #include -#include #include #include #include @@ -57,95 +54,9 @@ // boost #include -namespace agg { struct trans_affine; } - namespace mapnik { -// fwd declares -// TODO - move these transform declares to own header -namespace detail { struct transform_node; } -using transform_list = std::vector; -using transform_list_ptr = std::shared_ptr; -using transform_type = transform_list_ptr; -class feature_impl; - -MAPNIK_DECL void evaluate_transform(agg::trans_affine& tr, - feature_impl const& feature, - attributes const& vars, - transform_type const& trans_expr, - double scale_factor=1.0); - -struct enumeration_wrapper -{ - int value; - enumeration_wrapper() = delete; - template - explicit enumeration_wrapper(T value_) - : value(value_) {} - - inline operator int() const - { - return value; - } -}; - -using dash_array = std::vector >; - -class text_placements; -using text_placements_ptr = std::shared_ptr; - -namespace detail { - -using value_base_type = util::variant; - -struct strict_value : value_base_type -{ - // default ctor - strict_value() - : value_base_type() {} - // copy ctor - strict_value(const char* val) - : value_base_type(val) {} - - template - strict_value(T const& obj) - : value_base_type(typename detail::mapnik_value_type::type(obj)) - {} - // move ctor - template - strict_value(T && obj) noexcept - : value_base_type(std::move(obj)) {} - -}; -} - -struct MAPNIK_DECL symbolizer_base -{ - using value_type = detail::strict_value; - using key_type = mapnik::keys; - using cont_type = std::map; - cont_type properties; -}; - -inline bool is_expression(symbolizer_base::value_type const& val) -{ - return val.is(); -} - // symbolizer properties target types enum class property_types : std::uint8_t { @@ -183,12 +94,6 @@ enum class property_types : std::uint8_t target_font_feature_settings }; -inline bool operator==(symbolizer_base const& lhs, symbolizer_base const& rhs) -{ - return lhs.properties.size() == rhs.properties.size() && - std::equal(lhs.properties.begin(), lhs.properties.end(), rhs.properties.begin()); -} - template struct evaluate_path_wrapper { @@ -563,33 +468,6 @@ using property_meta_type = std::tuple; } diff --git a/include/mapnik/symbolizer_hash.hpp b/include/mapnik/symbolizer_hash.hpp index 1a85fca65..591ba579d 100644 --- a/include/mapnik/symbolizer_hash.hpp +++ b/include/mapnik/symbolizer_hash.hpp @@ -24,7 +24,7 @@ #define MAPNIK_SYMBOLIZER_HASH_HPP // mapnik -#include +#include #include // stl #include diff --git a/include/mapnik/symbolizer_utils.hpp b/include/mapnik/symbolizer_utils.hpp index 1d094c4c2..ac8a9b3cb 100644 --- a/include/mapnik/symbolizer_utils.hpp +++ b/include/mapnik/symbolizer_utils.hpp @@ -437,7 +437,7 @@ struct set_symbolizer_property_impl boost::optional enum_str = node.get_opt_attr(name); if (enum_str) { - boost::optional enum_val = detail::enum_traits::from_string(*enum_str); + boost::optional enum_val = detail::enum_traits::from_string(*enum_str); if (enum_val) { put(sym, key, *enum_val); @@ -451,7 +451,7 @@ struct set_symbolizer_property_impl auto result = pre_evaluate_expression(*val); if (std::get<1>(result)) { - boost::optional enum_val = detail::enum_traits::from_string(std::get<0>(result).to_string()); + boost::optional enum_val = detail::enum_traits::from_string(std::get<0>(result).to_string()); if (enum_val) { put(sym, key, *enum_val); diff --git a/include/mapnik/text/formatting/format.hpp b/include/mapnik/text/formatting/format.hpp index c52635788..265ae57c3 100644 --- a/include/mapnik/text/formatting/format.hpp +++ b/include/mapnik/text/formatting/format.hpp @@ -23,14 +23,18 @@ #ifndef FORMATTING_FORMAT_HPP #define FORMATTING_FORMAT_HPP +// mapnik #include #include -#include // boost #include -namespace mapnik { namespace formatting { +namespace mapnik { + +class feature_impl; + +namespace formatting { class MAPNIK_DECL format_node: public node { diff --git a/include/mapnik/text/formatting/list.hpp b/include/mapnik/text/formatting/list.hpp index 683717c05..caa3624ba 100644 --- a/include/mapnik/text/formatting/list.hpp +++ b/include/mapnik/text/formatting/list.hpp @@ -24,12 +24,17 @@ // mapnik #include -#include // boost #include +// stl +#include + namespace mapnik { + +class feature_impl; + namespace formatting { class MAPNIK_DECL list_node: public node { public: diff --git a/include/mapnik/text/formatting/text.hpp b/include/mapnik/text/formatting/text.hpp index 253d2e344..46b7abe47 100644 --- a/include/mapnik/text/formatting/text.hpp +++ b/include/mapnik/text/formatting/text.hpp @@ -22,13 +22,16 @@ #ifndef FORMATTING_TEXT_HPP #define FORMATTING_TEXT_HPP +// mapnik #include -#include // boost #include namespace mapnik { + +class feature_impl; + namespace formatting { class MAPNIK_DECL text_node: public node { public: diff --git a/include/mapnik/text/placement_finder.hpp b/include/mapnik/text/placement_finder.hpp index bf7dc157c..524a80cfe 100644 --- a/include/mapnik/text/placement_finder.hpp +++ b/include/mapnik/text/placement_finder.hpp @@ -29,7 +29,6 @@ #include #include #include -#include #include namespace mapnik @@ -40,6 +39,8 @@ using DetectorType = label_collision_detector4; class feature_impl; class vertex_cache; +class text_placement_info; +struct glyph_info; class placement_finder : mapnik::noncopyable { diff --git a/include/mapnik/text/placements_list.hpp b/include/mapnik/text/placements_list.hpp index a8da0b407..65ba15dda 100644 --- a/include/mapnik/text/placements_list.hpp +++ b/include/mapnik/text/placements_list.hpp @@ -24,7 +24,6 @@ //mapnik #include #include -#include #include #include diff --git a/include/mapnik/text/properties_util.hpp b/include/mapnik/text/properties_util.hpp index e571318f4..a28a23fb2 100644 --- a/include/mapnik/text/properties_util.hpp +++ b/include/mapnik/text/properties_util.hpp @@ -23,13 +23,15 @@ #ifndef MAPNIK_PROPERTIES_UTIL_HPP #define MAPNIK_PROPERTIES_UTIL_HPP -#include +#include #include -#include #include #include #include +// boost +#include + namespace mapnik { namespace detail { template diff --git a/include/mapnik/text/renderer.hpp b/include/mapnik/text/renderer.hpp index e0961b574..4024d5ad1 100644 --- a/include/mapnik/text/renderer.hpp +++ b/include/mapnik/text/renderer.hpp @@ -26,7 +26,7 @@ // mapnik #include #include -#include +#include #include // agg #include diff --git a/include/mapnik/text/symbolizer_helpers.hpp b/include/mapnik/text/symbolizer_helpers.hpp index b124aadc0..db4df730b 100644 --- a/include/mapnik/text/symbolizer_helpers.hpp +++ b/include/mapnik/text/symbolizer_helpers.hpp @@ -23,17 +23,16 @@ #define SYMBOLIZER_HELPERS_HPP //mapnik -#include -#include -#include -#include #include -#include -#include #include namespace mapnik { +class feature_impl; +class proj_transform; +class view_transform; +struct symbolizer_base; + template struct placement_finder_adapter { diff --git a/include/mapnik/text/text_properties.hpp b/include/mapnik/text/text_properties.hpp index d22d0b536..20a0b23fa 100644 --- a/include/mapnik/text/text_properties.hpp +++ b/include/mapnik/text/text_properties.hpp @@ -27,21 +27,29 @@ #include #include #include -#include #include #include #include #include #include -#include +#include +#include +#include + // stl #include #include + // boost #include #include -namespace mapnik { namespace detail { +namespace mapnik { + +class feature_impl; +class text_layout; + +namespace detail { struct evaluated_format_properties { @@ -134,8 +142,6 @@ struct MAPNIK_DECL text_layout_properties [](double dx, double dy) { return pixel_position(dx,dy);}; }; -class text_layout; - struct text_properties_expressions { symbolizer_base::value_type label_placement = enumeration_wrapper(POINT_PLACEMENT); diff --git a/src/agg/process_building_symbolizer.cpp b/src/agg/process_building_symbolizer.cpp index 0b2dd203b..362d967a9 100644 --- a/src/agg/process_building_symbolizer.cpp +++ b/src/agg/process_building_symbolizer.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/src/agg/process_debug_symbolizer.cpp b/src/agg/process_debug_symbolizer.cpp index 834718334..ecd37907a 100644 --- a/src/agg/process_debug_symbolizer.cpp +++ b/src/agg/process_debug_symbolizer.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include namespace mapnik { diff --git a/src/build.py b/src/build.py index f5da1c623..1813a9665 100644 --- a/src/build.py +++ b/src/build.py @@ -345,6 +345,7 @@ if env['GRID_RENDERER']: if env['SVG_RENDERER']: # svg backend source += Split( """ + svg/output/svg_output_grammars.cpp svg/output/svg_renderer.cpp svg/output/svg_generator.cpp svg/output/svg_output_attributes.cpp diff --git a/src/cairo/process_building_symbolizer.cpp b/src/cairo/process_building_symbolizer.cpp index 3506da04b..d3059e8e2 100644 --- a/src/cairo/process_building_symbolizer.cpp +++ b/src/cairo/process_building_symbolizer.cpp @@ -25,6 +25,7 @@ // mapnik #include #include +#include #include #include #include diff --git a/src/cairo/process_debug_symbolizer.cpp b/src/cairo/process_debug_symbolizer.cpp index bab726bec..e3a55b96c 100644 --- a/src/cairo/process_debug_symbolizer.cpp +++ b/src/cairo/process_debug_symbolizer.cpp @@ -24,6 +24,7 @@ // mapnik #include +#include #include #include #include diff --git a/src/cairo/process_raster_symbolizer.cpp b/src/cairo/process_raster_symbolizer.cpp index 62f45353a..c9bfcaf8a 100644 --- a/src/cairo/process_raster_symbolizer.cpp +++ b/src/cairo/process_raster_symbolizer.cpp @@ -25,6 +25,7 @@ // mapnik #include #include +#include #include #include diff --git a/src/cairo/process_text_symbolizer.cpp b/src/cairo/process_text_symbolizer.cpp index 0948b4cce..b43da44e4 100644 --- a/src/cairo/process_text_symbolizer.cpp +++ b/src/cairo/process_text_symbolizer.cpp @@ -26,7 +26,7 @@ #include #include #include - +#include namespace mapnik { diff --git a/src/grid/process_building_symbolizer.cpp b/src/grid/process_building_symbolizer.cpp index ed10f80bd..319e1a28e 100644 --- a/src/grid/process_building_symbolizer.cpp +++ b/src/grid/process_building_symbolizer.cpp @@ -33,11 +33,9 @@ #include #include #include +#include #include -// boost - - // stl #include diff --git a/src/renderer_common/process_group_symbolizer.cpp b/src/renderer_common/process_group_symbolizer.cpp index 3feaec330..f894029d5 100644 --- a/src/renderer_common/process_group_symbolizer.cpp +++ b/src/renderer_common/process_group_symbolizer.cpp @@ -20,8 +20,10 @@ * *****************************************************************************/ +// mapnik #include #include +#include namespace mapnik { diff --git a/src/rule.cpp b/src/rule.cpp index d303b80f7..3dfab5535 100644 --- a/src/rule.cpp +++ b/src/rule.cpp @@ -22,6 +22,7 @@ // mapnik #include +#include // stl #include diff --git a/src/svg/output/process_line_symbolizer.cpp b/src/svg/output/process_line_symbolizer.cpp index 8b0e936db..e99bfbe59 100644 --- a/src/svg/output/process_line_symbolizer.cpp +++ b/src/svg/output/process_line_symbolizer.cpp @@ -24,6 +24,8 @@ // mapnik #include +#include +#include namespace mapnik { diff --git a/src/svg/output/process_polygon_symbolizer.cpp b/src/svg/output/process_polygon_symbolizer.cpp index 3f71c6d74..3bcb345a5 100644 --- a/src/svg/output/process_polygon_symbolizer.cpp +++ b/src/svg/output/process_polygon_symbolizer.cpp @@ -24,6 +24,8 @@ // mapnik #include +#include +#include namespace mapnik { diff --git a/src/svg/output/process_symbolizers.cpp b/src/svg/output/process_symbolizers.cpp index 327b93a2e..997fca77f 100644 --- a/src/svg/output/process_symbolizers.cpp +++ b/src/svg/output/process_symbolizers.cpp @@ -23,6 +23,7 @@ #if defined(SVG_RENDERER) // mapnik +#include #include #include #include diff --git a/src/text/formatting/format.cpp b/src/text/formatting/format.cpp index c54303bc3..75374c28c 100644 --- a/src/text/formatting/format.cpp +++ b/src/text/formatting/format.cpp @@ -23,6 +23,7 @@ // mapnik #include #include +#include #include #include #include diff --git a/src/text/formatting/list.cpp b/src/text/formatting/list.cpp index 66c79f1e7..3115f9f66 100644 --- a/src/text/formatting/list.cpp +++ b/src/text/formatting/list.cpp @@ -23,9 +23,9 @@ // mapnik #include #include +#include // boost - #include namespace mapnik { diff --git a/src/text/formatting/text.cpp b/src/text/formatting/text.cpp index dee074866..2387b83b1 100644 --- a/src/text/formatting/text.cpp +++ b/src/text/formatting/text.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/src/text/placement_finder.cpp b/src/text/placement_finder.cpp index 269c3bad7..e32304f90 100644 --- a/src/text/placement_finder.cpp +++ b/src/text/placement_finder.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/src/text/properties_util.cpp b/src/text/properties_util.cpp index ec13c510b..ba0620167 100644 --- a/src/text/properties_util.cpp +++ b/src/text/properties_util.cpp @@ -22,6 +22,8 @@ #include #include +#include +#include #include namespace mapnik { namespace detail { diff --git a/src/text/symbolizer_helpers.cpp b/src/text/symbolizer_helpers.cpp index 7482468e4..9d4cf450c 100644 --- a/src/text/symbolizer_helpers.cpp +++ b/src/text/symbolizer_helpers.cpp @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include #include #include #include diff --git a/src/text/text_layout.cpp b/src/text/text_layout.cpp index 651430400..cf8ebca75 100644 --- a/src/text/text_layout.cpp +++ b/src/text/text_layout.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include // ICU diff --git a/src/text/text_properties.cpp b/src/text/text_properties.cpp index e9a6a2676..e564db749 100644 --- a/src/text/text_properties.cpp +++ b/src/text/text_properties.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include From f34d12094cba332043c4c9b709945ebc8374f7c3 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 30 Sep 2014 12:50:42 -0700 Subject: [PATCH 8/8] new files --- .../svg/output/svg_output_grammars_impl.hpp | 103 +++++++++++ include/mapnik/symbolizer_base.hpp | 169 ++++++++++++++++++ src/svg/output/svg_output_grammars.cpp | 31 ++++ 3 files changed, 303 insertions(+) create mode 100644 include/mapnik/svg/output/svg_output_grammars_impl.hpp create mode 100644 include/mapnik/symbolizer_base.hpp create mode 100644 src/svg/output/svg_output_grammars.cpp diff --git a/include/mapnik/svg/output/svg_output_grammars_impl.hpp b/include/mapnik/svg/output/svg_output_grammars_impl.hpp new file mode 100644 index 000000000..d98c90ca2 --- /dev/null +++ b/include/mapnik/svg/output/svg_output_grammars_impl.hpp @@ -0,0 +1,103 @@ +/***************************************************************************** + * + * 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 + * + *****************************************************************************/ + +// NOTE: This is an implementation header file and is only meant to be included +// from implementation files. It therefore doesn't have an include guard. + +// mapnik +#include +#include +#include + +namespace mapnik { namespace svg { + +using namespace boost::spirit; + +template +svg_path_attributes_grammar::svg_path_attributes_grammar() + : svg_path_attributes_grammar::base_type(svg_path_attributes) +{ + karma::lit_type lit; + karma::double_type double_; + karma::string_type kstring; + + svg_path_attributes = + lit("fill=\"") + << kstring + << lit("\" fill-opacity=\"") << double_ + << lit("\" stroke=\"") << kstring + << lit("\" stroke-opacity=\"") << double_ + << lit("\" stroke-width=\"") << double_ << lit("px") + << lit("\" stroke-linecap=\"") << kstring + << lit("\" stroke-linejoin=\"") << kstring + << lit("\" stroke-dashoffset=\"") << double_ << lit("px") << lit('"'); +} + +template +svg_path_dash_array_grammar::svg_path_dash_array_grammar() + : svg_path_dash_array_grammar::base_type(svg_path_dash_array) +{ + karma::double_type double_; + karma::lit_type lit; + + svg_path_dash_array = lit("stroke-dasharray=\"") << + -((double_ << lit(',') << double_) % lit(',')) << lit('"'); +} + +template +svg_rect_attributes_grammar::svg_rect_attributes_grammar() + : svg_rect_attributes_grammar::base_type(svg_rect_attributes) +{ + karma::lit_type lit; + karma::int_type int_; + karma::string_type kstring; + + svg_rect_attributes = + lit("x=\"") + << int_ + << lit("\" y=\"") << int_ + << lit("\" width=\"") << int_ << lit("px") + << lit("\" height=\"") << int_ << lit("px") + << lit("\" fill=\"") << kstring << lit('"'); +} + +template +svg_root_attributes_grammar::svg_root_attributes_grammar() + : svg_root_attributes_grammar::base_type(svg_root_attributes) +{ + karma::lit_type lit; + karma::int_type int_; + karma::string_type kstring; + karma::double_type double_; + + svg_root_attributes = + lit("width=\"") + << int_ + << lit("px") + << lit("\" height=\"") << int_ << lit("px") + << lit("\" version=\"") << double_ + << lit("\" xmlns=\"") << kstring + << lit("\" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\""); +} + +} +} diff --git a/include/mapnik/symbolizer_base.hpp b/include/mapnik/symbolizer_base.hpp new file mode 100644 index 000000000..4b8cd724d --- /dev/null +++ b/include/mapnik/symbolizer_base.hpp @@ -0,0 +1,169 @@ +/***************************************************************************** + * + * 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_SYMBOLIZER_BASE_HPP +#define MAPNIK_SYMBOLIZER_BASE_HPP + +// mapnik +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// stl +#include +#include +#include +#include + +namespace agg { struct trans_affine; } + +namespace mapnik +{ + +// fwd declares +// TODO - move these transform declares to own header +namespace detail { struct transform_node; } +using transform_list = std::vector; +using transform_list_ptr = std::shared_ptr; +using transform_type = transform_list_ptr; +class feature_impl; + +MAPNIK_DECL void evaluate_transform(agg::trans_affine& tr, + feature_impl const& feature, + attributes const& vars, + transform_type const& trans_expr, + double scale_factor=1.0); + +struct enumeration_wrapper +{ + int value; + enumeration_wrapper() = delete; + template + explicit enumeration_wrapper(T value_) + : value(value_) {} + + inline operator int() const + { + return value; + } +}; + +using dash_array = std::vector >; + +class text_placements; +using text_placements_ptr = std::shared_ptr; + +namespace detail { + +using value_base_type = util::variant; + +struct strict_value : value_base_type +{ + // default ctor + strict_value() + : value_base_type() {} + // copy ctor + strict_value(const char* val) + : value_base_type(val) {} + + template + strict_value(T const& obj) + : value_base_type(typename detail::mapnik_value_type::type(obj)) + {} + // move ctor + template + strict_value(T && obj) noexcept + : value_base_type(std::move(obj)) {} + +}; +} + +struct MAPNIK_DECL symbolizer_base +{ + using value_type = detail::strict_value; + using key_type = mapnik::keys; + using cont_type = std::map; + cont_type properties; +}; + +inline bool is_expression(symbolizer_base::value_type const& val) +{ + return val.is(); +} + +inline bool operator==(symbolizer_base const& lhs, symbolizer_base const& rhs) +{ + return lhs.properties.size() == rhs.properties.size() && + std::equal(lhs.properties.begin(), lhs.properties.end(), rhs.properties.begin()); +} + +// concrete symbolizer types +struct MAPNIK_DECL point_symbolizer : public symbolizer_base {}; +struct MAPNIK_DECL line_symbolizer : public symbolizer_base {}; +struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base {}; +struct MAPNIK_DECL text_symbolizer : public symbolizer_base {}; +struct MAPNIK_DECL shield_symbolizer : public text_symbolizer {}; +struct MAPNIK_DECL line_pattern_symbolizer : public symbolizer_base {}; +struct MAPNIK_DECL polygon_pattern_symbolizer : public symbolizer_base {}; +struct MAPNIK_DECL markers_symbolizer : public symbolizer_base {}; +struct MAPNIK_DECL raster_symbolizer : public symbolizer_base {}; +struct MAPNIK_DECL building_symbolizer : public symbolizer_base {}; +struct MAPNIK_DECL group_symbolizer : public symbolizer_base {}; +struct MAPNIK_DECL debug_symbolizer : public symbolizer_base {}; + +// symbolizer +using symbolizer = util::variant; + +} + +#endif // MAPNIK_SYMBOLIZER_BASE_HPP diff --git a/src/svg/output/svg_output_grammars.cpp b/src/svg/output/svg_output_grammars.cpp new file mode 100644 index 000000000..30ed5f90d --- /dev/null +++ b/src/svg/output/svg_output_grammars.cpp @@ -0,0 +1,31 @@ +/***************************************************************************** + * + * 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 + * + *****************************************************************************/ + +#include +#include +#include +#include + +template struct mapnik::svg::svg_path_attributes_grammar >; +template struct mapnik::svg::svg_path_dash_array_grammar >; +template struct mapnik::svg::svg_rect_attributes_grammar >; +template struct mapnik::svg::svg_root_attributes_grammar >; \ No newline at end of file