Add support for BOOST >= 1_72 (backport relevant changes from master)
This commit is contained in:
parent
78756a9056
commit
f1cf712d50
14 changed files with 284 additions and 222 deletions
|
@ -1087,6 +1087,7 @@ int main()
|
|||
return False
|
||||
|
||||
def boost_regex_has_icu(context):
|
||||
context.env.Append(LIBS='icui18n')
|
||||
if env['RUNTIME_LINK'] == 'static':
|
||||
# re-order icu libs to ensure linux linker is happy
|
||||
for lib_name in ['icui18n',env['ICU_LIB_NAME'],'icudata']:
|
||||
|
|
4
deps/agg/src/agg_pixfmt_rgba.cpp
vendored
4
deps/agg/src/agg_pixfmt_rgba.cpp
vendored
|
@ -5,11 +5,13 @@
|
|||
#include <boost/version.hpp>
|
||||
#if BOOST_VERSION >= 106900
|
||||
#include <boost/gil.hpp>
|
||||
#include <boost/gil/extension/toolbox/color_spaces/hsv.hpp>
|
||||
#include <boost/gil/extension/toolbox/color_spaces/hsl.hpp>
|
||||
#else
|
||||
#include <boost/gil/gil_all.hpp>
|
||||
#endif
|
||||
#include <boost/gil/extension/toolbox/hsv.hpp>
|
||||
#include <boost/gil/extension/toolbox/hsl.hpp>
|
||||
#endif
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
namespace agg
|
||||
|
|
|
@ -208,6 +208,11 @@ public:
|
|||
return geom_;
|
||||
}
|
||||
|
||||
inline geometry::geometry<double> & get_geometry()
|
||||
{
|
||||
return geom_;
|
||||
}
|
||||
|
||||
inline box2d<double> envelope() const
|
||||
{
|
||||
return mapnik::geometry::envelope(geom_);
|
||||
|
|
121
include/mapnik/geometry/boost_spirit_karma_adapter.hpp
Normal file
121
include/mapnik/geometry/boost_spirit_karma_adapter.hpp
Normal file
|
@ -0,0 +1,121 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* 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_BOOST_SPIRIT_KARMA_ADAPTER_HPP
|
||||
#define MAPNIK_BOOST_SPIRIT_KARMA_ADAPTER_HPP
|
||||
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
||||
namespace boost { using mapbox::util::get; }
|
||||
|
||||
#include <boost/spirit/home/karma/domain.hpp>
|
||||
#include <boost/spirit/home/support/attributes.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
template <>
|
||||
struct not_is_variant<mapnik::geometry::geometry<double>, karma::domain>
|
||||
: mpl::false_
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct not_is_variant<mapnik::geometry::geometry<std::int64_t>, karma::domain>
|
||||
: mpl::false_
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct variant_which< mapnik::geometry::geometry<double> >
|
||||
{
|
||||
static int call(mapnik::geometry::geometry<double> const& v)
|
||||
{
|
||||
return v.which();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct variant_which< mapnik::geometry::geometry<std::int64_t> >
|
||||
{
|
||||
static int call(mapnik::geometry::geometry<std::int64_t> const& v)
|
||||
{
|
||||
return v.which();
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename T, typename Tuple>
|
||||
struct has_type;
|
||||
|
||||
template <typename T>
|
||||
struct has_type<T, std::tuple<>> : std::false_type {};
|
||||
|
||||
template <typename T, typename U, typename... Types>
|
||||
struct has_type<T, std::tuple<U, Types...>> : has_type<T, std::tuple<Types...>> {};
|
||||
|
||||
template <typename T, typename... Types>
|
||||
struct has_type<T, std::tuple<T, Types...>> : std::true_type {};
|
||||
|
||||
template <typename T, typename Tuple>
|
||||
struct index;
|
||||
|
||||
template <typename T, typename... Types>
|
||||
struct index<T, std::tuple<T, Types...>>
|
||||
{
|
||||
static const std::size_t value = 0;
|
||||
};
|
||||
|
||||
template <typename T, typename U, typename... Types>
|
||||
struct index<T, std::tuple<U, Types...>>
|
||||
{
|
||||
static const std::size_t value = 1 + index<T, std::tuple<Types...>>::value;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template <typename Expected>
|
||||
struct compute_compatible_component_variant<mapnik::geometry::geometry<double>, Expected>
|
||||
: detail::has_type<Expected, mapnik::geometry::geometry<double>::types>
|
||||
{
|
||||
using compatible_type = Expected;
|
||||
static bool is_compatible(int index)
|
||||
{
|
||||
return (index == detail::index<compatible_type, mapnik::geometry::geometry<double>::types>::value);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Expected>
|
||||
struct compute_compatible_component_variant<mapnik::geometry::geometry<std::int64_t>, Expected>
|
||||
: detail::has_type<Expected, mapnik::geometry::geometry<std::int64_t>::types>
|
||||
{
|
||||
using compatible_type = Expected;
|
||||
static bool is_compatible(int index)
|
||||
{
|
||||
return (index == detail::index<compatible_type, mapnik::geometry::geometry<std::int64_t>::types>::value);
|
||||
}
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
|
||||
|
||||
#endif //MAPNIK_BOOST_SPIRIT_KARMA_ADAPTER_HPP
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2015 Artem Pavlenko
|
||||
* 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
|
||||
|
@ -63,17 +63,18 @@ struct end_container<mapnik::feature_impl const>
|
|||
}
|
||||
};
|
||||
|
||||
#if BOOST_VERSION >= 106900
|
||||
template <>
|
||||
struct transform_attribute<const boost::fusion::cons<mapnik::feature_impl const&, boost::fusion::nil>,
|
||||
mapnik::geometry::geometry<double> const& , karma::domain>
|
||||
{
|
||||
using type = mapnik::geometry::geometry<double> const&;
|
||||
static type pre(const boost::fusion::cons<mapnik::feature_impl const&, boost::fusion::nil>& f)
|
||||
{
|
||||
return boost::fusion::at<mpl::int_<0> >(f).get_geometry();
|
||||
}
|
||||
};
|
||||
struct transform_attribute<const mapnik::feature_impl, const mapnik::feature_impl &, boost::spirit::karma::domain, void>
|
||||
: detail::transform_attribute_base<mapnik::feature_impl const, mapnik::feature_impl const&, boost::spirit::karma::domain>
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct transform_attribute<const boost::fusion::cons<const mapnik::feature_impl &, boost::fusion::nil_>, const mapnik::feature_impl &,
|
||||
boost::spirit::karma::domain, void>
|
||||
: detail::transform_attribute_base<const boost::fusion::cons<const mapnik::feature_impl &, boost::fusion::nil_>, mapnik::feature_impl const&, boost::spirit::karma::domain>
|
||||
{};
|
||||
#endif
|
||||
}}}
|
||||
|
||||
namespace mapnik { namespace json {
|
||||
|
@ -91,6 +92,15 @@ struct get_id
|
|||
}
|
||||
};
|
||||
|
||||
struct extract_geometry
|
||||
{
|
||||
using result_type = mapnik::geometry::geometry<double> const&;
|
||||
template <typename T>
|
||||
result_type operator() (T const& f) const
|
||||
{
|
||||
return f.get_geometry();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename OutputIterator, typename FeatureType>
|
||||
struct feature_generator_grammar :
|
||||
|
@ -101,6 +111,7 @@ struct feature_generator_grammar :
|
|||
geometry_generator_grammar<OutputIterator, mapnik::geometry::geometry<double> > geometry;
|
||||
properties_generator_grammar<OutputIterator, FeatureType> properties;
|
||||
boost::phoenix::function<get_id<FeatureType> > id_;
|
||||
boost::phoenix::function<extract_geometry> geom_;
|
||||
};
|
||||
|
||||
}}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2015 Artem Pavlenko
|
||||
* 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
|
||||
|
@ -22,11 +22,6 @@
|
|||
|
||||
#include <mapnik/json/feature_generator_grammar.hpp>
|
||||
|
||||
#include <boost/spirit/include/karma.hpp>
|
||||
#include <boost/spirit/include/phoenix.hpp>
|
||||
#include <boost/spirit/include/phoenix_core.hpp>
|
||||
#include <boost/fusion/include/at.hpp>
|
||||
|
||||
namespace mapnik { namespace json {
|
||||
|
||||
template <typename OutputIterator, typename FeatureType>
|
||||
|
@ -40,7 +35,7 @@ feature_generator_grammar<OutputIterator, FeatureType>::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('}')
|
||||
;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2015 Artem Pavlenko
|
||||
* 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
|
||||
|
@ -26,13 +26,10 @@
|
|||
// mapnik
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/geometry_type.hpp>
|
||||
// boost
|
||||
#pragma GCC diagnostic push
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <boost/spirit/include/karma.hpp>
|
||||
#include <boost/spirit/include/phoenix_function.hpp>
|
||||
#include <boost/fusion/adapted/std_tuple.hpp>
|
||||
#include <boost/math/special_functions/trunc.hpp> // for vc++ and android whose c++11 libs lack std::trunc
|
||||
#include <boost/spirit/home/karma/domain.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
@ -43,18 +40,6 @@ namespace karma = boost::spirit::karma;
|
|||
|
||||
namespace detail {
|
||||
|
||||
template <typename Geometry>
|
||||
struct get_type
|
||||
{
|
||||
using result_type = mapnik::geometry::geometry_types;
|
||||
template <typename T>
|
||||
result_type operator() (T const& geom) const
|
||||
{
|
||||
auto type = mapnik::geometry::geometry_type(geom);
|
||||
return type;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct json_coordinate_policy : karma::real_policies<T>
|
||||
{
|
||||
|
@ -88,30 +73,28 @@ struct json_coordinate_policy : karma::real_policies<T>
|
|||
|
||||
template <typename OutputIterator, typename Geometry>
|
||||
struct geometry_generator_grammar :
|
||||
karma::grammar<OutputIterator, Geometry const&()>
|
||||
karma::grammar<OutputIterator, Geometry()>
|
||||
{
|
||||
using coord_type = typename Geometry::coord_type;
|
||||
geometry_generator_grammar();
|
||||
karma::rule<OutputIterator, Geometry const&()> geometry;
|
||||
karma::rule<OutputIterator, karma::locals<mapnik::geometry::geometry_types>, Geometry const&() > geometry_dispatch;
|
||||
karma::rule<OutputIterator, geometry::geometry<double> const&()> point;
|
||||
karma::rule<OutputIterator, geometry::point<double> const&()> point_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<double> const&()> linestring;
|
||||
karma::rule<OutputIterator, geometry::line_string<double> const&()> linestring_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<double> const&()> polygon;
|
||||
karma::rule<OutputIterator, geometry::polygon<double> const&()> polygon_coord;
|
||||
karma::rule<OutputIterator, geometry::linear_ring<double> const&()> exterior_ring_coord;
|
||||
karma::rule<OutputIterator, geometry::polygon<double>::rings_container const&()> interior_ring_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<double> const& ()> multi_point;
|
||||
karma::rule<OutputIterator, geometry::multi_point<double> const& ()> multi_point_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<double> const& ()> multi_linestring;
|
||||
karma::rule<OutputIterator, geometry::multi_line_string<double> const& ()> multi_linestring_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<double> const& ()> multi_polygon;
|
||||
karma::rule<OutputIterator, geometry::multi_polygon<double> const& ()> multi_polygon_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<double> const& ()> geometry_collection;
|
||||
karma::rule<OutputIterator, geometry::geometry_collection<double> const& ()> geometries;
|
||||
boost::phoenix::function<detail::get_type<Geometry> > geometry_type;
|
||||
karma::real_generator<double, detail::json_coordinate_policy<double> > coordinate;
|
||||
|
||||
karma::rule<OutputIterator, Geometry()> geometry;
|
||||
karma::rule<OutputIterator, geometry::point<coord_type>()> point;
|
||||
karma::rule<OutputIterator, geometry::point<coord_type>()> point_coord;
|
||||
karma::rule<OutputIterator, geometry::line_string<coord_type>()> linestring;
|
||||
karma::rule<OutputIterator, geometry::line_string<coord_type>()> linestring_coord;
|
||||
karma::rule<OutputIterator, geometry::polygon<coord_type>()> polygon;
|
||||
karma::rule<OutputIterator, geometry::polygon<coord_type>()> polygon_coord;
|
||||
karma::rule<OutputIterator, geometry::linear_ring<coord_type>()> linear_ring_coord;
|
||||
karma::rule<OutputIterator, geometry::multi_point<coord_type>()> multi_point;
|
||||
karma::rule<OutputIterator, geometry::multi_point<coord_type>()> multi_point_coord;
|
||||
karma::rule<OutputIterator, geometry::multi_line_string<coord_type>()> multi_linestring;
|
||||
karma::rule<OutputIterator, geometry::multi_line_string<coord_type> ()> multi_linestring_coord;
|
||||
karma::rule<OutputIterator, geometry::multi_polygon<coord_type>()> multi_polygon;
|
||||
karma::rule<OutputIterator, geometry::multi_polygon<coord_type>()> multi_polygon_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry_collection<coord_type>()> geometry_collection;
|
||||
karma::rule<OutputIterator, geometry::geometry_collection<coord_type>()> geometries;
|
||||
//
|
||||
karma::real_generator<coord_type, detail::json_coordinate_policy<coord_type> > coordinate;
|
||||
};
|
||||
|
||||
}}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2015 Artem Pavlenko
|
||||
* 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
|
||||
|
@ -22,93 +22,79 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/json/geometry_generator_grammar.hpp>
|
||||
#include <mapnik/util/spirit_transform_attribute.hpp>
|
||||
#include <mapnik/geometry_types.hpp>
|
||||
#include <mapnik/geometry_fusion_adapted.hpp>
|
||||
|
||||
// boost
|
||||
#pragma GCC diagnostic push
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <boost/spirit/include/karma.hpp>
|
||||
#include <boost/spirit/include/phoenix.hpp>
|
||||
#include <boost/spirit/include/phoenix_core.hpp>
|
||||
#include <boost/spirit/include/phoenix_fusion.hpp>
|
||||
#include <boost/fusion/include/at.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
namespace mapnik { namespace json {
|
||||
|
||||
namespace karma = boost::spirit::karma;
|
||||
namespace phoenix = boost::phoenix;
|
||||
|
||||
template <typename OutputIterator, typename Geometry>
|
||||
geometry_generator_grammar<OutputIterator, Geometry>::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)
|
||||
geometry =
|
||||
point
|
||||
|
|
||||
(&uint_(geometry::geometry_types::LineString)[_1 = _a]
|
||||
<< (linestring | "{\"type\":\"LineString\",\"coordinates\":[]}"))
|
||||
linestring
|
||||
|
|
||||
(&uint_(geometry::geometry_types::Polygon)[_1 = _a]
|
||||
<< (polygon | "{\"type\":\"Polygon\",\"coordinates\":[[]]}"))
|
||||
polygon
|
||||
|
|
||||
(&uint_(geometry::geometry_types::MultiPoint)[_1 = _a]
|
||||
<< (multi_point | "{\"type\":\"MultiPoint\",\"coordinates\":[]}"))
|
||||
multi_point
|
||||
|
|
||||
(&uint_(geometry::geometry_types::MultiLineString)[_1 = _a]
|
||||
<< (multi_linestring | "{\"type\":\"MultiLineString\",\"coordinates\":[[]]}"))
|
||||
multi_linestring
|
||||
|
|
||||
(&uint_(geometry::geometry_types::MultiPolygon)[_1 = _a]
|
||||
<< (multi_polygon | "{\"type\":\"MultiPolygon\",\"coordinates\":[[[]]]}"))
|
||||
multi_polygon
|
||||
|
|
||||
(&uint_(geometry::geometry_types::GeometryCollection)[_1 = _a] << geometry_collection)
|
||||
geometry_collection
|
||||
|
|
||||
lit("null")
|
||||
lit("null") // geometry_empty
|
||||
;
|
||||
|
||||
point = lit("{\"type\":\"Point\",\"coordinates\":") << point_coord << lit("}")
|
||||
;
|
||||
linestring = lit("{\"type\":\"LineString\",\"coordinates\":[") << linestring_coord << lit("]}")
|
||||
|
||||
linestring = lit("{\"type\":\"LineString\",\"coordinates\":") << linestring_coord << lit("}")
|
||||
;
|
||||
polygon = lit("{\"type\":\"Polygon\",\"coordinates\":[") << polygon_coord << lit("]}")
|
||||
|
||||
polygon = lit("{\"type\":\"Polygon\",\"coordinates\":") << polygon_coord << lit("}")
|
||||
;
|
||||
multi_point = lit("{\"type\":\"MultiPoint\",\"coordinates\":[") << multi_point_coord << lit("]}")
|
||||
|
||||
multi_point = lit("{\"type\":\"MultiPoint\",\"coordinates\":") << multi_point_coord << lit("}")
|
||||
;
|
||||
multi_linestring = lit("{\"type\":\"MultiLineString\",\"coordinates\":[") << multi_linestring_coord << lit("]}")
|
||||
|
||||
multi_linestring = lit("{\"type\":\"MultiLineString\",\"coordinates\":") << multi_linestring_coord << lit("}")
|
||||
;
|
||||
multi_polygon = lit("{\"type\":\"MultiPolygon\",\"coordinates\":[") << multi_polygon_coord << lit("]}")
|
||||
|
||||
multi_polygon = lit("{\"type\":\"MultiPolygon\",\"coordinates\":") << multi_polygon_coord << lit("}")
|
||||
;
|
||||
|
||||
geometry_collection = lit("{\"type\":\"GeometryCollection\",\"geometries\":[") << geometries << lit("]}")
|
||||
;
|
||||
|
||||
point_coord = lit('[') << coordinate << lit(',') << coordinate << lit(']')
|
||||
;
|
||||
linestring_coord = (point_coord % lit(','))
|
||||
|
||||
linestring_coord = lit('[') << -(point_coord % lit(',')) << lit(']')
|
||||
;
|
||||
polygon_coord = lit('[') << exterior_ring_coord << lit(']') << interior_ring_coord
|
||||
|
||||
linear_ring_coord = lit('[') << -(point_coord % lit(',')) << lit(']')
|
||||
;
|
||||
exterior_ring_coord = linestring_coord.alias()
|
||||
|
||||
polygon_coord = lit('[') << linear_ring_coord << *(lit(',') << linear_ring_coord)<< lit(']');
|
||||
;
|
||||
interior_ring_coord = *(lit(",[") << exterior_ring_coord << lit(']'))
|
||||
|
||||
multi_point_coord = lit('[') << -(point_coord % lit(',')) << lit(']')
|
||||
;
|
||||
multi_point_coord = linestring_coord.alias()
|
||||
|
||||
multi_linestring_coord = lit('[') << linestring_coord % lit(',') << lit(']')
|
||||
;
|
||||
multi_linestring_coord = (lit('[') << linestring_coord << lit(']')) % lit(',')
|
||||
|
||||
multi_polygon_coord = lit('[') << polygon_coord % lit(',') << lit("]")
|
||||
;
|
||||
multi_polygon_coord = (lit('[') << polygon_coord << lit(']')) % lit(',')
|
||||
;
|
||||
geometries = geometry % lit(',')
|
||||
|
||||
geometries = geometry % lit(',')
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,12 @@
|
|||
|
||||
#include <mapnik/json/properties_generator_grammar.hpp>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <boost/spirit/include/phoenix.hpp>
|
||||
#include <boost/fusion/adapted/std_tuple.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
namespace mapnik { namespace json {
|
||||
|
||||
namespace karma = boost::spirit::karma;
|
||||
|
@ -63,14 +69,13 @@ properties_generator_grammar<OutputIterator,KeyValueStore>::properties_generator
|
|||
boost::spirit::karma::string_type kstring;
|
||||
boost::spirit::karma::eps_type eps;
|
||||
using boost::phoenix::at_c;
|
||||
|
||||
properties = lit('{')
|
||||
<< -(pair % lit(','))
|
||||
<< lit('}')
|
||||
;
|
||||
|
||||
pair = lit('"')
|
||||
<< kstring[_1 = boost::phoenix::at_c<0>(_val)] << lit('"')
|
||||
<< kstring[_1 = at_c<0>(_val)] << lit('"')
|
||||
<< lit(':')
|
||||
<< value[_1 = extract_string_(at_c<1>(_val))]
|
||||
;
|
||||
|
@ -80,13 +85,6 @@ properties_generator_grammar<OutputIterator,KeyValueStore>::properties_generator
|
|||
kstring[_1 = at_c<0>(_val)]
|
||||
;
|
||||
|
||||
// FIXME http://boost-spirit.com/home/articles/karma-examples/creating-your-own-generator-component-for-spirit-karma/
|
||||
//value = (value_null_| bool_ | int__ | double_ | ustring)//[_1 = value_base_(_r1)]
|
||||
// ;
|
||||
//value_null_ = kstring[_1 = "null"]
|
||||
// ;
|
||||
//ustring = escaped_string_(quote_.c_str())[_1 = utf8_(_val)]
|
||||
// ;
|
||||
}
|
||||
|
||||
}}
|
||||
|
|
|
@ -141,7 +141,7 @@ struct coordinate_policy : karma::real_policies<T>
|
|||
|
||||
template <typename OutputIterator, typename Path>
|
||||
struct svg_path_generator :
|
||||
karma::grammar<OutputIterator, Path const& ()>
|
||||
karma::grammar<OutputIterator, Path()>
|
||||
{
|
||||
|
||||
using path_type = Path;
|
||||
|
@ -149,12 +149,12 @@ struct svg_path_generator :
|
|||
|
||||
svg_path_generator();
|
||||
// rules
|
||||
karma::rule<OutputIterator, path_type const& ()> svg;
|
||||
karma::rule<OutputIterator, path_type const& ()> point;
|
||||
karma::rule<OutputIterator, path_type const& ()> linestring;
|
||||
karma::rule<OutputIterator, path_type const& ()> polygon;
|
||||
karma::rule<OutputIterator, coord_type ()> svg_point;
|
||||
karma::rule<OutputIterator, path_type const& ()> svg_path;
|
||||
karma::rule<OutputIterator, path_type()> svg;
|
||||
karma::rule<OutputIterator, path_type()> point;
|
||||
karma::rule<OutputIterator, path_type()> linestring;
|
||||
karma::rule<OutputIterator, path_type()> polygon;
|
||||
karma::rule<OutputIterator, coord_type()> svg_point;
|
||||
karma::rule<OutputIterator, path_type()> svg_path;
|
||||
|
||||
// phoenix functions
|
||||
phoenix::function<svg_detail::get_type<path_type> > _type;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2015 Artem Pavlenko
|
||||
* 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
|
||||
|
@ -26,12 +26,10 @@
|
|||
// mapnik
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/geometry_type.hpp>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <boost/spirit/include/karma.hpp>
|
||||
#include <boost/spirit/include/phoenix_function.hpp>
|
||||
#include <boost/math/special_functions/trunc.hpp> // for vc++ and android whose c++11 libs lack std::trunc
|
||||
#include <boost/spirit/home/karma/domain.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
@ -39,22 +37,9 @@
|
|||
namespace mapnik { namespace wkt {
|
||||
|
||||
namespace karma = boost::spirit::karma;
|
||||
namespace phoenix = boost::phoenix;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename Geometry>
|
||||
struct get_type
|
||||
{
|
||||
using result_type = mapnik::geometry::geometry_types;
|
||||
template <typename T>
|
||||
result_type operator() (T const& geom) const
|
||||
{
|
||||
auto type = mapnik::geometry::geometry_type(geom);
|
||||
return type;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct wkt_coordinate_policy : karma::real_policies<T>
|
||||
{
|
||||
|
@ -102,33 +87,29 @@ struct coordinate_generator<std::int64_t>
|
|||
|
||||
template <typename OutputIterator, typename Geometry>
|
||||
struct wkt_generator_grammar :
|
||||
karma::grammar<OutputIterator, Geometry const& ()>
|
||||
karma::grammar<OutputIterator, Geometry()>
|
||||
{
|
||||
using coord_type = typename Geometry::coord_type;
|
||||
using coordinate_type = typename Geometry::coord_type;
|
||||
wkt_generator_grammar();
|
||||
// rules
|
||||
karma::rule<OutputIterator, Geometry const&()> geometry;
|
||||
karma::rule<OutputIterator, karma::locals<mapnik::geometry::geometry_types>, Geometry const&() > geometry_dispatch;
|
||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const&()> point;
|
||||
karma::rule<OutputIterator, geometry::point<coord_type> const&()> point_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const&()> linestring;
|
||||
karma::rule<OutputIterator, geometry::line_string<coord_type> const&()> linestring_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const&()> polygon;
|
||||
karma::rule<OutputIterator, geometry::polygon<coord_type> const&()> polygon_coord;
|
||||
karma::rule<OutputIterator, geometry::linear_ring<coord_type> const&()> exterior_ring_coord;
|
||||
karma::rule<OutputIterator, std::vector<geometry::linear_ring<coord_type> > const&()> interior_ring_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> multi_point;
|
||||
karma::rule<OutputIterator, geometry::multi_point<coord_type> const& ()> multi_point_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> multi_linestring;
|
||||
karma::rule<OutputIterator, geometry::multi_line_string<coord_type> const& ()> multi_linestring_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> multi_polygon;
|
||||
karma::rule<OutputIterator, geometry::multi_polygon<coord_type> const& ()> multi_polygon_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> geometry_collection;
|
||||
karma::rule<OutputIterator, geometry::geometry_collection<coord_type> const& ()> geometries;
|
||||
boost::phoenix::function<detail::get_type<Geometry> > geometry_type;
|
||||
karma::symbols<mapnik::geometry::geometry_types, char const*> empty;
|
||||
karma::rule<OutputIterator, Geometry()> geometry;
|
||||
karma::rule<OutputIterator, geometry::point<coordinate_type>()> point;
|
||||
karma::rule<OutputIterator, geometry::point<coordinate_type>()> point_coord;
|
||||
karma::rule<OutputIterator, geometry::line_string<coordinate_type>()> linestring;
|
||||
karma::rule<OutputIterator, geometry::line_string<coordinate_type>()> linestring_coord;
|
||||
karma::rule<OutputIterator, geometry::polygon<coordinate_type>()> polygon;
|
||||
karma::rule<OutputIterator, geometry::polygon<coordinate_type>()> polygon_coord;
|
||||
karma::rule<OutputIterator, geometry::linear_ring<coordinate_type>()> linear_ring_coord;
|
||||
karma::rule<OutputIterator, geometry::multi_point<coordinate_type>()> multi_point;
|
||||
karma::rule<OutputIterator, geometry::multi_point<coordinate_type>()> multi_point_coord;
|
||||
karma::rule<OutputIterator, geometry::multi_line_string<coordinate_type>()> multi_linestring;
|
||||
karma::rule<OutputIterator, geometry::multi_line_string<coordinate_type>()> multi_linestring_coord;
|
||||
karma::rule<OutputIterator, geometry::multi_polygon<coordinate_type>()> multi_polygon;
|
||||
karma::rule<OutputIterator, geometry::multi_polygon<coordinate_type>()> multi_polygon_coord;
|
||||
karma::rule<OutputIterator, geometry::geometry_collection<coordinate_type>()> geometry_collection;
|
||||
karma::rule<OutputIterator, geometry::geometry_collection<coordinate_type>()> geometries;
|
||||
//
|
||||
typename detail::coordinate_generator<coord_type>::generator coordinate;
|
||||
typename detail::coordinate_generator<coordinate_type>::generator coordinate;
|
||||
};
|
||||
|
||||
}}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2015 Artem Pavlenko
|
||||
* 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
|
||||
|
@ -22,97 +22,76 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/wkt/wkt_generator_grammar.hpp>
|
||||
#include <mapnik/util/spirit_transform_attribute.hpp>
|
||||
#include <mapnik/geometry_fusion_adapted.hpp>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <boost/spirit/include/phoenix.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
namespace mapnik { namespace wkt {
|
||||
|
||||
template <typename OutputIterator, typename Geometry>
|
||||
wkt_generator_grammar<OutputIterator, Geometry>::wkt_generator_grammar()
|
||||
: wkt_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;
|
||||
|
||||
empty.add
|
||||
(geometry::geometry_types::Point, "POINT EMPTY")
|
||||
(geometry::geometry_types::LineString, "LINESTRING EMPTY")
|
||||
(geometry::geometry_types::Polygon, "POLYGON EMPTY")
|
||||
(geometry::geometry_types::MultiPoint, "MULTIPOINT EMPTY")
|
||||
(geometry::geometry_types::MultiLineString, "MULTILINESTRING EMPTY")
|
||||
(geometry::geometry_types::MultiPolygon, "MULTIPOLYGON EMPTY")
|
||||
(geometry::geometry_types::GeometryCollection, "GEOMETRYCOLLECTION EMPTY")
|
||||
;
|
||||
|
||||
geometry = geometry_dispatch.alias()
|
||||
;
|
||||
|
||||
geometry_dispatch = eps[_a = geometry_type(_val)] <<
|
||||
(&uint_(geometry::geometry_types::Point)[_1 = _a]
|
||||
<< point)
|
||||
geometry =
|
||||
point
|
||||
|
|
||||
(&uint_(geometry::geometry_types::LineString)[_1 = _a]
|
||||
<< (linestring | empty[_1 = _a]))
|
||||
linestring
|
||||
|
|
||||
(&uint_(geometry::geometry_types::Polygon)[_1 = _a]
|
||||
<< (polygon | empty[_1 = _a]))
|
||||
polygon
|
||||
|
|
||||
(&uint_(geometry::geometry_types::MultiPoint)[_1 = _a]
|
||||
<< ( multi_point | empty[_1 = _a]))
|
||||
multi_point
|
||||
|
|
||||
(&uint_(geometry::geometry_types::MultiLineString)[_1 = _a]
|
||||
<< (multi_linestring | empty[_1 = _a]))
|
||||
multi_linestring
|
||||
|
|
||||
(&uint_(geometry::geometry_types::MultiPolygon)[_1 = _a]
|
||||
<< (multi_polygon | empty[_1 = _a]))
|
||||
multi_polygon
|
||||
|
|
||||
(&uint_(geometry::geometry_types::GeometryCollection)[_1 = _a]
|
||||
<< (geometry_collection | empty[_1 = _a]))
|
||||
geometry_collection
|
||||
|
|
||||
(&uint_(geometry::geometry_types::Unknown)[_1 = _a]
|
||||
<< lit("POINT EMPTY")) // special case for geometry_empty as mapnik::geometry::point<double> can't be empty
|
||||
lit("POINT EMPTY FAIL") // special case for geometry_empty
|
||||
;
|
||||
|
||||
point = lit("POINT(") << point_coord << lit(")")
|
||||
;
|
||||
linestring = lit("LINESTRING(") << linestring_coord << lit(")")
|
||||
|
||||
linestring = lit("LINESTRING") << (linestring_coord | lit(" EMPTY"))
|
||||
;
|
||||
polygon = lit("POLYGON(") << polygon_coord << lit(")")
|
||||
|
||||
polygon = lit("POLYGON") << (polygon_coord | lit(" EMPTY"))
|
||||
;
|
||||
multi_point = lit("MULTIPOINT(") << multi_point_coord << lit(")")
|
||||
|
||||
multi_point = lit("MULTIPOINT") << (multi_point_coord | lit(" EMPTY"))
|
||||
;
|
||||
multi_linestring = lit("MULTILINESTRING(") << multi_linestring_coord << lit(")")
|
||||
|
||||
multi_linestring = lit("MULTILINESTRING") << (multi_linestring_coord | lit(" EMPTY"))
|
||||
;
|
||||
multi_polygon = lit("MULTIPOLYGON(") << multi_polygon_coord << lit(")")
|
||||
|
||||
multi_polygon = lit("MULTIPOLYGON") << (multi_polygon_coord | lit(" EMPTY"))
|
||||
;
|
||||
geometry_collection = lit("GEOMETRYCOLLECTION(") << geometries << lit(")")
|
||||
|
||||
geometry_collection = lit("GEOMETRYCOLLECTION") << (lit("(") << geometries << lit(")") | lit(" EMPTY"))
|
||||
;
|
||||
|
||||
point_coord = coordinate << lit(' ') << coordinate
|
||||
;
|
||||
linestring_coord = point_coord % lit(',')
|
||||
|
||||
linestring_coord = lit('(') << point_coord % lit(',') << lit(')')
|
||||
;
|
||||
polygon_coord = lit('(') << exterior_ring_coord << lit(')') << interior_ring_coord
|
||||
|
||||
linear_ring_coord = lit('(') << point_coord % lit(',') << lit(')')
|
||||
;
|
||||
exterior_ring_coord = linestring_coord.alias()
|
||||
|
||||
polygon_coord = lit('(') << linear_ring_coord << *(lit(',') << linear_ring_coord)<< lit(')');
|
||||
;
|
||||
interior_ring_coord = *(lit(",(") << exterior_ring_coord << lit(')'))
|
||||
|
||||
multi_point_coord = lit('(') << point_coord % lit(',') << lit(')')
|
||||
;
|
||||
multi_point_coord = linestring_coord.alias()
|
||||
|
||||
multi_linestring_coord = lit("(") << linestring_coord % lit(',') << lit(")")
|
||||
;
|
||||
multi_linestring_coord = (lit('(') << linestring_coord << lit(')')) % lit(',')
|
||||
|
||||
multi_polygon_coord = lit("(") << polygon_coord % lit(',') << lit(")")
|
||||
;
|
||||
multi_polygon_coord = (lit('(') << polygon_coord << lit(')')) % lit(',')
|
||||
;
|
||||
geometries = geometry % lit(',')
|
||||
|
||||
geometries = geometry % lit(',')
|
||||
;
|
||||
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
||||
#include <mapnik/geometry/boost_spirit_karma_adapter.hpp>
|
||||
#include <mapnik/json/geometry_generator_grammar_impl.hpp>
|
||||
#include <mapnik/json/properties_generator_grammar_impl.hpp>
|
||||
#include <mapnik/json/feature_generator_grammar_impl.hpp>
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
||||
#include <mapnik/geometry/boost_spirit_karma_adapter.hpp>
|
||||
#include <mapnik/wkt/wkt_generator_grammar_impl.hpp>
|
||||
#include <string>
|
||||
|
||||
|
|
Loading…
Reference in a new issue