From 08f651289dcb6f5ab9f0be137190c19e2fbc045a Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 24 Aug 2014 15:58:28 -0700 Subject: [PATCH] fix compile with boost 1.56 - refs #2368 --- include/mapnik/marker.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mapnik/marker.hpp b/include/mapnik/marker.hpp index 568f565..9c8c0e4 100644 --- a/include/mapnik/marker.hpp +++ b/include/mapnik/marker.hpp @@ -124,12 +124,12 @@ class marker: private mapnik::noncopyable inline bool is_bitmap() const { - return bitmap_data_; + return bitmap_data_ ? true : false; } inline bool is_vector() const { - return vector_data_; + return vector_data_ ? true : false; } boost::optional get_bitmap_data() const From 5dd79e88c051cec702ad1aca13dfc1f6e7d087e1 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 19 Aug 2014 09:06:40 -0700 Subject: [PATCH] fix css_grammar compile error with boost 1.56 - close #2366 Conflicts: SConstruct --- SConstruct | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/SConstruct b/SConstruct index de9ea89..4bd700e 100644 --- a/SConstruct +++ b/SConstruct @@ -1623,6 +1623,15 @@ if not preconfigured: debug_defines = ['-DDEBUG', '-DMAPNIK_DEBUG'] ndebug_defines = ['-DNDEBUG'] + boost_version_from_header = int(env['BOOST_LIB_VERSION_FROM_HEADER'].split('_')[1]) + if boost_version_from_header > 53 or 'c++11' in env['CUSTOM_CXXFLAGS']: + env.Append(CPPDEFINES = '-DBOOST_SPIRIT_USE_PHOENIX_V3=1') + # - workaround boost gil channel_algorithm.hpp narrowing error + # TODO - remove when building against >= 1.55 + # https://github.com/mapnik/mapnik/issues/1970 + if 'clang++' in env['CXX']: + env.Append(CXXFLAGS = '-Wno-c++11-narrowing') + # Enable logging in debug mode (always) and release mode (when specified) if env['DEFAULT_LOG_SEVERITY']: if env['DEFAULT_LOG_SEVERITY'] not in severities: From 9c947232e9c26051598301b0ba4b0d98f212dbcb Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 19 Aug 2014 09:07:30 -0700 Subject: [PATCH] adapt to ptree change in boost 1.56 - closes #2365 --- src/save_map.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/save_map.cpp b/src/save_map.cpp index edfa029..bee0cc8 100644 --- a/src/save_map.cpp +++ b/src/save_map.cpp @@ -42,6 +42,7 @@ // boost #include #include +#include #include #include @@ -869,7 +870,11 @@ void save_map(Map const & map, std::string const& filename, bool explicit_defaul { ptree pt; serialize_map(pt,map,explicit_defaults); +#if BOOST_VERSION >= 105600 + write_xml(filename,pt,std::locale(),boost::property_tree::xml_writer_make_settings(' ',4)); +#else write_xml(filename,pt,std::locale(),boost::property_tree::xml_writer_make_settings(' ',4)); +#endif } std::string save_map_to_string(Map const & map, bool explicit_defaults) @@ -877,7 +882,11 @@ std::string save_map_to_string(Map const & map, bool explicit_defaults) ptree pt; serialize_map(pt,map,explicit_defaults); std::ostringstream ss; +#if BOOST_VERSION >= 105600 + write_xml(ss,pt,boost::property_tree::xml_writer_make_settings(' ',4)); +#else write_xml(ss,pt,boost::property_tree::xml_writer_make_settings(' ',4)); +#endif return ss.str(); } From 8c4a5d53d3311819f5fc984df47aad49e5b7acd9 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 22 Sep 2014 23:22:05 -0700 Subject: [PATCH] boost 1.56 support --- SConstruct | 2 +- include/mapnik/css_color_grammar.hpp | 8 ++ include/mapnik/expression_grammar.hpp | 10 +- include/mapnik/expression_grammar_impl.hpp | 2 +- include/mapnik/json/feature_grammar.hpp | 25 ++++ include/mapnik/json/geometry_generator_grammar.hpp | 131 +++++++++++++++++---- include/mapnik/json/geometry_grammar.hpp | 62 +++++++++- include/mapnik/svg/svg_path_commands.hpp | 37 ++++++ include/mapnik/svg/svg_transform_grammar.hpp | 20 ++++ include/mapnik/util/geometry_svg_generator.hpp | 51 ++++++-- include/mapnik/util/geometry_wkt_generator.hpp | 4 +- include/mapnik/wkt/wkt_grammar.hpp | 5 +- src/json/feature_collection_parser.cpp | 2 + 13 files changed, 312 insertions(+), 47 deletions(-) diff --git a/SConstruct b/SConstruct index 4bd700e..6aefc58 100644 --- a/SConstruct +++ b/SConstruct @@ -1431,7 +1431,7 @@ if not preconfigured: env["CAIRO_ALL_LIBS"] = ['cairo'] if env['RUNTIME_LINK'] == 'static': env["CAIRO_ALL_LIBS"].extend( - ['pixman-1','expat','fontconfig','iconv'] + ['pixman-1','expat','iconv'] ) # todo - run actual checkLib? env['HAS_CAIRO'] = True diff --git a/include/mapnik/css_color_grammar.hpp b/include/mapnik/css_color_grammar.hpp index a15f0fa..e20bdb2 100644 --- a/include/mapnik/css_color_grammar.hpp +++ b/include/mapnik/css_color_grammar.hpp @@ -125,7 +125,11 @@ struct alpha_conv_impl struct hsl_conv_impl { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -413,7 +417,11 @@ struct alpha_conv_impl struct hsl_conv_impl { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; diff --git a/include/mapnik/expression_grammar.hpp b/include/mapnik/expression_grammar.hpp index ed4a430..0b48924 100644 --- a/include/mapnik/expression_grammar.hpp +++ b/include/mapnik/expression_grammar.hpp @@ -65,7 +65,11 @@ struct unicode_impl struct regex_match_impl { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef expr_node type; @@ -82,7 +86,11 @@ struct regex_match_impl struct regex_replace_impl { - template +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else + template +#endif struct result { typedef expr_node type; diff --git a/include/mapnik/expression_grammar_impl.hpp b/include/mapnik/expression_grammar_impl.hpp index 5ca2c5e..2255d48 100644 --- a/include/mapnik/expression_grammar_impl.hpp +++ b/include/mapnik/expression_grammar_impl.hpp @@ -145,7 +145,7 @@ expression_grammar::expression_grammar(mapnik::transcoder const& tr) multiplicative_expr = unary_expr [_val = _1] >> *( '*' >> unary_expr [_val *= _1] | '/' >> unary_expr [_val /= _1] - | '%' >> unary_expr [_val %= _1] + | '%' >> unary_expr [_val %= construct(_1)] //needed by clang++ with -std=c++11 | regex_match_expr[_val = regex_match_(_val, _1)] | regex_replace_expr(_val) [_val = _1] ) diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp index a117b53..6a4a087 100644 --- a/include/mapnik/json/feature_grammar.hpp +++ b/include/mapnik/json/feature_grammar.hpp @@ -66,6 +66,30 @@ class attribute_value_visitor mapnik::transcoder const& tr_; }; +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 +struct put_property +{ + typedef void result_type; + explicit put_property(mapnik::transcoder const& tr) + : tr_(tr) {} + template + result_type operator() (T0 & feature, T1 const& key, T2 const& val) const + { + feature.put_new(key, boost::apply_visitor(attribute_value_visitor(tr_),val)); + } + mapnik::transcoder const& tr_; +}; + +struct extract_geometry +{ + typedef boost::ptr_vector& result_type; + template + result_type operator() (T & feature) const + { + return feature.paths(); + } +}; +#else struct put_property { template @@ -100,6 +124,7 @@ struct extract_geometry return feature.paths(); } }; +#endif template struct feature_grammar : diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index 47974c2..2c21bab 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -38,11 +38,8 @@ #include #include #include -#include -#include // trunc to avoid needing C++11 - - -//#define BOOST_SPIRIT_USE_PHOENIX_V3 1 +#include +#include // for vc++ and android whose c++11 libs lack std::trunct namespace boost { namespace spirit { namespace traits { @@ -61,6 +58,68 @@ namespace phoenix = boost::phoenix; namespace { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 +struct get_type +{ + typedef int result_type; + result_type operator() (geometry_type const& geom) const + { + return static_cast(geom.type()); + } +}; + +struct get_first +{ + typedef geometry_type::value_type const result_type; + result_type operator() (geometry_type const& geom) const + { + geometry_type::value_type coord; + boost::get<0>(coord) = geom.vertex(0,&boost::get<1>(coord),&boost::get<2>(coord)); + return coord; + } +}; + +struct multi_geometry_type +{ + typedef boost::tuple result_type; + result_type operator() (geometry_container const& geom) const + { + unsigned type = 0u; + bool collection = false; + + geometry_container::const_iterator itr = geom.begin(); + geometry_container::const_iterator end = geom.end(); + + for ( ; itr != end; ++itr) + { + if (type != 0u && itr->type() != type) + { + collection = true; + break; + } + type = itr->type(); + } + if (geom.size() > 1) type +=3; + return boost::tuple(type, collection); + } +}; + +struct not_empty +{ + typedef bool result_type; + result_type operator() (geometry_container const& cont) const + { + geometry_container::const_iterator itr = cont.begin(); + geometry_container::const_iterator end = cont.end(); + for ( ; itr != end; ++itr) + { + if (itr->size() > 0) return true; + } + return false; + } +}; + +#else struct get_type { template @@ -100,7 +159,7 @@ struct multi_geometry_type for ( ; itr != end; ++itr) { - if (type != 0u && itr->type() != type) + if (type != 0u && static_cast(itr->type()) != type) { collection = true; break; @@ -113,6 +172,28 @@ struct multi_geometry_type }; +struct not_empty +{ + template + struct result { typedef bool type; }; + + bool operator() (geometry_container const& cont) const + { + geometry_container::const_iterator itr = cont.begin(); + geometry_container::const_iterator end = cont.end(); + + for (; itr!=end; ++itr) + { + if (itr->size() > 0) return true; + } + return false; + } +}; + + +#endif + + template struct json_coordinate_policy : karma::real_policies { @@ -123,7 +204,7 @@ struct json_coordinate_policy : karma::real_policies { if (n == 0.0) return 0; using namespace boost::spirit; - return static_cast(15 - boost::math::trunc(log10(traits::get_absolute_value(n)))); + return static_cast(14 - boost::math::trunc(log10(traits::get_absolute_value(n)))); } template @@ -135,7 +216,7 @@ struct json_coordinate_policy : karma::real_policies template static bool fraction_part(OutputIterator& sink, T n - , unsigned adjprec, unsigned precision) + , unsigned adjprec, unsigned precision) { if (n == 0) return true; return base_type::fraction_part(sink, n, adjprec, precision); @@ -153,6 +234,7 @@ struct geometry_generator_grammar : : geometry_generator_grammar::base_type(coordinates) { using boost::spirit::karma::uint_; + using boost::spirit::bool_; using boost::spirit::karma::_val; using boost::spirit::karma::_1; using boost::spirit::karma::lit; @@ -182,15 +264,15 @@ struct geometry_generator_grammar : point_coord = &uint_ << lit('[') << coord_type << lit(',') << coord_type - << lit("]") + << lit(']') ; polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1] - << karma::string[ if_ (_r1 > 1) [_1 = "],["] - .else_[_1 = '[' ]] | &uint_ << lit(',')) - << lit('[') << coord_type - << lit(',') - << coord_type << lit(']') + << karma::string[ if_ (_r1 > 1u) [_1 = "],["] + .else_[_1 = '[' ]] + | + &uint_(mapnik::SEG_LINETO) + << lit(',')) << lit('[') << coord_type << lit(',') << coord_type << lit(']') ; coords2 %= *polygon_coord(_a) @@ -205,7 +287,6 @@ struct geometry_generator_grammar : karma::rule point; karma::rule linestring; karma::rule polygon; - karma::rule coords; karma::rule, geometry_type const& ()> coords2; karma::rule point_coord; @@ -235,6 +316,7 @@ struct multi_geometry_generator_grammar : using boost::spirit::karma::_1; using boost::spirit::karma::_a; using boost::spirit::karma::_r1; + using boost::spirit::bool_; geometry_types.add (mapnik::Point,"\"Point\"") @@ -245,7 +327,7 @@ struct multi_geometry_generator_grammar : (mapnik::Polygon + 3,"\"MultiPolygon\"") ; - start %= ( eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)] + start %= ( eps(phoenix::at_c<1>(_a))[_a = multi_type_(_val)] << lit("{\"type\":\"GeometryCollection\",\"geometries\":[") << geometry_collection << lit("]}") | @@ -255,13 +337,13 @@ struct multi_geometry_generator_grammar : geometry_collection = -(geometry2 % lit(',')) ; - geometry = (lit("{\"type\":") - << geometry_types[_1 = phoenix::at_c<0>(_a)][_a = _multi_type(_val)] - << lit(",\"coordinates\":") - << karma::string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = '[']] - << coordinates - << karma::string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = ']']] - << lit('}')) | lit("null") + geometry = ( &bool_(true)[_1 = not_empty_(_val)] << lit("{\"type\":") + << geometry_types[_1 = phoenix::at_c<0>(_a)][_a = multi_type_(_val)] + << lit(",\"coordinates\":") + << karma::string[ phoenix::if_ (phoenix::at_c<0>(_a) > 3u) [_1 = '['].else_[_1 = ""]] + << coordinates + << karma::string[ phoenix::if_ (phoenix::at_c<0>(_a) > 3u) [_1 = ']'].else_[_1 = ""]] + << lit('}')) | lit("null") ; geometry2 = lit("{\"type\":") @@ -287,8 +369,9 @@ struct multi_geometry_generator_grammar : karma::rule coordinates; geometry_generator_grammar path; // phoenix - phoenix::function _multi_type; + phoenix::function multi_type_; phoenix::function type_; + phoenix::function not_empty_; // symbols table karma::symbols geometry_types; }; diff --git a/include/mapnik/json/geometry_grammar.hpp b/include/mapnik/json/geometry_grammar.hpp index 9600b41..157d0e6 100644 --- a/include/mapnik/json/geometry_grammar.hpp +++ b/include/mapnik/json/geometry_grammar.hpp @@ -37,6 +37,58 @@ namespace qi = boost::spirit::qi; namespace standard_wide = boost::spirit::standard_wide; using standard_wide::space_type; +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 +struct push_vertex +{ + typedef void result_type; + + template + result_type operator() (T0 c, T1 path, T2 x, T3 y) const + { + BOOST_ASSERT( path!=0 ); + path->push_vertex(x,y,c); + } +}; + +struct close_path +{ + typedef void result_type; + + template + result_type operator() (T path) const + { + BOOST_ASSERT( path!=0 ); + if (path->size() > 2u) // to form a polygon ring we need at least 3 vertices + { + path->close_path(); + } + } +}; + +struct cleanup +{ + typedef void result_type; + template + void operator() (T0 & path) const + { + if (path) delete path, path=0; + } +}; + +struct where_message +{ + typedef std::string result_type; + + template + std::string operator() (Iterator first, Iterator last, std::size_t size) const + { + std::string str(first, last); + if (str.length() > size) + return str.substr(0, size) + "..." ; + return str; + } +}; +#else struct push_vertex { template @@ -65,8 +117,11 @@ struct close_path void operator() (T path) const { BOOST_ASSERT( path!=0 ); - path->close_path(); - } + if (path->size() > 2u) // to form a polygon ring we need at least 3 vertices + { + path->close_path(); + } + } }; struct cleanup @@ -101,12 +156,13 @@ struct where_message return str; } }; +#endif template struct geometry_grammar : qi::grammar, void(boost::ptr_vector& ) - , space_type> + , space_type> { geometry_grammar(); qi::rule, void(boost::ptr_vector& ),space_type> geometry; diff --git a/include/mapnik/svg/svg_path_commands.hpp b/include/mapnik/svg/svg_path_commands.hpp index e45b5b1..ba631ed 100644 --- a/include/mapnik/svg/svg_path_commands.hpp +++ b/include/mapnik/svg/svg_path_commands.hpp @@ -45,7 +45,12 @@ inline double deg2rad(double deg) template struct move_to { + +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -66,7 +71,11 @@ struct move_to template struct hline_to { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -88,7 +97,11 @@ struct hline_to template struct vline_to { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -109,7 +122,11 @@ struct vline_to template struct line_to { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -131,7 +148,11 @@ struct line_to template struct curve4 { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -156,7 +177,11 @@ struct curve4 template struct curve4_smooth { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -178,7 +203,11 @@ struct curve4_smooth template struct curve3 { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -201,7 +230,11 @@ struct curve3 template struct curve3_smooth { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -223,7 +256,11 @@ struct curve3_smooth template struct arc_to { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; diff --git a/include/mapnik/svg/svg_transform_grammar.hpp b/include/mapnik/svg/svg_transform_grammar.hpp index 087bab3..a63884b 100644 --- a/include/mapnik/svg/svg_transform_grammar.hpp +++ b/include/mapnik/svg/svg_transform_grammar.hpp @@ -50,7 +50,11 @@ namespace mapnik { namespace svg { template struct process_matrix { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -70,7 +74,11 @@ namespace mapnik { namespace svg { template struct process_rotate { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -101,7 +109,11 @@ namespace mapnik { namespace svg { template struct process_translate { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -123,7 +135,11 @@ namespace mapnik { namespace svg { template struct process_scale { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; @@ -146,7 +162,11 @@ namespace mapnik { namespace svg { template struct process_skew { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; diff --git a/include/mapnik/util/geometry_svg_generator.hpp b/include/mapnik/util/geometry_svg_generator.hpp index 0705210..210a376 100644 --- a/include/mapnik/util/geometry_svg_generator.hpp +++ b/include/mapnik/util/geometry_svg_generator.hpp @@ -23,6 +23,7 @@ #ifndef MAPNIK_GEOMETRY_SVG_GENERATOR_HPP #define MAPNIK_GEOMETRY_SVG_GENERATOR_HPP + // mapnik #include #include // for container stuff @@ -41,13 +42,11 @@ #include #include -//#define BOOST_SPIRIT_USE_PHOENIX_V3 1 -/*! - * adapted to conform to the concepts - * required by Karma to be recognized as a container of - * attributes for output generation. - */ +// adapted to conform to the concepts +// required by Karma to be recognized as a container of +// attributes for output generation. + namespace boost { namespace spirit { namespace traits { // TODO - this needs to be made generic to any path type @@ -76,7 +75,7 @@ template <> struct end_container { static mapnik::util::path_iterator - call (path_type const& g) + call (path_type const& /*g*/) { return mapnik::util::path_iterator(); } @@ -92,6 +91,31 @@ namespace mapnik { namespace util { namespace svg_detail { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template + struct get_type + { + typedef int result_type; + result_type operator() (Geometry const& geom) const + { + return static_cast(geom.type()); + } + }; + + template + struct get_first + { + typedef T geometry_type; + typedef typename geometry_type::value_type const result_type; + result_type operator() (geometry_type const& geom) const + { + typename geometry_type::value_type coord; + geom.rewind(0); + boost::get<0>(coord) = geom.vertex(&boost::get<1>(coord),&boost::get<2>(coord)); + return coord; + } + }; +#else template struct get_type { @@ -112,7 +136,7 @@ namespace mapnik { namespace util { template struct result { typedef typename geometry_type::value_type const type; }; - typename geometry_type::value_type const operator() (geometry_type const& geom) const + typename geometry_type::value_type operator() (geometry_type const& geom) const { typename geometry_type::value_type coord; geom.rewind(0); @@ -121,12 +145,13 @@ namespace mapnik { namespace util { } }; +#endif template struct coordinate_policy : karma::real_policies { typedef boost::spirit::karma::real_policies base_type; static int floatfield(T n) { return base_type::fmtflags::fixed; } - static unsigned precision(T n) { return 6u ;} + static unsigned precision(T n) { return 4u ;} }; } @@ -161,15 +186,15 @@ namespace mapnik { namespace util { ; linestring = &uint_(mapnik::LineString)[_1 = _type(_val)] - << svg_path << lit('\"') + << lit("d=\"") << svg_path << lit("\"") ; polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)] - << svg_path << lit('\"') + << lit("d=\"") << svg_path << lit("\"") ; - svg_path %= ((&uint_(mapnik::SEG_MOVETO) << lit("d=\"") << lit('M') - | &uint_(mapnik::SEG_LINETO) [_a +=1] << karma::string [if_(_a == 1) [_1 = "L" ] ]) + svg_path %= ((&uint_(mapnik::SEG_MOVETO) << lit('M') + | &uint_(mapnik::SEG_LINETO) [_a +=1] << karma::string [if_(_a == 1u) [_1 = "L" ].else_[_1 =""]]) << lit(' ') << coordinate << lit(' ') << coordinate) % lit(' ') ; diff --git a/include/mapnik/util/geometry_wkt_generator.hpp b/include/mapnik/util/geometry_wkt_generator.hpp index 79f9fe1..ee6e2d1 100644 --- a/include/mapnik/util/geometry_wkt_generator.hpp +++ b/include/mapnik/util/geometry_wkt_generator.hpp @@ -40,7 +40,6 @@ #include #include // trunc to avoid needing C++11 -//#define BOOST_SPIRIT_USE_PHOENIX_V3 1 namespace boost { namespace spirit { namespace traits { @@ -205,8 +204,7 @@ template struct wkt_multi_generator : karma::grammar >, GeometryContainer const& ()> { - typedef GeometryContainer geometry_contaner; - typedef boost::remove_pointer::type geometry_type; + typedef typename boost::remove_pointer::type geometry_type; wkt_multi_generator(); // rules diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index e7e986f..ff233d6 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -40,12 +40,15 @@ namespace mapnik { namespace wkt { using namespace boost::spirit; - using namespace boost::fusion; using namespace boost::phoenix; struct push_vertex { +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else template +#endif struct result { typedef void type; diff --git a/src/json/feature_collection_parser.cpp b/src/json/feature_collection_parser.cpp index 0e1ce12..e4f65d8 100644 --- a/src/json/feature_collection_parser.cpp +++ b/src/json/feature_collection_parser.cpp @@ -23,8 +23,10 @@ // TODO https://github.com/mapnik/mapnik/issues/1658 #include #if BOOST_VERSION >= 105200 +#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 #define BOOST_SPIRIT_USE_PHOENIX_V3 #endif +#endif // mapnik #include From 29b717f9f61f67740ac414ca2efa8bf77e3d4951 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 19 Aug 2014 13:51:32 -0700 Subject: [PATCH] adapt to new rtree interface in boost geometry >= 1.56 - refs #2367 Conflicts: plugins/input/geojson/geojson_datasource.cpp --- plugins/input/geojson/geojson_datasource.cpp | 22 +++++++++++++++------- plugins/input/geojson/geojson_datasource.hpp | 18 +++++++++++++++--- plugins/input/geojson/geojson_featureset.cpp | 11 ++++++++--- plugins/input/geojson/geojson_featureset.hpp | 9 +++++---- 4 files changed, 43 insertions(+), 17 deletions(-) diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index dd5e167..7072a27 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -32,10 +32,6 @@ #include #include #include -#include -#include -#include -#include // mapnik #include @@ -101,7 +97,11 @@ geojson_datasource::geojson_datasource(parameters const& params) extent_(), tr_(new mapnik::transcoder(*params.get("encoding","utf-8"))), features_(), +#if BOOST_VERSION >= 105600 + tree_() +#else tree_(16,1) +#endif { if (file_.empty()) throw mapnik::datasource_exception("GeoJSON Plugin: missing parameter"); @@ -139,9 +139,9 @@ geojson_datasource::geojson_datasource(parameters const& params) bool first = true; std::size_t count=0; - BOOST_FOREACH (mapnik::feature_ptr f, features_) + BOOST_FOREACH (mapnik::feature_ptr const& f, features_) { - mapnik::box2d const& box = f->envelope(); + mapnik::box2d box = f->envelope(); if (first) { extent_ = box; @@ -158,7 +158,11 @@ geojson_datasource::geojson_datasource(parameters const& params) { extent_.expand_to_include(box); } - tree_.insert(box_type(point_type(box.minx(),box.miny()),point_type(box.maxx(),box.maxy())), count++); +#if BOOST_VERSION >= 105600 + tree_.insert(std::make_pair(box_type(point_type(box.minx(),box.miny()),point_type(box.maxx(),box.maxy())),count++)); +#else + tree_.insert(box_type(point_type(box.minx(),box.miny()),point_type(box.maxx(),box.maxy())),count++); +#endif } } @@ -213,7 +217,11 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons if (extent_.intersects(b)) { box_type box(point_type(b.minx(),b.miny()),point_type(b.maxx(),b.maxy())); +#if BOOST_VERSION >= 105600 + tree_.query(boost::geometry::index::intersects(box),std::back_inserter(index_array_)); +#else index_array_ = tree_.find(box); +#endif return boost::make_shared(features_, index_array_.begin(), index_array_.end()); } // otherwise return an empty featureset pointer diff --git a/plugins/input/geojson/geojson_datasource.hpp b/plugins/input/geojson/geojson_datasource.hpp index 7cad44b..c02827b 100644 --- a/plugins/input/geojson/geojson_datasource.hpp +++ b/plugins/input/geojson/geojson_datasource.hpp @@ -36,11 +36,16 @@ // boost #include #include -#include #include -#include +#include #include +#include +#include +#if BOOST_VERSION >= 105600 +#include +#else #include +#endif // stl #include @@ -53,7 +58,14 @@ class geojson_datasource : public mapnik::datasource public: typedef boost::geometry::model::d2::point_xy point_type; typedef boost::geometry::model::box box_type; +#if BOOST_VERSION >= 105600 + typedef std::pair item_type; + typedef boost::geometry::index::linear<16,1> linear_type; + typedef boost::geometry::index::rtree spatial_index_type; +#else + typedef std::size_t item_type; typedef boost::geometry::index::rtree spatial_index_type; +#endif // constructor geojson_datasource(mapnik::parameters const& params); @@ -74,7 +86,7 @@ class geojson_datasource : public mapnik::datasource boost::shared_ptr tr_; std::vector features_; spatial_index_type tree_; - mutable std::deque index_array_; + mutable std::deque index_array_; }; diff --git a/plugins/input/geojson/geojson_featureset.cpp b/plugins/input/geojson/geojson_featureset.cpp index f6d45a9..93233ec 100644 --- a/plugins/input/geojson/geojson_featureset.cpp +++ b/plugins/input/geojson/geojson_featureset.cpp @@ -30,8 +30,8 @@ #include "geojson_featureset.hpp" geojson_featureset::geojson_featureset(std::vector const& features, - std::deque::const_iterator index_itr, - std::deque::const_iterator index_end) + array_type::const_iterator index_itr, + array_type::const_iterator index_end) : features_(features), index_itr_(index_itr), index_end_(index_end) {} @@ -42,7 +42,12 @@ mapnik::feature_ptr geojson_featureset::next() { if (index_itr_ != index_end_) { - std::size_t index = *index_itr_++; +#if BOOST_VERSION >= 105600 + geojson_datasource::item_type const& item = *index_itr_++; + std::size_t index = item.second; +#else + std::size_t const& index = *index_itr_++; +#endif if ( index < features_.size()) { return features_.at(index); diff --git a/plugins/input/geojson/geojson_featureset.hpp b/plugins/input/geojson/geojson_featureset.hpp index f8b37d6..fd68e7d 100644 --- a/plugins/input/geojson/geojson_featureset.hpp +++ b/plugins/input/geojson/geojson_featureset.hpp @@ -11,17 +11,18 @@ class geojson_featureset : public mapnik::Featureset { public: + typedef std::deque array_type; geojson_featureset(std::vector const& features, - std::deque::const_iterator index_itr, - std::deque::const_iterator index_end); + array_type::const_iterator index_itr, + array_type::const_iterator index_end); virtual ~geojson_featureset(); mapnik::feature_ptr next(); private: mapnik::box2d box_; std::vector const& features_; - std::deque::const_iterator index_itr_; - std::deque::const_iterator index_end_; + array_type::const_iterator index_itr_; + array_type::const_iterator index_end_; }; #endif // GEOJSON_FEATURESET_HPP