Created
September 26, 2014 06:40
-
-
Save tdsmith/22aeb0bfb9691de91463 to your computer and use it in GitHub Desktop.
Concatenated diffs for commits mentioned in https://github.com/mapnik/mapnik/issues/2428.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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<typename T> | |
+#else | |
template<typename T0,typename T1, typename T2, typename T3> | |
+#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<typename T> | |
+#else | |
template<typename T0,typename T1, typename T2, typename T3> | |
+#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 <typename T> | |
+#else | |
template <typename T0, typename T1> | |
+#endif | |
struct result | |
{ | |
typedef expr_node type; | |
@@ -82,7 +86,11 @@ struct regex_match_impl | |
struct regex_replace_impl | |
{ | |
- template <typename T0, typename T1, typename T2> | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename T> | |
+#else | |
+ template <typename T0, typename T1> | |
+#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<Iterator>::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<mapnik::expr_node>(_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 <typename T0,typename T1, typename T2> | |
+ 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<mapnik::geometry_type>& result_type; | |
+ template <typename T> | |
+ result_type operator() (T & feature) const | |
+ { | |
+ return feature.paths(); | |
+ } | |
+}; | |
+#else | |
struct put_property | |
{ | |
template <typename T0,typename T1, typename T2> | |
@@ -100,6 +124,7 @@ struct extract_geometry | |
return feature.paths(); | |
} | |
}; | |
+#endif | |
template <typename Iterator, typename FeatureType> | |
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 <boost/spirit/include/phoenix_fusion.hpp> | |
#include <boost/spirit/include/phoenix_function.hpp> | |
#include <boost/spirit/include/phoenix_statement.hpp> | |
-#include <boost/fusion/include/boost_tuple.hpp> | |
-#include <boost/math/special_functions/trunc.hpp> // trunc to avoid needing C++11 | |
- | |
- | |
-//#define BOOST_SPIRIT_USE_PHOENIX_V3 1 | |
+#include <boost/fusion/adapted/boost_tuple.hpp> | |
+#include <boost/math/special_functions/trunc.hpp> // 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<int>(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<unsigned,bool> 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<unsigned,bool>(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 <typename T> | |
@@ -100,7 +159,7 @@ struct multi_geometry_type | |
for ( ; itr != end; ++itr) | |
{ | |
- if (type != 0u && itr->type() != type) | |
+ if (type != 0u && static_cast<unsigned>(itr->type()) != type) | |
{ | |
collection = true; | |
break; | |
@@ -113,6 +172,28 @@ struct multi_geometry_type | |
}; | |
+struct not_empty | |
+{ | |
+ template <typename T> | |
+ 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 <typename T> | |
struct json_coordinate_policy : karma::real_policies<T> | |
{ | |
@@ -123,7 +204,7 @@ struct json_coordinate_policy : karma::real_policies<T> | |
{ | |
if (n == 0.0) return 0; | |
using namespace boost::spirit; | |
- return static_cast<unsigned>(15 - boost::math::trunc(log10(traits::get_absolute_value(n)))); | |
+ return static_cast<unsigned>(14 - boost::math::trunc(log10(traits::get_absolute_value(n)))); | |
} | |
template <typename OutputIterator> | |
@@ -135,7 +216,7 @@ struct json_coordinate_policy : karma::real_policies<T> | |
template <typename OutputIterator> | |
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<OutputIterator, geometry_type const& ()> point; | |
karma::rule<OutputIterator, geometry_type const& ()> linestring; | |
karma::rule<OutputIterator, geometry_type const& ()> polygon; | |
- | |
karma::rule<OutputIterator, geometry_type const& ()> coords; | |
karma::rule<OutputIterator, karma::locals<unsigned>, geometry_type const& ()> coords2; | |
karma::rule<OutputIterator, geometry_type::value_type ()> 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<OutputIterator, geometry_container const&()> coordinates; | |
geometry_generator_grammar<OutputIterator> path; | |
// phoenix | |
- phoenix::function<multi_geometry_type> _multi_type; | |
+ phoenix::function<multi_geometry_type> multi_type_; | |
phoenix::function<get_type > type_; | |
+ phoenix::function<not_empty> not_empty_; | |
// symbols table | |
karma::symbols<unsigned, char const*> 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 <typename T0,typename T1, typename T2, typename T3> | |
+ 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 <typename T> | |
+ 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 <typename T0> | |
+ void operator() (T0 & path) const | |
+ { | |
+ if (path) delete path, path=0; | |
+ } | |
+}; | |
+ | |
+struct where_message | |
+{ | |
+ typedef std::string result_type; | |
+ | |
+ template <typename Iterator> | |
+ 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 <typename T0,typename T1, typename T2, typename T3> | |
@@ -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 <typename Iterator> | |
struct geometry_grammar : | |
qi::grammar<Iterator,qi::locals<int>, void(boost::ptr_vector<mapnik::geometry_type>& ) | |
- , space_type> | |
+ , space_type> | |
{ | |
geometry_grammar(); | |
qi::rule<Iterator, qi::locals<int>, void(boost::ptr_vector<mapnik::geometry_type>& ),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 <typename PathType> | |
struct move_to | |
{ | |
+ | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename T0> | |
+#else | |
template <typename T0, typename T1> | |
+#endif | |
struct result | |
{ | |
typedef void type; | |
@@ -66,7 +71,11 @@ struct move_to | |
template <typename PathType> | |
struct hline_to | |
{ | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename T0> | |
+#else | |
template <typename T0, typename T1> | |
+#endif | |
struct result | |
{ | |
typedef void type; | |
@@ -88,7 +97,11 @@ struct hline_to | |
template <typename PathType> | |
struct vline_to | |
{ | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename T0> | |
+#else | |
template <typename T0, typename T1> | |
+#endif | |
struct result | |
{ | |
typedef void type; | |
@@ -109,7 +122,11 @@ struct vline_to | |
template <typename PathType> | |
struct line_to | |
{ | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename T0> | |
+#else | |
template <typename T0, typename T1> | |
+#endif | |
struct result | |
{ | |
typedef void type; | |
@@ -131,7 +148,11 @@ struct line_to | |
template <typename PathType> | |
struct curve4 | |
{ | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename T0> | |
+#else | |
template <typename T0, typename T1, typename T2, typename T3> | |
+#endif | |
struct result | |
{ | |
typedef void type; | |
@@ -156,7 +177,11 @@ struct curve4 | |
template <typename PathType> | |
struct curve4_smooth | |
{ | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename T0> | |
+#else | |
template <typename T0, typename T1, typename T2> | |
+#endif | |
struct result | |
{ | |
typedef void type; | |
@@ -178,7 +203,11 @@ struct curve4_smooth | |
template <typename PathType> | |
struct curve3 | |
{ | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename T0> | |
+#else | |
template <typename T0, typename T1, typename T2> | |
+#endif | |
struct result | |
{ | |
typedef void type; | |
@@ -201,7 +230,11 @@ struct curve3 | |
template <typename PathType> | |
struct curve3_smooth | |
{ | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename T0> | |
+#else | |
template <typename T0, typename T1> | |
+#endif | |
struct result | |
{ | |
typedef void type; | |
@@ -223,7 +256,11 @@ struct curve3_smooth | |
template <typename PathType> | |
struct arc_to | |
{ | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename T0> | |
+#else | |
template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5> | |
+#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 <typename TransformType> | |
struct process_matrix | |
{ | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename T0> | |
+#else | |
template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5> | |
+#endif | |
struct result | |
{ | |
typedef void type; | |
@@ -70,7 +74,11 @@ namespace mapnik { namespace svg { | |
template <typename TransformType> | |
struct process_rotate | |
{ | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename T0> | |
+#else | |
template <typename T0, typename T1, typename T2> | |
+#endif | |
struct result | |
{ | |
typedef void type; | |
@@ -101,7 +109,11 @@ namespace mapnik { namespace svg { | |
template <typename TransformType> | |
struct process_translate | |
{ | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename T0> | |
+#else | |
template <typename T0, typename T1> | |
+#endif | |
struct result | |
{ | |
typedef void type; | |
@@ -123,7 +135,11 @@ namespace mapnik { namespace svg { | |
template <typename TransformType> | |
struct process_scale | |
{ | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename T0> | |
+#else | |
template <typename T0, typename T1> | |
+#endif | |
struct result | |
{ | |
typedef void type; | |
@@ -146,7 +162,11 @@ namespace mapnik { namespace svg { | |
template <typename TransformType> | |
struct process_skew | |
{ | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename T0> | |
+#else | |
template <typename T0, typename T1> | |
+#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 <mapnik/global.hpp> | |
#include <mapnik/geometry.hpp> // for container stuff | |
@@ -41,13 +42,11 @@ | |
#include <boost/fusion/include/boost_tuple.hpp> | |
#include <boost/type_traits/remove_pointer.hpp> | |
-//#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<path_type const> | |
{ | |
static mapnik::util::path_iterator<path_type> | |
- call (path_type const& g) | |
+ call (path_type const& /*g*/) | |
{ | |
return mapnik::util::path_iterator<path_type>(); | |
} | |
@@ -92,6 +91,31 @@ namespace mapnik { namespace util { | |
namespace svg_detail { | |
+#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 | |
+ template <typename Geometry> | |
+ struct get_type | |
+ { | |
+ typedef int result_type; | |
+ result_type operator() (Geometry const& geom) const | |
+ { | |
+ return static_cast<int>(geom.type()); | |
+ } | |
+ }; | |
+ | |
+ template <typename T> | |
+ 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 <typename Geometry> | |
struct get_type | |
{ | |
@@ -112,7 +136,7 @@ namespace mapnik { namespace util { | |
template <typename U> | |
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 <typename T> | |
struct coordinate_policy : karma::real_policies<T> | |
{ | |
typedef boost::spirit::karma::real_policies<T> 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 <boost/type_traits/remove_pointer.hpp> | |
#include <boost/math/special_functions/trunc.hpp> // trunc to avoid needing C++11 | |
-//#define BOOST_SPIRIT_USE_PHOENIX_V3 1 | |
namespace boost { namespace spirit { namespace traits { | |
@@ -205,8 +204,7 @@ template <typename OutputIterator, typename GeometryContainer> | |
struct wkt_multi_generator : | |
karma::grammar<OutputIterator, karma::locals< boost::tuple<unsigned,bool> >, GeometryContainer const& ()> | |
{ | |
- typedef GeometryContainer geometry_contaner; | |
- typedef boost::remove_pointer<typename geometry_container::value_type>::type geometry_type; | |
+ typedef typename boost::remove_pointer<typename GeometryContainer::value_type>::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 <typename T> | |
+#else | |
template <typename T0,typename T1, typename T2, typename T3> | |
+#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 <boost/version.hpp> | |
#if BOOST_VERSION >= 105200 | |
+#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 | |
#define BOOST_SPIRIT_USE_PHOENIX_V3 | |
#endif | |
+#endif | |
// mapnik | |
#include <mapnik/json/feature_collection_parser.hpp> | |
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 <boost/algorithm/string.hpp> | |
#include <boost/spirit/include/support_multi_pass.hpp> | |
#include <boost/foreach.hpp> | |
-#include <boost/geometry/geometries/box.hpp> | |
-#include <boost/geometry/geometries/geometries.hpp> | |
-#include <boost/geometry.hpp> | |
-#include <boost/geometry/extensions/index/rtree/rtree.hpp> | |
// mapnik | |
#include <mapnik/unicode.hpp> | |
@@ -101,7 +97,11 @@ geojson_datasource::geojson_datasource(parameters const& params) | |
extent_(), | |
tr_(new mapnik::transcoder(*params.get<std::string>("encoding","utf-8"))), | |
features_(), | |
+#if BOOST_VERSION >= 105600 | |
+ tree_() | |
+#else | |
tree_(16,1) | |
+#endif | |
{ | |
if (file_.empty()) throw mapnik::datasource_exception("GeoJSON Plugin: missing <file> 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<double> const& box = f->envelope(); | |
+ mapnik::box2d<double> 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<geojson_featureset>(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 <boost/optional.hpp> | |
#include <boost/shared_ptr.hpp> | |
-#include <boost/geometry/geometries/box.hpp> | |
#include <boost/geometry/geometries/point_xy.hpp> | |
-#include <boost/geometry/algorithms/area.hpp> | |
+#include <boost/geometry/geometries/box.hpp> | |
#include <boost/geometry/geometries/geometries.hpp> | |
+#include <boost/geometry.hpp> | |
+#include <boost/version.hpp> | |
+#if BOOST_VERSION >= 105600 | |
+#include <boost/geometry/index/rtree.hpp> | |
+#else | |
#include <boost/geometry/extensions/index/rtree/rtree.hpp> | |
+#endif | |
// stl | |
#include <vector> | |
@@ -53,7 +58,14 @@ class geojson_datasource : public mapnik::datasource | |
public: | |
typedef boost::geometry::model::d2::point_xy<double> point_type; | |
typedef boost::geometry::model::box<point_type> box_type; | |
+#if BOOST_VERSION >= 105600 | |
+ typedef std::pair<box_type,std::size_t> item_type; | |
+ typedef boost::geometry::index::linear<16,1> linear_type; | |
+ typedef boost::geometry::index::rtree<item_type,linear_type> spatial_index_type; | |
+#else | |
+ typedef std::size_t item_type; | |
typedef boost::geometry::index::rtree<box_type,std::size_t> spatial_index_type; | |
+#endif | |
// constructor | |
geojson_datasource(mapnik::parameters const& params); | |
@@ -74,7 +86,7 @@ class geojson_datasource : public mapnik::datasource | |
boost::shared_ptr<mapnik::transcoder> tr_; | |
std::vector<mapnik::feature_ptr> features_; | |
spatial_index_type tree_; | |
- mutable std::deque<std::size_t> index_array_; | |
+ mutable std::deque<item_type> 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<mapnik::feature_ptr> const& features, | |
- std::deque<std::size_t>::const_iterator index_itr, | |
- std::deque<std::size_t>::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<geojson_datasource::item_type> array_type; | |
geojson_featureset(std::vector<mapnik::feature_ptr> const& features, | |
- std::deque<std::size_t>::const_iterator index_itr, | |
- std::deque<std::size_t>::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<double> box_; | |
std::vector<mapnik::feature_ptr> const& features_; | |
- std::deque<std::size_t>::const_iterator index_itr_; | |
- std::deque<std::size_t>::const_iterator index_end_; | |
+ array_type::const_iterator index_itr_; | |
+ array_type::const_iterator index_end_; | |
}; | |
#endif // GEOJSON_FEATURESET_HPP | |
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 <boost/algorithm/string.hpp> | |
#include <boost/optional.hpp> | |
+#include <boost/version.hpp> | |
#include <boost/property_tree/ptree.hpp> | |
#include <boost/property_tree/xml_parser.hpp> | |
@@ -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<ptree::key_type>(' ',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<ptree::key_type>(' ',4)); | |
+#else | |
write_xml(ss,pt,boost::property_tree::xml_writer_make_settings(' ',4)); | |
+#endif | |
return ss.str(); | |
} | |
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: | |
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<mapnik::image_ptr> get_bitmap_data() const |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment