diff --git a/include/mapnik/json/feature_generator_grammar.hpp b/include/mapnik/json/feature_generator_grammar.hpp index 9eaa3bb99..4e393ea0e 100644 --- a/include/mapnik/json/feature_generator_grammar.hpp +++ b/include/mapnik/json/feature_generator_grammar.hpp @@ -63,17 +63,6 @@ struct end_container } }; -template <> -struct transform_attribute, - mapnik::geometry::geometry const& , karma::domain> -{ - using type = mapnik::geometry::geometry const&; - static type pre(const boost::fusion::cons& f) - { - return boost::fusion::at >(f).get_geometry(); - } -}; - }}} namespace mapnik { namespace json { @@ -91,6 +80,15 @@ struct get_id } }; +struct extract_geometry +{ + using result_type = mapnik::geometry::geometry const&; + template + result_type operator() (T const& f) const + { + return f.get_geometry(); + } +}; template struct feature_generator_grammar : @@ -101,6 +99,7 @@ struct feature_generator_grammar : geometry_generator_grammar > geometry; properties_generator_grammar properties; boost::phoenix::function > id_; + boost::phoenix::function geom_; }; }} diff --git a/include/mapnik/json/feature_generator_grammar_impl.hpp b/include/mapnik/json/feature_generator_grammar_impl.hpp index f819baa80..7008bb9f3 100644 --- a/include/mapnik/json/feature_generator_grammar_impl.hpp +++ b/include/mapnik/json/feature_generator_grammar_impl.hpp @@ -40,7 +40,7 @@ feature_generator_grammar::feature_generator_gramma feature = lit("{\"type\":\"Feature\",\"id\":") << uint_[_1 = id_(_val)] - << lit(",\"geometry\":") << geometry + << lit(",\"geometry\":") << geometry[_1 = geom_(_val)] << lit(",\"properties\":") << properties << lit('}') ; diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index 018608849..3203a79f4 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -26,13 +26,10 @@ // mapnik #include #include -#include // boost #pragma GCC diagnostic push #include #include -#include -#include #include // for vc++ and android whose c++11 libs lack std::trunc #include #pragma GCC diagnostic pop @@ -43,18 +40,6 @@ namespace karma = boost::spirit::karma; namespace detail { -template -struct get_type -{ - using result_type = mapnik::geometry::geometry_types; - template - result_type operator() (T const& geom) const - { - auto type = mapnik::geometry::geometry_type(geom); - return type; - } -}; - template struct json_coordinate_policy : karma::real_policies { @@ -88,29 +73,29 @@ struct json_coordinate_policy : karma::real_policies template struct geometry_generator_grammar : - karma::grammar + karma::grammar { + using coord_type = typename Geometry::coord_type; geometry_generator_grammar(); - karma::rule geometry; - karma::rule, Geometry const&() > geometry_dispatch; - karma::rule const&()> point; - karma::rule const&()> point_coord; - karma::rule const&()> linestring; - karma::rule const&()> linestring_coord; - karma::rule const&()> polygon; - karma::rule const&()> polygon_coord; - karma::rule const&()> exterior_ring_coord; - karma::rule::rings_container const&()> interior_ring_coord; - karma::rule const& ()> multi_point; - karma::rule const& ()> multi_point_coord; - karma::rule const& ()> multi_linestring; - karma::rule const& ()> multi_linestring_coord; - karma::rule const& ()> multi_polygon; - karma::rule const& ()> multi_polygon_coord; - karma::rule const& ()> geometry_collection; - karma::rule const& ()> geometries; - boost::phoenix::function > geometry_type; - karma::real_generator > coordinate; + karma::rule geometry; + karma::rule()> point; + karma::rule()> point_coord; + karma::rule()> linestring; + karma::rule()> linestring_coord; + karma::rule()> polygon; + karma::rule()> polygon_coord; + karma::rule()> exterior_ring_coord; + karma::rule >()> interior_ring_coord; + karma::rule()> multi_point; + karma::rule()> multi_point_coord; + karma::rule()> multi_linestring; + karma::rule ()> multi_linestring_coord; + karma::rule()> multi_polygon; + karma::rule()> multi_polygon_coord; + karma::rule()> geometry_collection; + karma::rule()> geometries; + // + karma::real_generator > coordinate; }; diff --git a/include/mapnik/json/geometry_generator_grammar_impl.hpp b/include/mapnik/json/geometry_generator_grammar_impl.hpp index c1e2b4fe8..8a546d67b 100644 --- a/include/mapnik/json/geometry_generator_grammar_impl.hpp +++ b/include/mapnik/json/geometry_generator_grammar_impl.hpp @@ -22,60 +22,33 @@ // mapnik #include -#include -#include #include -// boost -#pragma GCC diagnostic push -#include -#include -#include -#include -#include -#include -#pragma GCC diagnostic pop namespace mapnik { namespace json { namespace karma = boost::spirit::karma; -namespace phoenix = boost::phoenix; template geometry_generator_grammar::geometry_generator_grammar() : geometry_generator_grammar::base_type(geometry) { - boost::spirit::karma::_val_type _val; - boost::spirit::karma::_1_type _1; - boost::spirit::karma::_a_type _a; boost::spirit::karma::lit_type lit; - boost::spirit::karma::uint_type uint_; - boost::spirit::karma::eps_type eps; - geometry = geometry_dispatch.alias() - ; - - geometry_dispatch = eps[_a = geometry_type(_val)] << - (&uint_(geometry::geometry_types::Point)[_1 = _a] - << (point | lit("null"))) + geometry = + point | - (&uint_(geometry::geometry_types::LineString)[_1 = _a] - << (linestring | lit("null"))) + linestring | - (&uint_(geometry::geometry_types::Polygon)[_1 = _a] - << (polygon | lit("null"))) + polygon | - (&uint_(geometry::geometry_types::MultiPoint)[_1 = _a] - << (multi_point | lit("null"))) + multi_point | - (&uint_(geometry::geometry_types::MultiLineString)[_1 = _a] - << (multi_linestring | lit("null"))) + multi_linestring | - (&uint_(geometry::geometry_types::MultiPolygon)[_1 = _a] - << (multi_polygon | lit("null"))) + multi_polygon | - (&uint_(geometry::geometry_types::GeometryCollection)[_1 = _a] - << (geometry_collection | lit("null"))) + geometry_collection | lit("null") ; diff --git a/include/mapnik/json/properties_generator_grammar_impl.hpp b/include/mapnik/json/properties_generator_grammar_impl.hpp index eff4565b5..df9b113c5 100644 --- a/include/mapnik/json/properties_generator_grammar_impl.hpp +++ b/include/mapnik/json/properties_generator_grammar_impl.hpp @@ -23,6 +23,14 @@ #include +#pragma GCC diagnostic push +#include +#include +#include +#include +#include +#pragma GCC diagnostic pop + namespace mapnik { namespace json { namespace karma = boost::spirit::karma; diff --git a/src/json/mapnik_json_generator_grammar.cpp b/src/json/mapnik_json_generator_grammar.cpp index 2b0171f98..6b8edd136 100644 --- a/src/json/mapnik_json_generator_grammar.cpp +++ b/src/json/mapnik_json_generator_grammar.cpp @@ -20,8 +20,7 @@ * *****************************************************************************/ -#include - +#include #include #include #include @@ -31,5 +30,5 @@ using sink_type = std::back_insert_iterator; template struct mapnik::json::properties_generator_grammar; -template struct mapnik::json::feature_generator_grammar; template struct mapnik::json::geometry_generator_grammar >; +template struct mapnik::json::feature_generator_grammar;