commit
70fbdd21c7
20 changed files with 205 additions and 74 deletions
39
include/mapnik/boost_spirit_instantiate.hpp
Normal file
39
include/mapnik/boost_spirit_instantiate.hpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2018 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_BOOST_SPIRIT_INSTANTIATE_HPP
|
||||
#define MAPNIK_BOOST_SPIRIT_INSTANTIATE_HPP
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
// helper macro
|
||||
#define BOOST_SPIRIT_INSTANTIATE_UNUSED(rule_type, Iterator, Context) \
|
||||
template bool parse_rule<Iterator, Context, boost::spirit::x3::unused_type const>( \
|
||||
rule_type rule_ \
|
||||
, Iterator& first, Iterator const& last \
|
||||
, Context const& context, boost::spirit::x3::unused_type const& ); \
|
||||
/***/
|
||||
|
||||
}}}
|
||||
|
||||
|
||||
#endif // MAPNIK_BOOST_SPIRIT_INSTANTIATE_HPP
|
|
@ -24,7 +24,7 @@
|
|||
#define MAPNIK_EXPRESSIONS_GRAMMAR_X3_HPP
|
||||
|
||||
#include <mapnik/expression_node.hpp>
|
||||
|
||||
#include <mapnik/unicode.hpp>
|
||||
#pragma GCC diagnostic push
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <boost/spirit/home/x3.hpp>
|
||||
|
@ -32,6 +32,13 @@
|
|||
|
||||
namespace mapnik { namespace grammar {
|
||||
|
||||
#if BOOST_VERSION >= 106700
|
||||
using transcoder_type = mapnik::transcoder;
|
||||
#else
|
||||
using transcoder_type = std::reference_wrapper<mapnik::transcoder const>;
|
||||
#endif
|
||||
|
||||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
struct transcoder_tag;
|
||||
struct expression_class; // top-most ID
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#define MAPNIK_EXPRESSIONS_GRAMMAR_X3_CONFIG_HPP
|
||||
|
||||
#include <mapnik/expression_grammar_x3.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace mapnik { namespace grammar {
|
||||
|
@ -32,10 +31,9 @@ namespace mapnik { namespace grammar {
|
|||
namespace x3 = boost::spirit::x3;
|
||||
using iterator_type = std::string::const_iterator;
|
||||
using phrase_context_type = x3::phrase_parse_context<x3::ascii::space_type>::type;
|
||||
|
||||
// define combined context
|
||||
using context_type = x3::context<transcoder_tag,
|
||||
std::reference_wrapper<mapnik::transcoder const> const,
|
||||
transcoder_type const,
|
||||
phrase_context_type>;
|
||||
|
||||
}}
|
||||
|
|
|
@ -70,6 +70,12 @@ namespace mapnik { namespace grammar {
|
|||
auto const& escaped_unicode = json::grammar::escaped_unicode;
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
inline mapnik::transcoder const& extract_transcoder(Context const& ctx)
|
||||
{
|
||||
return x3::get<transcoder_tag>(ctx);
|
||||
}
|
||||
|
||||
auto append = [](auto const& ctx)
|
||||
{
|
||||
_val(ctx) += _attr(ctx);
|
||||
|
@ -130,7 +136,7 @@ namespace mapnik { namespace grammar {
|
|||
|
||||
auto do_unicode = [] (auto const& ctx)
|
||||
{
|
||||
auto const& tr = x3::get<transcoder_tag>(ctx).get();
|
||||
auto const& tr = extract_transcoder(ctx);
|
||||
_val(ctx) = std::move(tr.transcode(_attr(ctx).c_str()));
|
||||
};
|
||||
|
||||
|
@ -188,13 +194,13 @@ namespace mapnik { namespace grammar {
|
|||
// regex
|
||||
auto do_regex_match = [] (auto const& ctx)
|
||||
{
|
||||
auto const& tr = x3::get<transcoder_tag>(ctx).get();
|
||||
auto const& tr = extract_transcoder(ctx);
|
||||
_val(ctx) = std::move(mapnik::regex_match_node(tr, std::move(_val(ctx)) , std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_regex_replace = [] (auto const& ctx)
|
||||
{
|
||||
auto const& tr = x3::get<transcoder_tag>(ctx).get();
|
||||
auto const& tr = extract_transcoder(ctx);
|
||||
auto const& pair = _attr(ctx);
|
||||
auto const& pattern = std::get<0>(pair);
|
||||
auto const& format = std::get<1>(pair);
|
||||
|
|
|
@ -67,13 +67,24 @@ struct extract_positions
|
|||
|
||||
using box_type = mapnik::box2d<double>;
|
||||
using boxes_type = std::vector<std::pair<box_type, std::pair<std::uint64_t, std::uint64_t>>>;
|
||||
using callback_type = extract_positions<grammar::iterator_type, boxes_type>;
|
||||
|
||||
|
||||
using box_type_f = mapnik::box2d<float>;
|
||||
using boxes_type_f = std::vector<std::pair<box_type_f, std::pair<std::uint64_t, std::uint64_t>>>;
|
||||
using callback_type_f = extract_positions<grammar::iterator_type, boxes_type_f>;
|
||||
|
||||
|
||||
#if BOOST_VERSION >= 106700
|
||||
using size_type = std::size_t;
|
||||
using keys_map_type = keys_map;
|
||||
using callback_type = extract_positions<grammar::iterator_type, boxes_type>;
|
||||
using callback_type_f = extract_positions<grammar::iterator_type, boxes_type_f>;
|
||||
#else
|
||||
using size_type = std::reference_wrapper<std::size_t> const;
|
||||
using keys_map_type = std::reference_wrapper<keys_map> const;
|
||||
using callback_type = std::reference_wrapper<extract_positions<grammar::iterator_type, boxes_type>> const;
|
||||
using callback_type_f = std::reference_wrapper<extract_positions<grammar::iterator_type, boxes_type_f>> const;
|
||||
#endif
|
||||
|
||||
namespace grammar {
|
||||
|
||||
struct bracket_tag;
|
||||
|
@ -84,30 +95,27 @@ using space_type = x3::standard::space_type;
|
|||
|
||||
using phrase_parse_context_type = x3::phrase_parse_context<space_type>::type;
|
||||
|
||||
using context_type = x3::context<keys_tag, std::reference_wrapper<keys_map> const,
|
||||
phrase_parse_context_type>;
|
||||
|
||||
using extract_bounding_boxes_context_type =
|
||||
x3::context<bracket_tag, std::reference_wrapper<std::size_t> const,
|
||||
x3::context<feature_callback_tag, std::reference_wrapper<callback_type> const,
|
||||
context_type>>;
|
||||
x3::context<bracket_tag, size_type,
|
||||
x3::context<feature_callback_tag, callback_type,
|
||||
context_type>>;
|
||||
|
||||
using extract_bounding_boxes_reverse_context_type =
|
||||
x3::context<keys_tag, std::reference_wrapper<keys_map> const,
|
||||
x3::context<feature_callback_tag, std::reference_wrapper<callback_type> const,
|
||||
x3::context<bracket_tag, std::reference_wrapper<std::size_t> const,
|
||||
x3::context<keys_tag, keys_map_type,
|
||||
x3::context<feature_callback_tag, callback_type,
|
||||
x3::context<bracket_tag, size_type,
|
||||
phrase_parse_context_type>>>;
|
||||
|
||||
|
||||
using extract_bounding_boxes_context_type_f =
|
||||
x3::context<bracket_tag, std::reference_wrapper<std::size_t> const,
|
||||
x3::context<feature_callback_tag, std::reference_wrapper<callback_type_f> const,
|
||||
x3::context<bracket_tag, size_type,
|
||||
x3::context<feature_callback_tag, callback_type_f,
|
||||
context_type>>;
|
||||
|
||||
using extract_bounding_boxes_reverse_context_type_f =
|
||||
x3::context<keys_tag, std::reference_wrapper<keys_map> const,
|
||||
x3::context<feature_callback_tag, std::reference_wrapper<callback_type_f> const,
|
||||
x3::context<bracket_tag, std::reference_wrapper<std::size_t> const,
|
||||
x3::context<keys_tag, keys_map_type,
|
||||
x3::context<feature_callback_tag, callback_type_f,
|
||||
x3::context<bracket_tag, size_type,
|
||||
phrase_parse_context_type>>>;
|
||||
|
||||
}}}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <boost/bimap/unordered_set_of.hpp>
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
#include <mapnik/boost_spirit_instantiate.hpp>
|
||||
|
||||
namespace mapnik { namespace json {
|
||||
|
||||
|
@ -89,33 +90,35 @@ struct feature_tag;
|
|||
namespace x3 = boost::spirit::x3;
|
||||
using space_type = x3::standard::space_type;
|
||||
using iterator_type = char const*;
|
||||
|
||||
using phrase_parse_context_type = x3::phrase_parse_context<space_type>::type;
|
||||
|
||||
#if BOOST_VERSION >= 106700
|
||||
using keys_map_type = keys_map;
|
||||
using transcoder_type = mapnik::transcoder const;
|
||||
using feature_impl_type = mapnik::feature_impl;
|
||||
#else
|
||||
using keys_map_type = std::reference_wrapper<keys_map> const;
|
||||
using transcoder_type = std::reference_wrapper<mapnik::transcoder const> const;
|
||||
using feature_impl_type = std::reference_wrapper<mapnik::feature_impl> const;
|
||||
#endif
|
||||
|
||||
using context_type = x3::context<keys_tag,
|
||||
std::reference_wrapper<keys_map> const,
|
||||
keys_map_type,
|
||||
phrase_parse_context_type>;
|
||||
|
||||
using feature_context_type = x3::context<transcoder_tag,
|
||||
std::reference_wrapper<mapnik::transcoder> const,
|
||||
transcoder_type,
|
||||
x3::context<feature_tag,
|
||||
std::reference_wrapper<mapnik::feature_impl> const,
|
||||
phrase_parse_context_type>>;
|
||||
feature_impl_type,
|
||||
phrase_parse_context_type>>;
|
||||
|
||||
// our spirit x3 grammars needs this one with changed order of feature_impl and transcoder (??)
|
||||
using feature_context_const_type = x3::context<feature_tag,
|
||||
std::reference_wrapper<mapnik::feature_impl> const,
|
||||
feature_impl_type,
|
||||
x3::context<transcoder_tag,
|
||||
std::reference_wrapper<mapnik::transcoder const> const,
|
||||
transcoder_type,
|
||||
phrase_parse_context_type>>;
|
||||
|
||||
// helper macro
|
||||
#define BOOST_SPIRIT_INSTANTIATE_UNUSED(rule_type, Iterator, Context) \
|
||||
template bool parse_rule<Iterator, Context, boost::spirit::x3::unused_type const>( \
|
||||
rule_type rule_ \
|
||||
, Iterator& first, Iterator const& last \
|
||||
, Context const& context, boost::spirit::x3::unused_type const& ); \
|
||||
/***/
|
||||
|
||||
}}}
|
||||
|
||||
#endif // MAPNIK_JSON_GRAMMAR_CONFIG_HPP
|
||||
|
|
|
@ -39,9 +39,17 @@ namespace x3 = boost::spirit::x3;
|
|||
using space_type = x3::standard::space_type;
|
||||
using iterator_type = char const*;
|
||||
|
||||
#if BOOST_VERSION >= 106700
|
||||
using svg_converter_wrapper_type = svg_converter_type;
|
||||
using relative_type = bool;
|
||||
#else
|
||||
using svg_converter_wrapper_type = std::reference_wrapper<svg_converter_type> const;
|
||||
using relative_type = std::reference_wrapper<bool> const;
|
||||
#endif
|
||||
|
||||
using phrase_parse_context_type = x3::phrase_parse_context<space_type>::type;
|
||||
using svg_parse_context_type = x3::context<relative_tag, std::reference_wrapper<bool> const,
|
||||
x3::context<svg_path_tag,std::reference_wrapper<svg_converter_type> const,
|
||||
using svg_parse_context_type = x3::context<relative_tag, relative_type,
|
||||
x3::context<svg_path_tag, svg_converter_wrapper_type,
|
||||
phrase_parse_context_type>>;
|
||||
|
||||
inline double deg2rad(double deg) {return (M_PI * deg) / 180.0;}
|
||||
|
|
|
@ -43,24 +43,36 @@ using x3::no_case;
|
|||
|
||||
using coord_type = std::tuple<double,double>;
|
||||
|
||||
template <typename Context>
|
||||
svg_converter_type & extract_path(Context const& ctx)
|
||||
{
|
||||
return x3::get<svg_path_tag>(ctx);
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
bool & extract_relative(Context const& ctx)
|
||||
{
|
||||
return x3::get<relative_tag>(ctx);
|
||||
}
|
||||
|
||||
auto const move_to = [] (auto const& ctx)
|
||||
{
|
||||
x3::get<svg_path_tag>(ctx).get().move_to(std::get<0>(_attr(ctx)), std::get<1>(_attr(ctx)), x3::get<relative_tag>(ctx));
|
||||
extract_path(ctx).move_to(std::get<0>(_attr(ctx)), std::get<1>(_attr(ctx)), x3::get<relative_tag>(ctx));
|
||||
};
|
||||
|
||||
auto const line_to = [] (auto const & ctx)
|
||||
{
|
||||
x3::get<svg_path_tag>(ctx).get().line_to(std::get<0>(_attr(ctx)), std::get<1>(_attr(ctx)), x3::get<relative_tag>(ctx));
|
||||
extract_path(ctx).line_to(std::get<0>(_attr(ctx)), std::get<1>(_attr(ctx)), x3::get<relative_tag>(ctx));
|
||||
};
|
||||
|
||||
auto const hline_to = [] (auto const& ctx)
|
||||
{
|
||||
x3::get<svg_path_tag>(ctx).get().hline_to(_attr(ctx), x3::get<relative_tag>(ctx));
|
||||
extract_path(ctx).hline_to(_attr(ctx), x3::get<relative_tag>(ctx));
|
||||
};
|
||||
|
||||
auto const vline_to = [] (auto const& ctx)
|
||||
{
|
||||
x3::get<svg_path_tag>(ctx).get().vline_to(_attr(ctx), x3::get<relative_tag>(ctx));
|
||||
extract_path(ctx).vline_to(_attr(ctx), x3::get<relative_tag>(ctx));
|
||||
};
|
||||
|
||||
auto const curve4 = [] (auto const& ctx)
|
||||
|
@ -69,7 +81,7 @@ auto const curve4 = [] (auto const& ctx)
|
|||
auto const& p0 = boost::fusion::at_c<0>(attr);
|
||||
auto const& p1 = boost::fusion::at_c<1>(attr);
|
||||
auto const& p2 = boost::fusion::at_c<2>(attr);
|
||||
x3::get<svg_path_tag>(ctx).get().curve4(std::get<0>(p0),std::get<1>(p0),
|
||||
extract_path(ctx).curve4(std::get<0>(p0),std::get<1>(p0),
|
||||
std::get<0>(p1),std::get<1>(p1),
|
||||
std::get<0>(p2),std::get<1>(p2),
|
||||
x3::get<relative_tag>(ctx));
|
||||
|
@ -80,7 +92,7 @@ auto const curve4_smooth = [] (auto const& ctx)
|
|||
auto const& attr = _attr(ctx);
|
||||
auto const& p0 = boost::fusion::at_c<0>(attr);
|
||||
auto const& p1 = boost::fusion::at_c<1>(attr);
|
||||
x3::get<svg_path_tag>(ctx).get().curve4(std::get<0>(p0),std::get<1>(p0),
|
||||
extract_path(ctx).curve4(std::get<0>(p0),std::get<1>(p0),
|
||||
std::get<0>(p1),std::get<1>(p1),
|
||||
x3::get<relative_tag>(ctx));
|
||||
};
|
||||
|
@ -90,7 +102,7 @@ auto const curve3 = [] (auto const& ctx)
|
|||
auto const& attr = _attr(ctx);
|
||||
auto const& p0 = boost::fusion::at_c<0>(attr);
|
||||
auto const& p1 = boost::fusion::at_c<1>(attr);
|
||||
x3::get<svg_path_tag>(ctx).get().curve3(std::get<0>(p0),std::get<1>(p0),
|
||||
extract_path(ctx).curve3(std::get<0>(p0),std::get<1>(p0),
|
||||
std::get<0>(p1),std::get<1>(p1),
|
||||
x3::get<relative_tag>(ctx));
|
||||
};
|
||||
|
@ -98,7 +110,7 @@ auto const curve3 = [] (auto const& ctx)
|
|||
auto const curve3_smooth = [] (auto const& ctx)
|
||||
{
|
||||
auto const& attr = _attr(ctx);
|
||||
x3::get<svg_path_tag>(ctx).get().curve3(std::get<0>(attr),std::get<1>(attr),
|
||||
extract_path(ctx).curve3(std::get<0>(attr),std::get<1>(attr),
|
||||
x3::get<relative_tag>(ctx));
|
||||
};
|
||||
|
||||
|
@ -111,7 +123,7 @@ auto const arc_to = [] (auto & ctx)
|
|||
int large_arc_flag = boost::fusion::at_c<2>(attr);
|
||||
int sweep_flag = boost::fusion::at_c<3>(attr);
|
||||
auto const& v = boost::fusion::at_c<4>(attr);
|
||||
x3::get<svg_path_tag>(ctx).get().arc_to(std::get<0>(p),std::get<1>(p),
|
||||
extract_path(ctx).arc_to(std::get<0>(p),std::get<1>(p),
|
||||
deg2rad(angle), large_arc_flag, sweep_flag,
|
||||
std::get<0>(v),std::get<1>(v),
|
||||
x3::get<relative_tag>(ctx));
|
||||
|
@ -119,17 +131,17 @@ auto const arc_to = [] (auto & ctx)
|
|||
|
||||
auto const close_path = [] (auto const& ctx)
|
||||
{
|
||||
x3::get<svg_path_tag>(ctx).get().close_subpath();
|
||||
extract_path(ctx).close_subpath();
|
||||
};
|
||||
|
||||
auto const relative = [] (auto const& ctx)
|
||||
{
|
||||
x3::get<relative_tag>(ctx).get() = true;
|
||||
extract_relative(ctx) = true;
|
||||
};
|
||||
|
||||
auto const absolute = [] (auto const& ctx)
|
||||
{
|
||||
x3::get<relative_tag>(ctx).get() = false;
|
||||
extract_relative(ctx) = false;
|
||||
};
|
||||
|
||||
// exported rules
|
||||
|
|
|
@ -44,9 +44,15 @@ using x3::lit;
|
|||
using x3::double_;
|
||||
using x3::no_case;
|
||||
|
||||
template <typename Context>
|
||||
agg::trans_affine & extract_transform(Context const& ctx)
|
||||
{
|
||||
return x3::get<svg_transform_tag>(ctx);
|
||||
}
|
||||
|
||||
auto const matrix_action = [] (auto const& ctx)
|
||||
{
|
||||
auto & tr = x3::get<svg_transform_tag>(ctx).get();
|
||||
auto & tr = extract_transform(ctx);
|
||||
auto const& attr = _attr(ctx);
|
||||
auto a = boost::fusion::at_c<0>(attr);
|
||||
auto b = boost::fusion::at_c<1>(attr);
|
||||
|
@ -59,7 +65,7 @@ auto const matrix_action = [] (auto const& ctx)
|
|||
|
||||
auto const rotate_action = [] (auto const& ctx)
|
||||
{
|
||||
auto & tr = x3::get<svg_transform_tag>(ctx).get();
|
||||
auto & tr = extract_transform(ctx);
|
||||
auto const& attr = _attr(ctx);
|
||||
auto a = boost::fusion::at_c<0>(attr);
|
||||
auto cx = boost::fusion::at_c<1>(attr) ? *boost::fusion::at_c<1>(attr) : 0.0;
|
||||
|
@ -79,7 +85,7 @@ auto const rotate_action = [] (auto const& ctx)
|
|||
|
||||
auto const translate_action = [] (auto const& ctx)
|
||||
{
|
||||
auto & tr = x3::get<svg_transform_tag>(ctx).get();
|
||||
auto & tr = extract_transform(ctx);
|
||||
auto const& attr = _attr(ctx);
|
||||
auto tx = boost::fusion::at_c<0>(attr);
|
||||
auto ty = boost::fusion::at_c<1>(attr);
|
||||
|
@ -89,7 +95,7 @@ auto const translate_action = [] (auto const& ctx)
|
|||
|
||||
auto const scale_action = [] (auto const& ctx)
|
||||
{
|
||||
auto & tr = x3::get<svg_transform_tag>(ctx).get();
|
||||
auto & tr = extract_transform(ctx);
|
||||
auto const& attr = _attr(ctx);
|
||||
auto sx = boost::fusion::at_c<0>(attr);
|
||||
auto sy = boost::fusion::at_c<1>(attr);
|
||||
|
@ -99,14 +105,14 @@ auto const scale_action = [] (auto const& ctx)
|
|||
|
||||
auto const skewX_action = [] (auto const& ctx)
|
||||
{
|
||||
auto & tr = x3::get<svg_transform_tag>(ctx).get();
|
||||
auto & tr = extract_transform(ctx);
|
||||
auto skew_x = _attr(ctx);
|
||||
tr = agg::trans_affine_skewing(deg2rad(skew_x), 0.0) * tr;
|
||||
};
|
||||
|
||||
auto const skewY_action = [] (auto const& ctx)
|
||||
{
|
||||
auto & tr = x3::get<svg_transform_tag>(ctx).get();
|
||||
auto & tr = extract_transform(ctx);
|
||||
auto skew_y= _attr(ctx);
|
||||
tr = agg::trans_affine_skewing(0.0, deg2rad(skew_y)) * tr;
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#include <mapnik/css_color_grammar_x3_def.hpp>
|
||||
|
||||
#include <mapnik/image_filter_types.hpp>
|
||||
namespace mapnik { namespace css_color_grammar {
|
||||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
|
@ -30,4 +30,7 @@ using context_type = x3::phrase_parse_context<x3::ascii::space_type>::type;
|
|||
|
||||
BOOST_SPIRIT_INSTANTIATE(css_color_grammar_type, iterator_type, context_type);
|
||||
|
||||
template bool parse_rule<iterator_type, context_type, mapnik::filter::color_to_alpha>
|
||||
(css_color_grammar_type, iterator_type&, iterator_type const&, context_type const&, mapnik::filter::color_to_alpha&);
|
||||
|
||||
}}
|
||||
|
|
|
@ -35,11 +35,17 @@ expression_ptr parse_expression(std::string const& str)
|
|||
auto node = std::make_shared<expr_node>();
|
||||
using boost::spirit::x3::ascii::space;
|
||||
mapnik::transcoder const tr("utf8");
|
||||
#if BOOST_VERSION >=106700
|
||||
auto parser = boost::spirit::x3::with<mapnik::grammar::transcoder_tag>(tr)
|
||||
[
|
||||
mapnik::expression_grammar()
|
||||
];
|
||||
#else
|
||||
auto parser = boost::spirit::x3::with<mapnik::grammar::transcoder_tag>(std::ref(tr))
|
||||
[
|
||||
mapnik::expression_grammar()
|
||||
];
|
||||
|
||||
#endif
|
||||
bool r = false;
|
||||
std::string::const_iterator itr = str.begin();
|
||||
std::string::const_iterator const end = str.end();
|
||||
|
|
|
@ -185,12 +185,19 @@ void extract_bounding_boxes(Iterator& start, Iterator const& end, Boxes & boxes)
|
|||
extract_positions<iterator_type, Boxes> callback(start, boxes);
|
||||
auto keys = mapnik::json::get_keys();
|
||||
std::size_t bracket_counter = 0;
|
||||
#if BOOST_VERSION >= 106700
|
||||
auto feature_collection_impl = x3::with<mapnik::json::grammar::bracket_tag>(bracket_counter)
|
||||
[x3::with<mapnik::json::grammar::feature_callback_tag>(callback)
|
||||
[x3::with<mapnik::json::grammar::keys_tag>(keys)
|
||||
[mapnik::json::grammar::feature_collection]
|
||||
]];
|
||||
#else
|
||||
auto feature_collection_impl = x3::with<mapnik::json::grammar::bracket_tag>(std::ref(bracket_counter))
|
||||
[x3::with<mapnik::json::grammar::feature_callback_tag>(std::ref(callback))
|
||||
[x3::with<mapnik::json::grammar::keys_tag>(std::ref(keys))
|
||||
[mapnik::json::grammar::feature_collection]
|
||||
]];
|
||||
|
||||
#endif
|
||||
if (!x3::phrase_parse(start, end, feature_collection_impl, space_type()))
|
||||
{
|
||||
throw std::runtime_error("Can't extract bounding boxes");
|
||||
|
|
|
@ -27,8 +27,6 @@ namespace mapnik { namespace json { namespace grammar {
|
|||
|
||||
BOOST_SPIRIT_INSTANTIATE(feature_grammar_type, iterator_type, feature_context_type);
|
||||
BOOST_SPIRIT_INSTANTIATE(geometry_grammar_type, iterator_type, phrase_parse_context_type);
|
||||
|
||||
BOOST_SPIRIT_INSTANTIATE_UNUSED(feature_grammar_type, iterator_type, feature_context_type);
|
||||
BOOST_SPIRIT_INSTANTIATE_UNUSED(feature_grammar_type, iterator_type, feature_context_const_type);
|
||||
|
||||
}
|
||||
|
|
|
@ -31,9 +31,15 @@ void parse_feature(Iterator start, Iterator end, feature_impl& feature, mapnik::
|
|||
{
|
||||
namespace x3 = boost::spirit::x3;
|
||||
using space_type = mapnik::json::grammar::space_type;
|
||||
#if BOOST_VERSION >= 106700
|
||||
auto grammar = x3::with<mapnik::json::grammar::transcoder_tag>(tr)
|
||||
[x3::with<mapnik::json::grammar::feature_tag>(feature)
|
||||
[ mapnik::json::feature_grammar() ]];
|
||||
#else
|
||||
auto grammar = x3::with<mapnik::json::grammar::transcoder_tag>(std::ref(tr))
|
||||
[x3::with<mapnik::json::grammar::feature_tag>(std::ref(feature))
|
||||
[ mapnik::json::feature_grammar() ]];
|
||||
[ mapnik::json::feature_grammar() ]];
|
||||
#endif
|
||||
if (!x3::phrase_parse(start, end, grammar, space_type()))
|
||||
{
|
||||
throw std::runtime_error("Can't parser GeoJSON Feature");
|
||||
|
|
|
@ -37,10 +37,18 @@ transform_list_ptr parse_transform(std::string const& str, std::string const& en
|
|||
std::string::const_iterator itr = str.begin();
|
||||
std::string::const_iterator end = str.end();
|
||||
mapnik::transcoder const tr(encoding);
|
||||
#if BOOST_VERSION >= 106700
|
||||
auto const parser = boost::spirit::x3::with<mapnik::grammar::transcoder_tag>(tr)
|
||||
[
|
||||
mapnik::transform_expression_grammar()
|
||||
];
|
||||
#else
|
||||
auto const parser = boost::spirit::x3::with<mapnik::grammar::transcoder_tag>(std::ref(tr))
|
||||
[
|
||||
mapnik::transform_expression_grammar()
|
||||
];
|
||||
#endif
|
||||
|
||||
bool status = false;
|
||||
try
|
||||
{
|
||||
|
|
|
@ -21,16 +21,10 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#include <mapnik/svg/svg_path_grammar_x3_def.hpp>
|
||||
#include <mapnik/boost_spirit_instantiate.hpp>
|
||||
|
||||
namespace mapnik { namespace svg { namespace grammar {
|
||||
|
||||
#define BOOST_SPIRIT_INSTANTIATE_UNUSED(rule_type, Iterator, Context) \
|
||||
template bool parse_rule<Iterator, Context, boost::spirit::x3::unused_type const>( \
|
||||
rule_type rule_ \
|
||||
, Iterator& first, Iterator const& last \
|
||||
, Context const& context, boost::spirit::x3::unused_type const& ); \
|
||||
/***/
|
||||
|
||||
BOOST_SPIRIT_INSTANTIATE_UNUSED(svg_path_grammar_type, iterator_type, svg_parse_context_type);
|
||||
BOOST_SPIRIT_INSTANTIATE_UNUSED(svg_points_grammar_type, iterator_type, svg_parse_context_type);
|
||||
|
||||
|
|
|
@ -40,10 +40,15 @@ bool parse_path(const char* wkt, PathType& p)
|
|||
iterator_type last = wkt + std::strlen(wkt);
|
||||
bool relative = false;
|
||||
using space_type = mapnik::svg::grammar::space_type;
|
||||
#if BOOST_VERSION >= 106700
|
||||
auto const grammar = x3::with<mapnik::svg::grammar::svg_path_tag>(p)
|
||||
[ x3::with<mapnik::svg::grammar::relative_tag>(relative)
|
||||
[mapnik::svg::svg_path_grammar()]];
|
||||
#else
|
||||
auto const grammar = x3::with<mapnik::svg::grammar::svg_path_tag>(std::ref(p))
|
||||
[ x3::with<mapnik::svg::grammar::relative_tag>(std::ref(relative))
|
||||
[mapnik::svg::svg_path_grammar()]];
|
||||
|
||||
#endif
|
||||
try
|
||||
{
|
||||
if (!x3::phrase_parse(first, last, grammar, space_type())
|
||||
|
|
|
@ -40,10 +40,15 @@ bool parse_points(const char* wkt, PathType& p)
|
|||
iterator_type last = wkt + std::strlen(wkt);
|
||||
bool relative = false;
|
||||
|
||||
#if BOOST_VERSION >= 106700
|
||||
auto const grammar = x3::with<mapnik::svg::grammar::svg_path_tag>(p)
|
||||
[ x3::with<mapnik::svg::grammar::relative_tag>(relative)
|
||||
[mapnik::svg::svg_points_grammar()]];
|
||||
#else
|
||||
auto const grammar = x3::with<mapnik::svg::grammar::svg_path_tag>(std::ref(p))
|
||||
[ x3::with<mapnik::svg::grammar::relative_tag>(std::ref(relative))
|
||||
[mapnik::svg::svg_points_grammar()]];
|
||||
|
||||
#endif
|
||||
try
|
||||
{
|
||||
if (!x3::phrase_parse(first, last, grammar, space_type())
|
||||
|
|
|
@ -37,8 +37,15 @@ bool parse_svg_transform(const char* wkt, Transform& tr)
|
|||
iterator_type first = wkt;
|
||||
iterator_type last = wkt + std::strlen(wkt);
|
||||
using space_type = mapnik::svg::grammar::space_type;
|
||||
|
||||
#if BOOST_VERSION >= 106700
|
||||
auto const grammar = x3::with<mapnik::svg::grammar::svg_transform_tag>(tr)
|
||||
[mapnik::svg::svg_transform_grammar()];
|
||||
|
||||
#else
|
||||
auto const grammar = x3::with<mapnik::svg::grammar::svg_transform_tag>(std::ref(tr))
|
||||
[mapnik::svg::svg_transform_grammar()];
|
||||
[mapnik::svg::svg_transform_grammar()];
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -285,8 +285,13 @@ std::pair<bool,typename T::value_type::first_type> process_geojson_file_x3(T & b
|
|||
using namespace boost::spirit;
|
||||
using space_type = mapnik::json::grammar::space_type;
|
||||
auto keys = mapnik::json::get_keys();
|
||||
#if BOOST_VERSION >= 106700
|
||||
auto feature_grammar = x3::with<mapnik::json::grammar::keys_tag>(keys)
|
||||
[ geojson_value ];
|
||||
#else
|
||||
auto feature_grammar = x3::with<mapnik::json::grammar::keys_tag>(std::ref(keys))
|
||||
[ geojson_value ];
|
||||
#endif
|
||||
for (auto const& item : boxes)
|
||||
{
|
||||
if (item.first.valid())
|
||||
|
|
Loading…
Reference in a new issue