Replace MAPNIK_INIT_PRIORITY workaround
Spirit rules are just placeholders. They are cheap to construct and by doing this static initialization order fiasco problem is effectively avoided. Also had to fix name clash between geojson and generic json parsers.
This commit is contained in:
parent
01a4057317
commit
c191e196c0
54 changed files with 98 additions and 339 deletions
|
@ -41,15 +41,10 @@ namespace css_color_grammar
|
||||||
struct css_color_class;
|
struct css_color_class;
|
||||||
using css_color_grammar_type = x3::rule<css_color_class, mapnik::color>;
|
using css_color_grammar_type = x3::rule<css_color_class, mapnik::color>;
|
||||||
|
|
||||||
|
css_color_grammar_type const css_color = "css_color";
|
||||||
|
|
||||||
BOOST_SPIRIT_DECLARE(css_color_grammar_type);
|
BOOST_SPIRIT_DECLARE(css_color_grammar_type);
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
namespace mapnik
|
|
||||||
{
|
|
||||||
css_color_grammar::css_color_grammar_type const& color_grammar();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // MAPNIK_CSS_COLOR_GRAMMAR_X3_HPP
|
#endif // MAPNIK_CSS_COLOR_GRAMMAR_X3_HPP
|
||||||
|
|
|
@ -220,8 +220,6 @@ x3::uint_parser<std::uint8_t, 16, 2, 2> hex2;
|
||||||
x3::uint_parser<std::uint8_t, 16, 1, 1> hex1;
|
x3::uint_parser<std::uint8_t, 16, 1, 1> hex1;
|
||||||
x3::uint_parser<std::uint16_t, 10, 1, 3> dec3;
|
x3::uint_parser<std::uint16_t, 10, 1, 3> dec3;
|
||||||
|
|
||||||
// starting rule
|
|
||||||
css_color_grammar_type const css_color("css_color");
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class hex2_color, color> const hex2_color("hex2_color");
|
x3::rule<class hex2_color, color> const hex2_color("hex2_color");
|
||||||
x3::rule<class hex1_color, color> const hex1_color("hex1_color");
|
x3::rule<class hex1_color, color> const hex1_color("hex1_color");
|
||||||
|
@ -443,12 +441,6 @@ BOOST_SPIRIT_DEFINE(
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
css_color_grammar::css_color_grammar_type const& color_grammar()
|
|
||||||
{
|
|
||||||
return css_color_grammar::css_color;
|
|
||||||
}
|
|
||||||
|
|
||||||
} //ns mapnik
|
} //ns mapnik
|
||||||
|
|
||||||
#endif //MAPNIK_CSS_COLOR_GRAMMAR_X3_DEF_HPP
|
#endif //MAPNIK_CSS_COLOR_GRAMMAR_X3_DEF_HPP
|
||||||
|
|
|
@ -60,6 +60,8 @@ struct quote_tag;
|
||||||
struct csv_line_class;
|
struct csv_line_class;
|
||||||
using csv_line_grammar_type = x3::rule<csv_line_class, csv_line>;
|
using csv_line_grammar_type = x3::rule<csv_line_class, csv_line>;
|
||||||
|
|
||||||
|
csv_line_grammar_type const line = "csv-line";
|
||||||
|
|
||||||
BOOST_SPIRIT_DECLARE(csv_line_grammar_type);
|
BOOST_SPIRIT_DECLARE(csv_line_grammar_type);
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -81,8 +81,6 @@ struct literal : x3::parser<literal<T>>
|
||||||
auto static const separator = literal<separator_tag>{};
|
auto static const separator = literal<separator_tag>{};
|
||||||
auto static const quote = literal<quote_tag>{};
|
auto static const quote = literal<quote_tag>{};
|
||||||
|
|
||||||
// starting rule
|
|
||||||
csv_line_grammar_type const line("csv-line");
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class csv_column, csv_value> column("csv-column");
|
x3::rule<class csv_column, csv_value> column("csv-column");
|
||||||
x3::rule<class csv_text, csv_value> text("csv-text");
|
x3::rule<class csv_text, csv_value> text("csv-text");
|
||||||
|
@ -108,12 +106,6 @@ BOOST_SPIRIT_DEFINE (
|
||||||
);
|
);
|
||||||
|
|
||||||
} // grammar
|
} // grammar
|
||||||
|
|
||||||
grammar::csv_line_grammar_type const& csv_line_grammar()
|
|
||||||
{
|
|
||||||
return grammar::line;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace mapnik
|
} // namespace mapnik
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,15 +44,10 @@ struct transcoder_tag;
|
||||||
struct expression_class; // top-most ID
|
struct expression_class; // top-most ID
|
||||||
using expression_grammar_type = x3::rule<expression_class, expr_node>;
|
using expression_grammar_type = x3::rule<expression_class, expr_node>;
|
||||||
|
|
||||||
|
expression_grammar_type const expression("expression");
|
||||||
|
|
||||||
BOOST_SPIRIT_DECLARE(expression_grammar_type);
|
BOOST_SPIRIT_DECLARE(expression_grammar_type);
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
namespace mapnik
|
|
||||||
{
|
|
||||||
grammar::expression_grammar_type const& expression_grammar();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // MAPNIK_EXPRESSIONS_GRAMMAR_X3_HPP
|
#endif // MAPNIK_EXPRESSIONS_GRAMMAR_X3_HPP
|
||||||
|
|
|
@ -300,8 +300,7 @@ namespace mapnik { namespace grammar {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} unesc_char;
|
} unesc_char;
|
||||||
// starting rule
|
|
||||||
expression_grammar_type const expression("expression");
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class logical_expression, mapnik::expr_node> const logical_expression("logical expression");
|
x3::rule<class logical_expression, mapnik::expr_node> const logical_expression("logical expression");
|
||||||
x3::rule<class not_expression, mapnik::expr_node> const not_expression("not expression");
|
x3::rule<class not_expression, mapnik::expr_node> const not_expression("not expression");
|
||||||
|
@ -451,12 +450,4 @@ namespace mapnik { namespace grammar {
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
namespace mapnik
|
|
||||||
{
|
|
||||||
grammar::expression_grammar_type const& expression_grammar()
|
|
||||||
{
|
|
||||||
return grammar::expression;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // MAPNIK_EXPRESSIONS_GRAMMAR_X3_DEF_HPP
|
#endif // MAPNIK_EXPRESSIONS_GRAMMAR_X3_DEF_HPP
|
||||||
|
|
|
@ -41,15 +41,10 @@ namespace image_filter
|
||||||
struct image_filter_class;
|
struct image_filter_class;
|
||||||
using image_filter_grammar_type = x3::rule<image_filter_class, std::vector<filter::filter_type> >;
|
using image_filter_grammar_type = x3::rule<image_filter_class, std::vector<filter::filter_type> >;
|
||||||
|
|
||||||
BOOST_SPIRIT_DECLARE(image_filter_grammar_type);
|
image_filter_grammar_type const start = "start";
|
||||||
|
|
||||||
|
BOOST_SPIRIT_DECLARE(image_filter_grammar_type);
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
namespace mapnik {
|
|
||||||
|
|
||||||
image_filter::image_filter_grammar_type const& image_filter_grammar();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // MAPNIK_IMAGE_FILTER_GRAMMAR_X3_HPP
|
#endif // MAPNIK_IMAGE_FILTER_GRAMMAR_X3_HPP
|
||||||
|
|
|
@ -108,10 +108,8 @@ auto percent = [](auto & ctx)
|
||||||
x3::uint_parser<unsigned, 10, 1, 3> radius;
|
x3::uint_parser<unsigned, 10, 1, 3> radius;
|
||||||
|
|
||||||
// Import the expression rule
|
// Import the expression rule
|
||||||
namespace { auto const& css_color = color_grammar(); }
|
namespace { using css_color_grammar::css_color; }
|
||||||
|
|
||||||
// starting rule
|
|
||||||
image_filter_grammar_type const start("start");
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class filter_class, filter::filter_type > const filter("filter");
|
x3::rule<class filter_class, filter::filter_type > const filter("filter");
|
||||||
|
|
||||||
|
@ -250,12 +248,6 @@ BOOST_SPIRIT_DEFINE(
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
} // image_filter
|
} // image_filter
|
||||||
|
|
||||||
image_filter::image_filter_grammar_type const& image_filter_grammar()
|
|
||||||
{
|
|
||||||
return image_filter::start;
|
|
||||||
}
|
|
||||||
|
|
||||||
} //ns mapnik
|
} //ns mapnik
|
||||||
|
|
||||||
#endif //MAPNIK_IMAGE_FILTER_GRAMMAR_X3_DEF_HPP
|
#endif //MAPNIK_IMAGE_FILTER_GRAMMAR_X3_DEF_HPP
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
*
|
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
|
||||||
*
|
|
||||||
* Copyright (C) 2017 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_INIT_PRIORITY_HPP
|
|
||||||
#define MAPNIK_INIT_PRIORITY_HPP
|
|
||||||
|
|
||||||
// helper macro for dealing with static variables initialising order fiasco (#3821)
|
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
|
||||||
#define MAPNIK_INIT_PRIORITY(priority) __attribute__((init_priority(priority)))
|
|
||||||
#else
|
|
||||||
#define MAPNIK_INIT_PRIORITY
|
|
||||||
// TODO: anything we can do on windows?
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif //MAPNIK_INIT_PRIORITY_HPP
|
|
|
@ -36,15 +36,12 @@ namespace x3 = boost::spirit::x3;
|
||||||
using feature_grammar_type = x3::rule<class feature_rule_tag>;
|
using feature_grammar_type = x3::rule<class feature_rule_tag>;
|
||||||
using geometry_grammar_type = x3::rule<struct geomerty_rule_tag, mapnik::geometry::geometry<double> >;
|
using geometry_grammar_type = x3::rule<struct geomerty_rule_tag, mapnik::geometry::geometry<double> >;
|
||||||
|
|
||||||
|
feature_grammar_type const feature_rule = "Feature Rule";
|
||||||
|
geometry_grammar_type const geometry_rule = "Geometry Rule";
|
||||||
|
|
||||||
BOOST_SPIRIT_DECLARE(feature_grammar_type);
|
BOOST_SPIRIT_DECLARE(feature_grammar_type);
|
||||||
BOOST_SPIRIT_DECLARE(geometry_grammar_type);
|
BOOST_SPIRIT_DECLARE(geometry_grammar_type);
|
||||||
|
|
||||||
}
|
}}}
|
||||||
|
|
||||||
grammar::feature_grammar_type const& feature_grammar();
|
|
||||||
grammar::geometry_grammar_type const& geometry_grammar();
|
|
||||||
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
||||||
#endif // MAPNIK_JSON_FEATURE_GRAMMAR_X3_HPP
|
#endif // MAPNIK_JSON_FEATURE_GRAMMAR_X3_HPP
|
||||||
|
|
|
@ -141,11 +141,9 @@ using x3::char_;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// import unicode string rule
|
// import unicode string rule
|
||||||
auto const& geojson_string = unicode_string_grammar();
|
auto const& geojson_string = unicode_string;
|
||||||
// import positions rule
|
// import positions rule
|
||||||
auto const& positions_rule = positions_grammar();
|
auto const& positions_rule = positions;
|
||||||
// import generic rule
|
|
||||||
auto const& value = generic_json_grammar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// geometry types symbols
|
// geometry types symbols
|
||||||
|
@ -234,10 +232,6 @@ auto assign_property = [](auto const& ctx)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//exported rules
|
|
||||||
feature_grammar_type const feature_rule = "Feature Rule";
|
|
||||||
geometry_grammar_type const geometry_rule = "Geometry Rule";
|
|
||||||
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<struct feature_type_tag> const feature_type = "Feature Type";
|
x3::rule<struct feature_type_tag> const feature_type = "Feature Type";
|
||||||
x3::rule<struct geometry_type_tag, mapnik::geometry::geometry_types> const geometry_type = "Geometry Type";
|
x3::rule<struct geometry_type_tag, mapnik::geometry::geometry_types> const geometry_type = "Geometry Type";
|
||||||
|
|
|
@ -39,13 +39,13 @@ namespace grammar {
|
||||||
|
|
||||||
using generic_json_grammar_type = x3::rule<class generic_json_tag, json_value>;
|
using generic_json_grammar_type = x3::rule<class generic_json_tag, json_value>;
|
||||||
using generic_json_key_value_type = x3::rule<class json_object_element_tag, json_object_element>;
|
using generic_json_key_value_type = x3::rule<class json_object_element_tag, json_object_element>;
|
||||||
|
|
||||||
|
generic_json_grammar_type const value = "JSON Value";
|
||||||
|
generic_json_key_value_type const key_value = "JSON Object element";
|
||||||
|
|
||||||
BOOST_SPIRIT_DECLARE(generic_json_grammar_type);
|
BOOST_SPIRIT_DECLARE(generic_json_grammar_type);
|
||||||
BOOST_SPIRIT_DECLARE(generic_json_key_value_type);
|
BOOST_SPIRIT_DECLARE(generic_json_key_value_type);
|
||||||
}
|
|
||||||
|
|
||||||
grammar::generic_json_grammar_type const& generic_json_grammar();
|
}}}
|
||||||
grammar::generic_json_key_value_type const& generic_json_key_value();
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
||||||
#endif // MAPNIK_JSON_GENERIC_JSON_GRAMMAR_X3_HPP
|
#endif // MAPNIK_JSON_GENERIC_JSON_GRAMMAR_X3_HPP
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include <boost/fusion/include/std_pair.hpp>
|
#include <boost/fusion/include/std_pair.hpp>
|
||||||
#include <mapnik/json/generic_json_grammar_x3.hpp>
|
#include <mapnik/json/generic_json_grammar_x3.hpp>
|
||||||
#include <mapnik/json/unicode_string_grammar_x3.hpp>
|
#include <mapnik/json/unicode_string_grammar_x3.hpp>
|
||||||
#include <mapnik/init_priority.hpp>
|
|
||||||
|
|
||||||
namespace mapnik { namespace json { namespace grammar {
|
namespace mapnik { namespace json { namespace grammar {
|
||||||
|
|
||||||
|
@ -70,12 +69,8 @@ using x3::lit;
|
||||||
using x3::string;
|
using x3::string;
|
||||||
|
|
||||||
// import unicode string rule
|
// import unicode string rule
|
||||||
namespace { auto const& json_string = mapnik::json::unicode_string_grammar(); }
|
namespace { auto const& json_string = mapnik::json::grammar::unicode_string; }
|
||||||
|
|
||||||
// exported rules
|
|
||||||
// start
|
|
||||||
generic_json_grammar_type const value MAPNIK_INIT_PRIORITY(102) ("JSON Value");
|
|
||||||
generic_json_key_value_type const key_value("JSON Object element");
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class json_object_tag, json_object> const object("JSON Object");
|
x3::rule<class json_object_tag, json_object> const object("JSON Object");
|
||||||
x3::rule<class json_array_tag, json_array> const array("JSON Array");
|
x3::rule<class json_array_tag, json_array> const array("JSON Array");
|
||||||
|
|
|
@ -71,13 +71,13 @@ struct geojson_value : geojson_value_base
|
||||||
namespace grammar {
|
namespace grammar {
|
||||||
|
|
||||||
using geojson_grammar_type = x3::rule<class geojson_tag, geojson_value>;
|
using geojson_grammar_type = x3::rule<class geojson_tag, geojson_value>;
|
||||||
using key_value_type = x3::rule<class key_value_tag, geojson_object_element>;
|
using geojson_key_value_type = x3::rule<class geojson_key_value_type_tag, geojson_object_element>;
|
||||||
BOOST_SPIRIT_DECLARE(geojson_grammar_type, key_value_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
grammar::geojson_grammar_type const& geojson_grammar();
|
geojson_grammar_type const geojson_value = "GeoJSON Value";
|
||||||
grammar::key_value_type const& key_value_grammar();
|
geojson_key_value_type const geojson_key_value = "GeoJSON Key/Value Type";
|
||||||
|
|
||||||
}}
|
BOOST_SPIRIT_DECLARE(geojson_grammar_type, geojson_key_value_type);
|
||||||
|
|
||||||
|
}}}
|
||||||
|
|
||||||
#endif // MAPNIK_JSON_GEOJSON_GRAMMAR_X3_HPP
|
#endif // MAPNIK_JSON_GEOJSON_GRAMMAR_X3_HPP
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include <mapnik/json/geojson_grammar_x3.hpp>
|
#include <mapnik/json/geojson_grammar_x3.hpp>
|
||||||
#include <mapnik/json/unicode_string_grammar_x3.hpp>
|
#include <mapnik/json/unicode_string_grammar_x3.hpp>
|
||||||
#include <mapnik/json/positions_grammar_x3.hpp>
|
#include <mapnik/json/positions_grammar_x3.hpp>
|
||||||
#include <mapnik/init_priority.hpp>
|
|
||||||
|
|
||||||
#include <boost/fusion/include/std_pair.hpp>
|
#include <boost/fusion/include/std_pair.hpp>
|
||||||
|
|
||||||
|
@ -88,40 +87,35 @@ struct geometry_type_ : x3::symbols<mapnik::geometry::geometry_types>
|
||||||
}
|
}
|
||||||
} geometry_type_sym;
|
} geometry_type_sym;
|
||||||
|
|
||||||
// exported rules
|
|
||||||
// start
|
|
||||||
geojson_grammar_type const value MAPNIK_INIT_PRIORITY(106) ("JSON Value");
|
|
||||||
key_value_type const key_value MAPNIK_INIT_PRIORITY(107) ("JSON key/value");
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class json_object_tag, geojson_object> const object("JSON Object");
|
x3::rule<class json_object_tag, geojson_object> const object("JSON Object");
|
||||||
x3::rule<class json_array_tag, geojson_array> const array("JSON Array");
|
x3::rule<class json_array_tag, geojson_array> const array("JSON Array");
|
||||||
x3::rule<class json_number_tag, geojson_value> const number("JSON Number");
|
x3::rule<class json_number_tag, json::geojson_value> const number("JSON Number");
|
||||||
//x3::rule<class key_value_tag, geojson_object_element> key_value("JSON key/value");
|
x3::rule<class key_value_tag, geojson_object_element> key_value("JSON key/value");
|
||||||
// GeoJSON
|
// GeoJSON
|
||||||
x3::rule<class geojson_coordinates_tag, geojson_object_element> const coordinates("GeoJSON Coordinates");
|
x3::rule<class geojson_coordinates_tag, geojson_object_element> const coordinates("GeoJSON Coordinates");
|
||||||
x3::rule<class geojson_geometry_type_tag, geojson_object_element> const geometry_type("GeoJSON Geometry Type");
|
x3::rule<class geojson_geometry_type_tag, geojson_object_element> const geometry_type("GeoJSON Geometry Type");
|
||||||
x3::rule<class geojson_key_value_type_tag, geojson_object_element> const geojson_key_value("GeoJSON Key/Value Type");
|
|
||||||
auto const geojson_double = x3::real_parser<value_double, x3::strict_real_policies<value_double>>();
|
auto const geojson_double = x3::real_parser<value_double, x3::strict_real_policies<value_double>>();
|
||||||
auto const geojson_integer = x3::int_parser<value_integer, 10, 1, -1>();
|
auto const geojson_integer = x3::int_parser<value_integer, 10, 1, -1>();
|
||||||
|
|
||||||
// import unicode string rule
|
// import unicode string rule
|
||||||
namespace { auto const& geojson_string = mapnik::json::unicode_string_grammar(); }
|
namespace { auto const& geojson_string = unicode_string; }
|
||||||
// import positions rule
|
// import positions rule
|
||||||
namespace { auto const& positions_rule = mapnik::json::positions_grammar(); }
|
namespace { auto const& positions_rule = positions; }
|
||||||
|
|
||||||
// GeoJSON types
|
// GeoJSON types
|
||||||
auto const value_def = object | array | geojson_string | number
|
auto const geojson_value_def = object | array | geojson_string | number
|
||||||
;
|
;
|
||||||
|
|
||||||
auto const coordinates_def = lexeme[lit('"') >> (string("coordinates") > lit('"'))][assign_key]
|
auto const coordinates_def = lexeme[lit('"') >> (string("coordinates") > lit('"'))][assign_key]
|
||||||
> lit(':') > (positions_rule[assign_value] | value[assign_value])
|
> lit(':') > (positions_rule[assign_value] | geojson_value[assign_value])
|
||||||
;
|
;
|
||||||
|
|
||||||
auto const geometry_type_def = lexeme[lit('"') >> (string("type") > lit('"'))][assign_key]
|
auto const geometry_type_def = lexeme[lit('"') >> (string("type") > lit('"'))][assign_key]
|
||||||
> lit(':') > (geometry_type_sym[assign_value] | value[assign_value])
|
> lit(':') > (geometry_type_sym[assign_value] | geojson_value[assign_value])
|
||||||
;
|
;
|
||||||
|
|
||||||
auto const key_value_def = geojson_string[assign_key] > lit(':') > value[assign_value]
|
auto const key_value_def = geojson_string[assign_key] > lit(':') > geojson_value[assign_value]
|
||||||
;
|
;
|
||||||
|
|
||||||
auto const geojson_key_value_def =
|
auto const geojson_key_value_def =
|
||||||
|
@ -138,7 +132,7 @@ auto const object_def = lit('{')
|
||||||
;
|
;
|
||||||
|
|
||||||
auto const array_def = lit('[')
|
auto const array_def = lit('[')
|
||||||
> -(value % lit(','))
|
> -(geojson_value % lit(','))
|
||||||
> lit(']')
|
> lit(']')
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -153,7 +147,7 @@ auto const number_def = geojson_double[assign]
|
||||||
#include <mapnik/warning_ignore.hpp>
|
#include <mapnik/warning_ignore.hpp>
|
||||||
|
|
||||||
BOOST_SPIRIT_DEFINE(
|
BOOST_SPIRIT_DEFINE(
|
||||||
value,
|
geojson_value,
|
||||||
geometry_type,
|
geometry_type,
|
||||||
coordinates,
|
coordinates,
|
||||||
object,
|
object,
|
||||||
|
|
|
@ -39,12 +39,10 @@ namespace grammar {
|
||||||
namespace x3 = boost::spirit::x3;
|
namespace x3 = boost::spirit::x3;
|
||||||
using positions_grammar_type = x3::rule<class positions_tag, positions>;
|
using positions_grammar_type = x3::rule<class positions_tag, positions>;
|
||||||
|
|
||||||
|
positions_grammar_type const positions = "Positions";
|
||||||
|
|
||||||
BOOST_SPIRIT_DECLARE(positions_grammar_type);
|
BOOST_SPIRIT_DECLARE(positions_grammar_type);
|
||||||
|
|
||||||
}
|
}}}
|
||||||
|
|
||||||
grammar::positions_grammar_type const& positions_grammar();
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
||||||
#endif // MAPNIK_JSON_POSITIONS_GRAMMAR_X3_HPP
|
#endif // MAPNIK_JSON_POSITIONS_GRAMMAR_X3_HPP
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
#include <mapnik/json/positions_grammar_x3.hpp>
|
#include <mapnik/json/positions_grammar_x3.hpp>
|
||||||
#include <mapnik/geometry/fusion_adapted.hpp>
|
#include <mapnik/geometry/fusion_adapted.hpp>
|
||||||
#include <mapnik/init_priority.hpp>
|
|
||||||
|
|
||||||
namespace mapnik { namespace json { namespace grammar {
|
namespace mapnik { namespace json { namespace grammar {
|
||||||
|
|
||||||
|
@ -42,8 +41,6 @@ auto assign_helper = [](auto const& ctx)
|
||||||
};
|
};
|
||||||
} // anonymous ns
|
} // anonymous ns
|
||||||
|
|
||||||
// start rule
|
|
||||||
positions_grammar_type const positions MAPNIK_INIT_PRIORITY(103) ("Positions");
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class point_class, point> const point("Position");
|
x3::rule<class point_class, point> const point("Position");
|
||||||
x3::rule<class ring_class, ring> const ring("Ring");
|
x3::rule<class ring_class, ring> const ring("Ring");
|
||||||
|
|
|
@ -37,12 +37,10 @@ namespace x3 = boost::spirit::x3;
|
||||||
|
|
||||||
using topojson_grammar_type = x3::rule<class topojson_rule_tag, topojson::topology>;
|
using topojson_grammar_type = x3::rule<class topojson_rule_tag, topojson::topology>;
|
||||||
|
|
||||||
|
topojson_grammar_type const topology = "Topology";
|
||||||
|
|
||||||
BOOST_SPIRIT_DECLARE(topojson_grammar_type);
|
BOOST_SPIRIT_DECLARE(topojson_grammar_type);
|
||||||
|
|
||||||
}
|
}}}
|
||||||
|
|
||||||
grammar::topojson_grammar_type const& topojson_grammar();
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
||||||
#endif //MAPNIK_TOPOJSON_GRAMMAR_X3_HPP
|
#endif //MAPNIK_TOPOJSON_GRAMMAR_X3_HPP
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include <mapnik/json/unicode_string_grammar_x3.hpp>
|
#include <mapnik/json/unicode_string_grammar_x3.hpp>
|
||||||
#include <mapnik/json/generic_json_grammar_x3.hpp>
|
#include <mapnik/json/generic_json_grammar_x3.hpp>
|
||||||
#include <mapnik/json/topojson_grammar_x3.hpp>
|
#include <mapnik/json/topojson_grammar_x3.hpp>
|
||||||
#include <mapnik/init_priority.hpp>
|
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#include <mapnik/warning_ignore.hpp>
|
#include <mapnik/warning_ignore.hpp>
|
||||||
|
@ -280,9 +279,9 @@ using x3::omit;
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
// import unicode string rule
|
// import unicode string rule
|
||||||
auto const& json_string = json::unicode_string_grammar();
|
auto const& json_string = json::grammar::unicode_string;
|
||||||
// json value
|
// json value
|
||||||
auto const& json_value = json::generic_json_grammar();
|
auto const& json_value = json::grammar::value;
|
||||||
}
|
}
|
||||||
|
|
||||||
using coordinates_type = util::variant<topojson::coordinate,std::vector<topojson::coordinate>>;
|
using coordinates_type = util::variant<topojson::coordinate,std::vector<topojson::coordinate>>;
|
||||||
|
@ -305,8 +304,6 @@ struct topojson_geometry_type_ : x3::symbols<int>
|
||||||
}
|
}
|
||||||
} topojson_geometry_type;
|
} topojson_geometry_type;
|
||||||
|
|
||||||
// start rule
|
|
||||||
topojson_grammar_type const topology MAPNIK_INIT_PRIORITY(104) ("Topology");
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class transform_tag, mapnik::topojson::transform> const transform = "Transform";
|
x3::rule<class transform_tag, mapnik::topojson::transform> const transform = "Transform";
|
||||||
x3::rule<class bbox_tag, mapnik::topojson::bounding_box> const bbox = "Bounding Box";
|
x3::rule<class bbox_tag, mapnik::topojson::bounding_box> const bbox = "Bounding Box";
|
||||||
|
|
|
@ -34,12 +34,10 @@ namespace mapnik { namespace json { namespace grammar {
|
||||||
namespace x3 = boost::spirit::x3;
|
namespace x3 = boost::spirit::x3;
|
||||||
using unicode_string_grammar_type = x3::rule<class unicode_string_tag, std::string>;
|
using unicode_string_grammar_type = x3::rule<class unicode_string_tag, std::string>;
|
||||||
|
|
||||||
|
unicode_string_grammar_type const unicode_string = "Unicode String";
|
||||||
|
|
||||||
BOOST_SPIRIT_DECLARE(unicode_string_grammar_type);
|
BOOST_SPIRIT_DECLARE(unicode_string_grammar_type);
|
||||||
|
|
||||||
}
|
}}}
|
||||||
|
|
||||||
grammar::unicode_string_grammar_type const& unicode_string_grammar();
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
||||||
#endif // MAPNIK_JSON_UNICODE_STRING_GRAMMAR_X3_HPP
|
#endif // MAPNIK_JSON_UNICODE_STRING_GRAMMAR_X3_HPP
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#define MAPNIK_JSON_UNICODE_STRING_GRAMMAR_X3_DEF_HPP
|
#define MAPNIK_JSON_UNICODE_STRING_GRAMMAR_X3_DEF_HPP
|
||||||
|
|
||||||
#include <mapnik/json/unicode_string_grammar_x3.hpp>
|
#include <mapnik/json/unicode_string_grammar_x3.hpp>
|
||||||
#include <mapnik/init_priority.hpp>
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/regex/pending/unicode_iterator.hpp>
|
#include <boost/regex/pending/unicode_iterator.hpp>
|
||||||
//
|
//
|
||||||
|
@ -109,8 +108,6 @@ x3::uint_parser<std::uint8_t, 16, 2, 2> const hex2 {};
|
||||||
x3::uint_parser<std::uint16_t, 16, 4, 4> const hex4 {};
|
x3::uint_parser<std::uint16_t, 16, 4, 4> const hex4 {};
|
||||||
x3::uint_parser<uchar, 16, 8, 8> const hex8 {};
|
x3::uint_parser<uchar, 16, 8, 8> const hex8 {};
|
||||||
|
|
||||||
// start rule
|
|
||||||
unicode_string_grammar_type const unicode_string MAPNIK_INIT_PRIORITY(101) ("Unicode String");
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class double_quoted_tag, std::string> const double_quoted("Double-quoted string");
|
x3::rule<class double_quoted_tag, std::string> const double_quoted("Double-quoted string");
|
||||||
x3::rule<class escaped_tag, std::string> const escaped("Escaped Character");
|
x3::rule<class escaped_tag, std::string> const escaped("Escaped Character");
|
||||||
|
|
|
@ -37,12 +37,10 @@ namespace x3 = boost::spirit::x3;
|
||||||
struct path_expression_class; // top-most ID
|
struct path_expression_class; // top-most ID
|
||||||
using path_expression_grammar_type = x3::rule<path_expression_class, path_expression>;
|
using path_expression_grammar_type = x3::rule<path_expression_class, path_expression>;
|
||||||
|
|
||||||
|
path_expression_grammar_type const path_expression = "path_expression";
|
||||||
|
|
||||||
BOOST_SPIRIT_DECLARE(path_expression_grammar_type);
|
BOOST_SPIRIT_DECLARE(path_expression_grammar_type);
|
||||||
|
|
||||||
}
|
}}
|
||||||
|
|
||||||
grammar::path_expression_grammar_type const& path_expression_grammar();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // MAPNIK_PATH_EXPRESSIONS_GRAMMAR_X3_HPP
|
#endif // MAPNIK_PATH_EXPRESSIONS_GRAMMAR_X3_HPP
|
||||||
|
|
|
@ -33,8 +33,6 @@ using x3::standard_wide::char_;
|
||||||
using x3::lexeme;
|
using x3::lexeme;
|
||||||
auto create_string = [](auto & ctx) { _val(ctx).push_back(_attr(ctx)); };
|
auto create_string = [](auto & ctx) { _val(ctx).push_back(_attr(ctx)); };
|
||||||
auto create_attribute = [](auto & ctx) { _val(ctx).push_back(mapnik::attribute(_attr(ctx))); };
|
auto create_attribute = [](auto & ctx) { _val(ctx).push_back(mapnik::attribute(_attr(ctx))); };
|
||||||
// top-most rule
|
|
||||||
path_expression_grammar_type const path_expression("path_expression");
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class attr_expression, std::string> const attr_expression("attribute");
|
x3::rule<class attr_expression, std::string> const attr_expression("attribute");
|
||||||
x3::rule<class str_expression, std::string> const str_expression("string");
|
x3::rule<class str_expression, std::string> const str_expression("string");
|
||||||
|
@ -51,13 +49,4 @@ BOOST_SPIRIT_DEFINE(
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
namespace mapnik {
|
|
||||||
|
|
||||||
grammar::path_expression_grammar_type const& path_expression_grammar()
|
|
||||||
{
|
|
||||||
return grammar::path_expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //MAPNIK_PATH_EXPRESSIONS_GRAMMAR_X3_DEF_HPP
|
#endif //MAPNIK_PATH_EXPRESSIONS_GRAMMAR_X3_DEF_HPP
|
||||||
|
|
|
@ -32,15 +32,12 @@ namespace x3 = boost::spirit::x3;
|
||||||
using svg_path_grammar_type = x3::rule<class svg_path_rule_tag>;
|
using svg_path_grammar_type = x3::rule<class svg_path_rule_tag>;
|
||||||
using svg_points_grammar_type = x3::rule<class svg_points_rule_tag>;
|
using svg_points_grammar_type = x3::rule<class svg_points_rule_tag>;
|
||||||
|
|
||||||
|
svg_path_grammar_type const svg_path = "SVG Path";
|
||||||
|
svg_points_grammar_type const svg_points = "SVG_Points";
|
||||||
|
|
||||||
BOOST_SPIRIT_DECLARE(svg_path_grammar_type,
|
BOOST_SPIRIT_DECLARE(svg_path_grammar_type,
|
||||||
svg_points_grammar_type);
|
svg_points_grammar_type);
|
||||||
|
|
||||||
}
|
}}}
|
||||||
|
|
||||||
grammar::svg_path_grammar_type const& svg_path_grammar();
|
|
||||||
|
|
||||||
grammar::svg_points_grammar_type const& svg_points_grammar();
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
||||||
#endif // MAPNIK_SVG_PATH_GRAMMAR_X3_HPP
|
#endif // MAPNIK_SVG_PATH_GRAMMAR_X3_HPP
|
||||||
|
|
|
@ -146,10 +146,6 @@ auto const absolute = [] (auto const& ctx)
|
||||||
extract_relative(ctx) = false;
|
extract_relative(ctx) = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// exported rules
|
|
||||||
svg_path_grammar_type const svg_path = "SVG Path";
|
|
||||||
svg_points_grammar_type const svg_points = "SVG_Points";
|
|
||||||
|
|
||||||
// rules
|
// rules
|
||||||
auto const coord = x3::rule<class coord_tag, coord_type>{} = double_ > -lit(',') > double_;
|
auto const coord = x3::rule<class coord_tag, coord_type>{} = double_ > -lit(',') > double_;
|
||||||
|
|
||||||
|
@ -200,18 +196,6 @@ BOOST_SPIRIT_DEFINE(
|
||||||
);
|
);
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
}
|
}}}
|
||||||
|
|
||||||
grammar::svg_path_grammar_type const& svg_path_grammar()
|
|
||||||
{
|
|
||||||
return grammar::svg_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
grammar::svg_points_grammar_type const& svg_points_grammar()
|
|
||||||
{
|
|
||||||
return grammar::svg_points;
|
|
||||||
}
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
||||||
#endif // MAPNIK_SVG_PATH_GRAMMAR_X3_HPP
|
#endif // MAPNIK_SVG_PATH_GRAMMAR_X3_HPP
|
||||||
|
|
|
@ -32,12 +32,10 @@ using namespace boost::spirit::x3;
|
||||||
|
|
||||||
using svg_transform_grammar_type = x3::rule<class svg_transform_rule_tag>;
|
using svg_transform_grammar_type = x3::rule<class svg_transform_rule_tag>;
|
||||||
|
|
||||||
|
svg_transform_grammar_type const svg_transform = "SVG Transform";
|
||||||
|
|
||||||
BOOST_SPIRIT_DECLARE(svg_transform_grammar_type);
|
BOOST_SPIRIT_DECLARE(svg_transform_grammar_type);
|
||||||
|
|
||||||
}
|
}}}
|
||||||
|
|
||||||
grammar::svg_transform_grammar_type const& svg_transform_grammar();
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
||||||
#endif // MAPNIK_SVG_TRANSFORM_GRAMMAR_X3_HPP
|
#endif // MAPNIK_SVG_TRANSFORM_GRAMMAR_X3_HPP
|
||||||
|
|
|
@ -118,8 +118,6 @@ auto const skewY_action = [] (auto const& ctx)
|
||||||
tr = agg::trans_affine_skewing(0.0, agg::deg2rad(skew_y)) * tr;
|
tr = agg::trans_affine_skewing(0.0, agg::deg2rad(skew_y)) * tr;
|
||||||
};
|
};
|
||||||
|
|
||||||
//exported rule
|
|
||||||
svg_transform_grammar_type const svg_transform = "SVG Transform";
|
|
||||||
// rules
|
// rules
|
||||||
auto const matrix = x3::rule<class matrix_tag> {} = no_case[lit("matrix")]
|
auto const matrix = x3::rule<class matrix_tag> {} = no_case[lit("matrix")]
|
||||||
> lit('(') > (double_ > -lit(',')
|
> lit('(') > (double_ > -lit(',')
|
||||||
|
@ -157,14 +155,6 @@ BOOST_SPIRIT_DEFINE(
|
||||||
);
|
);
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
}
|
}}}
|
||||||
|
|
||||||
grammar::svg_transform_grammar_type const& svg_transform_grammar()
|
|
||||||
{
|
|
||||||
return grammar::svg_transform;
|
|
||||||
}
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // MAPNIK_SVG_TRANSFORM_GRAMMAR_X3_HPP
|
#endif // MAPNIK_SVG_TRANSFORM_GRAMMAR_X3_HPP
|
||||||
|
|
|
@ -39,13 +39,10 @@ namespace grammar {
|
||||||
struct transform_expression_class; // top-most ID
|
struct transform_expression_class; // top-most ID
|
||||||
using transform_expression_grammar_type = x3::rule<transform_expression_class, mapnik::transform_list>;
|
using transform_expression_grammar_type = x3::rule<transform_expression_class, mapnik::transform_list>;
|
||||||
|
|
||||||
|
transform_expression_grammar_type const transform("transform");
|
||||||
|
|
||||||
BOOST_SPIRIT_DECLARE(transform_expression_grammar_type);
|
BOOST_SPIRIT_DECLARE(transform_expression_grammar_type);
|
||||||
|
|
||||||
}} // ns
|
}} // ns
|
||||||
|
|
||||||
namespace mapnik
|
|
||||||
{
|
|
||||||
grammar::transform_expression_grammar_type const& transform_expression_grammar();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -127,8 +127,6 @@ auto const construct_rotate = [](auto const& ctx)
|
||||||
_val(ctx) = mapnik::rotate_node(a, sx, sy);
|
_val(ctx) = mapnik::rotate_node(a, sx, sy);
|
||||||
};
|
};
|
||||||
|
|
||||||
// starting rule
|
|
||||||
transform_expression_grammar_type const transform("transform");
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class transform_list_class, mapnik::transform_list> transform_list_rule("transform list");
|
x3::rule<class transform_list_class, mapnik::transform_list> transform_list_rule("transform list");
|
||||||
x3::rule<class transform_node_class, mapnik::transform_node> transform_node_rule("transform node");
|
x3::rule<class transform_node_class, mapnik::transform_node> transform_node_rule("transform node");
|
||||||
|
@ -155,7 +153,7 @@ auto const atom = x3::rule<class atom_tag, expr_node> {} = double_[create_expr_n
|
||||||
auto const sep_atom = x3::rule<class sep_atom_tag, expr_node> {} = -lit(',') >> double_[create_expr_node]
|
auto const sep_atom = x3::rule<class sep_atom_tag, expr_node> {} = -lit(',') >> double_[create_expr_node]
|
||||||
;
|
;
|
||||||
|
|
||||||
auto const expr_def = expression_grammar();
|
auto const expr_def = expression;
|
||||||
// Individual arguments in lists containing one or more compound
|
// Individual arguments in lists containing one or more compound
|
||||||
// expressions are separated by a comma.
|
// expressions are separated by a comma.
|
||||||
auto const sep_expr_def = lit(',') > expr
|
auto const sep_expr_def = lit(',') > expr
|
||||||
|
@ -212,12 +210,4 @@ BOOST_SPIRIT_DEFINE (
|
||||||
|
|
||||||
}} // ns
|
}} // ns
|
||||||
|
|
||||||
namespace mapnik
|
|
||||||
{
|
|
||||||
grammar::transform_expression_grammar_type const& transform_expression_grammar()
|
|
||||||
{
|
|
||||||
return grammar::transform;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,14 +36,11 @@ namespace x3 = boost::spirit::x3;
|
||||||
struct wkt_class; // top-most ID
|
struct wkt_class; // top-most ID
|
||||||
using wkt_grammar_type = x3::rule<wkt_class, mapnik::geometry::geometry<double>>;
|
using wkt_grammar_type = x3::rule<wkt_class, mapnik::geometry::geometry<double>>;
|
||||||
|
|
||||||
|
wkt_grammar_type const wkt("wkt");
|
||||||
|
|
||||||
BOOST_SPIRIT_DECLARE(wkt_grammar_type);
|
BOOST_SPIRIT_DECLARE(wkt_grammar_type);
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
namespace mapnik
|
|
||||||
{
|
|
||||||
grammar::wkt_grammar_type const& wkt_grammar();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // MAPNIK_WKT_GRAMMAR_X3_HPP
|
#endif // MAPNIK_WKT_GRAMMAR_X3_HPP
|
||||||
|
|
|
@ -57,8 +57,6 @@ auto add_ring = [](auto const& ctx)
|
||||||
_val(ctx).push_back(std::move(ring));
|
_val(ctx).push_back(std::move(ring));
|
||||||
};
|
};
|
||||||
|
|
||||||
// start rule
|
|
||||||
wkt_grammar_type const wkt("wkt");
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class empty, mapnik::geometry::geometry_empty> const empty("EMPTY");
|
x3::rule<class empty, mapnik::geometry::geometry_empty> const empty("EMPTY");
|
||||||
x3::rule<class point, mapnik::geometry::geometry<double> > const point("POINT");
|
x3::rule<class point, mapnik::geometry::geometry<double> > const point("POINT");
|
||||||
|
@ -126,12 +124,4 @@ BOOST_SPIRIT_DEFINE(
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
namespace mapnik
|
|
||||||
{
|
|
||||||
grammar::wkt_grammar_type const& wkt_grammar()
|
|
||||||
{
|
|
||||||
return grammar::wkt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // MAPNIK_WKT_GRAMMAR_X3_DEF_HPP
|
#endif // MAPNIK_WKT_GRAMMAR_X3_DEF_HPP
|
||||||
|
|
|
@ -197,7 +197,7 @@ mapnik::csv_line parse_line(char const* start, char const* end, char separator,
|
||||||
namespace x3 = boost::spirit::x3;
|
namespace x3 = boost::spirit::x3;
|
||||||
auto parser = x3::with<mapnik::grammar::quote_tag>(quote)
|
auto parser = x3::with<mapnik::grammar::quote_tag>(quote)
|
||||||
[ x3::with<mapnik::grammar::separator_tag>(separator)
|
[ x3::with<mapnik::grammar::separator_tag>(separator)
|
||||||
[ mapnik::csv_line_grammar()]
|
[ mapnik::grammar::line ]
|
||||||
];
|
];
|
||||||
|
|
||||||
mapnik::csv_line values;
|
mapnik::csv_line values;
|
||||||
|
|
|
@ -184,7 +184,7 @@ void topojson_datasource::parse_topojson(T const& buffer)
|
||||||
using space_type = boost::spirit::x3::standard::space_type;
|
using space_type = boost::spirit::x3::standard::space_type;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boost::spirit::x3::phrase_parse(itr, end, mapnik::json::topojson_grammar(), space_type(), topo_);
|
boost::spirit::x3::phrase_parse(itr, end, mapnik::json::grammar::topology, space_type(), topo_);
|
||||||
}
|
}
|
||||||
catch (boost::spirit::x3::expectation_failure<char const*> const& ex)
|
catch (boost::spirit::x3::expectation_failure<char const*> const& ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace mapnik {
|
||||||
color parse_color(std::string const& str)
|
color parse_color(std::string const& str)
|
||||||
{
|
{
|
||||||
// TODO - early return for @color?
|
// TODO - early return for @color?
|
||||||
auto const& grammar = mapnik::color_grammar();
|
auto const& grammar = mapnik::css_color_grammar::css_color;
|
||||||
color c;
|
color c;
|
||||||
std::string::const_iterator first = str.begin();
|
std::string::const_iterator first = str.begin();
|
||||||
std::string::const_iterator last = str.end();
|
std::string::const_iterator last = str.end();
|
||||||
|
|
|
@ -38,12 +38,12 @@ expression_ptr parse_expression(std::string const& str)
|
||||||
#if BOOST_VERSION >=106700
|
#if BOOST_VERSION >=106700
|
||||||
auto parser = boost::spirit::x3::with<mapnik::grammar::transcoder_tag>(tr)
|
auto parser = boost::spirit::x3::with<mapnik::grammar::transcoder_tag>(tr)
|
||||||
[
|
[
|
||||||
mapnik::expression_grammar()
|
mapnik::grammar::expression
|
||||||
];
|
];
|
||||||
#else
|
#else
|
||||||
auto parser = boost::spirit::x3::with<mapnik::grammar::transcoder_tag>(std::ref(tr))
|
auto parser = boost::spirit::x3::with<mapnik::grammar::transcoder_tag>(std::ref(tr))
|
||||||
[
|
[
|
||||||
mapnik::expression_grammar()
|
mapnik::grammar::expression
|
||||||
];
|
];
|
||||||
#endif
|
#endif
|
||||||
bool r = false;
|
bool r = false;
|
||||||
|
|
|
@ -92,11 +92,10 @@ auto on_feature_callback = [] (auto const& ctx)
|
||||||
x3::get<feature_callback_tag>(ctx)(_attr(ctx));
|
x3::get<feature_callback_tag>(ctx)(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace { auto const& geojson_value = geojson_grammar();}
|
|
||||||
// import unicode string rule
|
// import unicode string rule
|
||||||
namespace { auto const& geojson_string = unicode_string_grammar(); }
|
namespace { auto const& geojson_string = unicode_string; }
|
||||||
// import positions rule
|
// import positions rule
|
||||||
namespace { auto const& positions_rule = positions_grammar(); }
|
namespace { auto const& positions_rule = positions; }
|
||||||
|
|
||||||
// extract bounding box from GeoJSON Feature
|
// extract bounding box from GeoJSON Feature
|
||||||
|
|
||||||
|
|
|
@ -29,16 +29,4 @@ BOOST_SPIRIT_INSTANTIATE(feature_grammar_type, iterator_type, feature_context_ty
|
||||||
BOOST_SPIRIT_INSTANTIATE(geometry_grammar_type, iterator_type, phrase_parse_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_const_type);
|
BOOST_SPIRIT_INSTANTIATE_UNUSED(feature_grammar_type, iterator_type, feature_context_const_type);
|
||||||
|
|
||||||
}
|
}}}
|
||||||
|
|
||||||
grammar::feature_grammar_type const& feature_grammar()
|
|
||||||
{
|
|
||||||
return grammar::feature_rule;
|
|
||||||
}
|
|
||||||
|
|
||||||
grammar::geometry_grammar_type const& geometry_grammar()
|
|
||||||
{
|
|
||||||
return grammar::geometry_rule;
|
|
||||||
}
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
|
@ -34,15 +34,4 @@ BOOST_SPIRIT_INSTANTIATE_UNUSED(generic_json_grammar_type, iterator_type, phrase
|
||||||
BOOST_SPIRIT_INSTANTIATE_UNUSED(generic_json_grammar_type, iterator_type, feature_context_type);
|
BOOST_SPIRIT_INSTANTIATE_UNUSED(generic_json_grammar_type, iterator_type, feature_context_type);
|
||||||
BOOST_SPIRIT_INSTANTIATE_UNUSED(generic_json_grammar_type, iterator_type, feature_context_const_type);
|
BOOST_SPIRIT_INSTANTIATE_UNUSED(generic_json_grammar_type, iterator_type, feature_context_const_type);
|
||||||
|
|
||||||
}
|
}}}
|
||||||
|
|
||||||
grammar::generic_json_grammar_type const& generic_json_grammar()
|
|
||||||
{
|
|
||||||
return grammar::value;
|
|
||||||
}
|
|
||||||
grammar::generic_json_key_value_type const& generic_json_key_value()
|
|
||||||
{
|
|
||||||
return grammar::key_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
namespace mapnik { namespace json { namespace grammar {
|
namespace mapnik { namespace json { namespace grammar {
|
||||||
|
|
||||||
BOOST_SPIRIT_INSTANTIATE(geojson_grammar_type, iterator_type, context_type);
|
BOOST_SPIRIT_INSTANTIATE(geojson_grammar_type, iterator_type, context_type);
|
||||||
BOOST_SPIRIT_INSTANTIATE(key_value_type, iterator_type, context_type);
|
BOOST_SPIRIT_INSTANTIATE(geojson_key_value_type, iterator_type, context_type);
|
||||||
|
|
||||||
BOOST_SPIRIT_INSTANTIATE(geojson_grammar_type, iterator_type, extract_bounding_boxes_context_type);
|
BOOST_SPIRIT_INSTANTIATE(geojson_grammar_type, iterator_type, extract_bounding_boxes_context_type);
|
||||||
|
|
||||||
|
@ -38,16 +38,4 @@ BOOST_SPIRIT_INSTANTIATE_UNUSED(geojson_grammar_type, iterator_type, extract_bou
|
||||||
BOOST_SPIRIT_INSTANTIATE_UNUSED(geojson_grammar_type, iterator_type, extract_bounding_boxes_context_type_f);
|
BOOST_SPIRIT_INSTANTIATE_UNUSED(geojson_grammar_type, iterator_type, extract_bounding_boxes_context_type_f);
|
||||||
BOOST_SPIRIT_INSTANTIATE_UNUSED(geojson_grammar_type, iterator_type, extract_bounding_boxes_reverse_context_type_f);
|
BOOST_SPIRIT_INSTANTIATE_UNUSED(geojson_grammar_type, iterator_type, extract_bounding_boxes_reverse_context_type_f);
|
||||||
|
|
||||||
}
|
}}}
|
||||||
|
|
||||||
grammar::geojson_grammar_type const& geojson_grammar()
|
|
||||||
{
|
|
||||||
return grammar::value;
|
|
||||||
}
|
|
||||||
|
|
||||||
grammar::key_value_type const& key_value_grammar()
|
|
||||||
{
|
|
||||||
return grammar::key_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ bool from_geojson(std::string const& json, mapnik::geometry::geometry<double> &
|
||||||
{
|
{
|
||||||
namespace x3 = boost::spirit::x3;
|
namespace x3 = boost::spirit::x3;
|
||||||
using space_type = mapnik::json::grammar::space_type;
|
using space_type = mapnik::json::grammar::space_type;
|
||||||
auto grammar = mapnik::json::geometry_grammar();
|
auto grammar = mapnik::json::grammar::geometry_rule;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const char* start = json.c_str();
|
const char* start = json.c_str();
|
||||||
|
|
|
@ -34,11 +34,11 @@ void parse_feature(Iterator start, Iterator end, feature_impl& feature, mapnik::
|
||||||
#if BOOST_VERSION >= 106700
|
#if BOOST_VERSION >= 106700
|
||||||
auto grammar = x3::with<mapnik::json::grammar::transcoder_tag>(tr)
|
auto grammar = x3::with<mapnik::json::grammar::transcoder_tag>(tr)
|
||||||
[x3::with<mapnik::json::grammar::feature_tag>(feature)
|
[x3::with<mapnik::json::grammar::feature_tag>(feature)
|
||||||
[ mapnik::json::feature_grammar() ]];
|
[ mapnik::json::grammar::feature_rule ]];
|
||||||
#else
|
#else
|
||||||
auto grammar = x3::with<mapnik::json::grammar::transcoder_tag>(std::ref(tr))
|
auto grammar = x3::with<mapnik::json::grammar::transcoder_tag>(std::ref(tr))
|
||||||
[x3::with<mapnik::json::grammar::feature_tag>(std::ref(feature))
|
[x3::with<mapnik::json::grammar::feature_tag>(std::ref(feature))
|
||||||
[ mapnik::json::feature_grammar() ]];
|
[ mapnik::json::grammar::feature_rule ]];
|
||||||
#endif
|
#endif
|
||||||
if (!x3::phrase_parse(start, end, grammar, space_type()))
|
if (!x3::phrase_parse(start, end, grammar, space_type()))
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,7 @@ void parse_geometry(Iterator start, Iterator end, feature_impl& feature)
|
||||||
{
|
{
|
||||||
namespace x3 = boost::spirit::x3;
|
namespace x3 = boost::spirit::x3;
|
||||||
using space_type = mapnik::json::grammar::space_type;
|
using space_type = mapnik::json::grammar::space_type;
|
||||||
auto grammar = mapnik::json::geometry_grammar();
|
auto grammar = mapnik::json::grammar::geometry_rule;
|
||||||
if (!x3::phrase_parse(start, end, grammar, space_type(), feature.get_geometry()))
|
if (!x3::phrase_parse(start, end, grammar, space_type(), feature.get_geometry()))
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Can't parser GeoJSON Geometry");
|
throw std::runtime_error("Can't parser GeoJSON Geometry");
|
||||||
|
|
|
@ -41,11 +41,4 @@ BOOST_SPIRIT_INSTANTIATE_UNUSED(positions_grammar_type, iterator_type, extract_b
|
||||||
BOOST_SPIRIT_INSTANTIATE_UNUSED(positions_grammar_type, iterator_type, extract_bounding_boxes_context_type_f);
|
BOOST_SPIRIT_INSTANTIATE_UNUSED(positions_grammar_type, iterator_type, extract_bounding_boxes_context_type_f);
|
||||||
BOOST_SPIRIT_INSTANTIATE_UNUSED(positions_grammar_type, iterator_type, extract_bounding_boxes_reverse_context_type_f);
|
BOOST_SPIRIT_INSTANTIATE_UNUSED(positions_grammar_type, iterator_type, extract_bounding_boxes_reverse_context_type_f);
|
||||||
|
|
||||||
}
|
}}}
|
||||||
|
|
||||||
grammar::positions_grammar_type const& positions_grammar()
|
|
||||||
{
|
|
||||||
return grammar::positions;
|
|
||||||
}
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
|
@ -27,11 +27,4 @@ namespace mapnik { namespace json { namespace grammar {
|
||||||
|
|
||||||
BOOST_SPIRIT_INSTANTIATE(topojson_grammar_type, iterator_type, phrase_parse_context_type);
|
BOOST_SPIRIT_INSTANTIATE(topojson_grammar_type, iterator_type, phrase_parse_context_type);
|
||||||
|
|
||||||
}
|
}}}
|
||||||
|
|
||||||
grammar::topojson_grammar_type const& topojson_grammar()
|
|
||||||
{
|
|
||||||
return grammar::topology;
|
|
||||||
}
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
|
@ -42,11 +42,5 @@ BOOST_SPIRIT_INSTANTIATE_UNUSED(unicode_string_grammar_type, iterator_type, extr
|
||||||
BOOST_SPIRIT_INSTANTIATE_UNUSED(unicode_string_grammar_type, iterator_type, extract_bounding_boxes_reverse_context_type);
|
BOOST_SPIRIT_INSTANTIATE_UNUSED(unicode_string_grammar_type, iterator_type, extract_bounding_boxes_reverse_context_type);
|
||||||
BOOST_SPIRIT_INSTANTIATE_UNUSED(unicode_string_grammar_type, iterator_type, extract_bounding_boxes_context_type_f);
|
BOOST_SPIRIT_INSTANTIATE_UNUSED(unicode_string_grammar_type, iterator_type, extract_bounding_boxes_context_type_f);
|
||||||
BOOST_SPIRIT_INSTANTIATE_UNUSED(unicode_string_grammar_type, iterator_type, extract_bounding_boxes_reverse_context_type_f);
|
BOOST_SPIRIT_INSTANTIATE_UNUSED(unicode_string_grammar_type, iterator_type, extract_bounding_boxes_reverse_context_type_f);
|
||||||
}
|
|
||||||
|
|
||||||
grammar::unicode_string_grammar_type const& unicode_string_grammar()
|
}}}
|
||||||
{
|
|
||||||
return grammar::unicode_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace filter {
|
||||||
|
|
||||||
bool parse_image_filters(std::string const& str, std::vector<filter_type> & image_filters)
|
bool parse_image_filters(std::string const& str, std::vector<filter_type> & image_filters)
|
||||||
{
|
{
|
||||||
auto const& grammar = mapnik::image_filter_grammar();
|
auto const& grammar = mapnik::image_filter::start;
|
||||||
auto itr = str.begin();
|
auto itr = str.begin();
|
||||||
auto end = str.end();
|
auto end = str.end();
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ path_expression_ptr parse_path(std::string const& str)
|
||||||
using boost::spirit::x3::standard_wide::space;
|
using boost::spirit::x3::standard_wide::space;
|
||||||
std::string::const_iterator itr = str.begin();
|
std::string::const_iterator itr = str.begin();
|
||||||
std::string::const_iterator end = str.end();
|
std::string::const_iterator end = str.end();
|
||||||
bool r = x3::phrase_parse(itr, end, path_expression_grammar(), space, *path);
|
bool r = x3::phrase_parse(itr, end, grammar::path_expression, space, *path);
|
||||||
if (r && itr == end)
|
if (r && itr == end)
|
||||||
{
|
{
|
||||||
return path;
|
return path;
|
||||||
|
|
|
@ -40,12 +40,12 @@ transform_list_ptr parse_transform(std::string const& str, std::string const& en
|
||||||
#if BOOST_VERSION >= 106700
|
#if BOOST_VERSION >= 106700
|
||||||
auto const parser = boost::spirit::x3::with<mapnik::grammar::transcoder_tag>(tr)
|
auto const parser = boost::spirit::x3::with<mapnik::grammar::transcoder_tag>(tr)
|
||||||
[
|
[
|
||||||
mapnik::transform_expression_grammar()
|
mapnik::grammar::transform
|
||||||
];
|
];
|
||||||
#else
|
#else
|
||||||
auto const parser = boost::spirit::x3::with<mapnik::grammar::transcoder_tag>(std::ref(tr))
|
auto const parser = boost::spirit::x3::with<mapnik::grammar::transcoder_tag>(std::ref(tr))
|
||||||
[
|
[
|
||||||
mapnik::transform_expression_grammar()
|
mapnik::grammar::transform
|
||||||
];
|
];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -43,11 +43,11 @@ bool parse_path(const char* wkt, PathType& p)
|
||||||
#if BOOST_VERSION >= 106700
|
#if BOOST_VERSION >= 106700
|
||||||
auto const grammar = x3::with<mapnik::svg::grammar::svg_path_tag>(p)
|
auto const grammar = x3::with<mapnik::svg::grammar::svg_path_tag>(p)
|
||||||
[ x3::with<mapnik::svg::grammar::relative_tag>(relative)
|
[ x3::with<mapnik::svg::grammar::relative_tag>(relative)
|
||||||
[mapnik::svg::svg_path_grammar()]];
|
[mapnik::svg::grammar::svg_path]];
|
||||||
#else
|
#else
|
||||||
auto const grammar = x3::with<mapnik::svg::grammar::svg_path_tag>(std::ref(p))
|
auto const grammar = x3::with<mapnik::svg::grammar::svg_path_tag>(std::ref(p))
|
||||||
[ x3::with<mapnik::svg::grammar::relative_tag>(std::ref(relative))
|
[ x3::with<mapnik::svg::grammar::relative_tag>(std::ref(relative))
|
||||||
[mapnik::svg::svg_path_grammar()]];
|
[mapnik::svg::grammar::svg_path]];
|
||||||
#endif
|
#endif
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,11 +43,11 @@ bool parse_points(const char* wkt, PathType& p)
|
||||||
#if BOOST_VERSION >= 106700
|
#if BOOST_VERSION >= 106700
|
||||||
auto const grammar = x3::with<mapnik::svg::grammar::svg_path_tag>(p)
|
auto const grammar = x3::with<mapnik::svg::grammar::svg_path_tag>(p)
|
||||||
[ x3::with<mapnik::svg::grammar::relative_tag>(relative)
|
[ x3::with<mapnik::svg::grammar::relative_tag>(relative)
|
||||||
[mapnik::svg::svg_points_grammar()]];
|
[mapnik::svg::grammar::svg_points]];
|
||||||
#else
|
#else
|
||||||
auto const grammar = x3::with<mapnik::svg::grammar::svg_path_tag>(std::ref(p))
|
auto const grammar = x3::with<mapnik::svg::grammar::svg_path_tag>(std::ref(p))
|
||||||
[ x3::with<mapnik::svg::grammar::relative_tag>(std::ref(relative))
|
[ x3::with<mapnik::svg::grammar::relative_tag>(std::ref(relative))
|
||||||
[mapnik::svg::svg_points_grammar()]];
|
[mapnik::svg::grammar::svg_points]];
|
||||||
#endif
|
#endif
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,11 +40,11 @@ bool parse_svg_transform(const char* wkt, Transform& tr)
|
||||||
|
|
||||||
#if BOOST_VERSION >= 106700
|
#if BOOST_VERSION >= 106700
|
||||||
auto const grammar = x3::with<mapnik::svg::grammar::svg_transform_tag>(tr)
|
auto const grammar = x3::with<mapnik::svg::grammar::svg_transform_tag>(tr)
|
||||||
[mapnik::svg::svg_transform_grammar()];
|
[mapnik::svg::grammar::svg_transform];
|
||||||
|
|
||||||
#else
|
#else
|
||||||
auto const grammar = x3::with<mapnik::svg::grammar::svg_transform_tag>(std::ref(tr))
|
auto const grammar = x3::with<mapnik::svg::grammar::svg_transform_tag>(std::ref(tr))
|
||||||
[mapnik::svg::svg_transform_grammar()];
|
[mapnik::svg::grammar::svg_transform];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -35,7 +35,7 @@ bool from_wkt(std::string const& wkt, mapnik::geometry::geometry<double> & geom)
|
||||||
bool result;
|
bool result;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
result = x3::phrase_parse(itr, end, wkt_grammar(), space, geom);
|
result = x3::phrase_parse(itr, end, grammar::wkt, space, geom);
|
||||||
}
|
}
|
||||||
catch (x3::expectation_failure<std::string::const_iterator> const& ex)
|
catch (x3::expectation_failure<std::string::const_iterator> const& ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@ TEST_CASE("CSS color") {
|
||||||
|
|
||||||
SECTION("CSS colors")
|
SECTION("CSS colors")
|
||||||
{
|
{
|
||||||
auto const& color_grammar = mapnik::color_grammar();
|
auto const& color_grammar = mapnik::css_color_grammar::css_color;
|
||||||
boost::spirit::x3::ascii::space_type space;
|
boost::spirit::x3::ascii::space_type space;
|
||||||
{
|
{
|
||||||
// rgb
|
// rgb
|
||||||
|
|
|
@ -58,7 +58,7 @@ bool parse_topology_string(std::string const& buffer, mapnik::topojson::topology
|
||||||
char const* end = itr + buffer.length();
|
char const* end = itr + buffer.length();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boost::spirit::x3::phrase_parse(itr, end, mapnik::json::topojson_grammar(), space_type() , topo);
|
boost::spirit::x3::phrase_parse(itr, end, mapnik::json::grammar::topology, space_type() , topo);
|
||||||
}
|
}
|
||||||
catch (boost::spirit::x3::expectation_failure<char const*> const& ex)
|
catch (boost::spirit::x3::expectation_failure<char const*> const& ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -224,7 +224,7 @@ using box_type = mapnik::box2d<float>;
|
||||||
using boxes_type = std::vector<std::pair<box_type, std::pair<std::uint64_t, std::uint64_t>>>;
|
using boxes_type = std::vector<std::pair<box_type, std::pair<std::uint64_t, std::uint64_t>>>;
|
||||||
using base_iterator_type = char const*;
|
using base_iterator_type = char const*;
|
||||||
|
|
||||||
auto const& geojson_value = mapnik::json::geojson_grammar();
|
auto const& geojson_value = mapnik::json::grammar::geojson_value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue