ammend topojson_grammar and remove last boost::variant usage

This commit is contained in:
artemp 2014-08-12 16:16:17 +01:00
parent 7f8e18f89b
commit f57f3a7f83
6 changed files with 20 additions and 21 deletions

View file

@ -92,7 +92,7 @@ private:
qi::rule<Iterator, space_type, mapnik::topojson::multi_linestring()> multi_linestring;
qi::rule<Iterator, space_type, mapnik::topojson::polygon()> polygon;
qi::rule<Iterator, space_type, mapnik::topojson::multi_polygon()> multi_polygon;
qi::rule<Iterator, space_type, std::vector<mapnik::topojson::geometry>()> geometry_collection;
qi::rule<Iterator, space_type, void(std::vector<mapnik::topojson::geometry>&)> geometry_collection;
qi::rule<Iterator, space_type, std::vector<index_type>()> ring;
@ -105,7 +105,6 @@ private:
// error
boost::phoenix::function<where_message> where_message_;
};
}}

View file

@ -40,13 +40,15 @@ topojson_grammar<Iterator>::topojson_grammar()
qi::no_skip_type no_skip;
qi::omit_type omit;
qi::_val_type _val;
qi::_1_type _1;
qi::_2_type _2;
qi::_3_type _3;
qi::_4_type _4;
qi::_r1_type _r1;
standard_wide::char_type char_;
using qi::fail;
using qi::on_error;
using phoenix::construct;
using phoenix::push_back;
// generic json types
value = object | array | string_ | number
@ -114,7 +116,7 @@ topojson_grammar<Iterator>::topojson_grammar()
>> lit('{')
>> -((omit[string_]
>> lit(':')
>> (geometry_collection | geometry)) % lit(','))
>> (geometry_collection(_val) | geometry)) % lit(','))
>> lit('}')
;
@ -130,7 +132,7 @@ topojson_grammar<Iterator>::topojson_grammar()
geometry_collection = lit('{')
>> lit("\"type\"") >> lit(':') >> lit("\"GeometryCollection\"") >> lit(',')
>> lit("\"geometries\"") >> lit(':') >> lit('[') >> -(geometry % lit(','))
>> lit("\"geometries\"") >> lit(':') >> lit('[') >> -(geometry[push_back(_r1, _1)] % lit(','))
>> lit(']')
>> lit('}')
;

View file

@ -27,11 +27,10 @@
#include <mapnik/box2d.hpp>
#include <mapnik/json/topology.hpp>
#include <mapnik/util/variant.hpp>
#include <boost/variant.hpp>
namespace mapnik { namespace topojson {
struct bounding_box_visitor : public boost::static_visitor<box2d<double> >
struct bounding_box_visitor : public mapnik::util::static_visitor<box2d<double> >
{
bounding_box_visitor(topology const& topo)
: topo_(topo) {}

View file

@ -32,7 +32,6 @@
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/fusion/adapted/std_tuple.hpp>
#include <boost/optional.hpp>
#include <boost/variant.hpp>
namespace mapnik { namespace topojson {
@ -86,7 +85,7 @@ struct multi_polygon
struct invalid {};
using geometry = boost::variant<invalid,
using geometry = util::variant<invalid,
point,
linestring,
polygon,

View file

@ -34,7 +34,7 @@
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry.hpp>
#include <boost/geometry/extensions/index/rtree/rtree.hpp>
#include <boost/variant.hpp>
// mapnik
#include <mapnik/unicode.hpp>
#include <mapnik/value_types.hpp>
@ -87,7 +87,7 @@ struct attr_value_converter : public mapnik::util::static_visitor<mapnik::eAttri
}
};
struct geometry_type_visitor : public boost::static_visitor<int>
struct geometry_type_visitor : public mapnik::util::static_visitor<int>
{
int operator() (mapnik::topojson::point const&) const
{
@ -211,14 +211,14 @@ void topojson_datasource::parse_topojson(T & stream)
std::size_t count = 0;
for (auto const& geom : topo_.geometries)
{
mapnik::box2d<double> bbox = boost::apply_visitor(mapnik::topojson::bounding_box_visitor(topo_), geom);
mapnik::box2d<double> bbox = mapnik::util::apply_visitor(mapnik::topojson::bounding_box_visitor(topo_), geom);
if (bbox.valid())
{
if (count == 0)
{
extent_ = bbox;
collect_attributes_visitor assessor(desc_);
boost::apply_visitor(assessor,geom);
mapnik::util::apply_visitor( std::ref(assessor), geom);
}
else
{
@ -245,7 +245,7 @@ boost::optional<mapnik::datasource::geometry_t> topojson_datasource::get_geometr
for (std::size_t i = 0; i < num_features && i < 5; ++i)
{
mapnik::topojson::geometry const& geom = topo_.geometries[i];
int type = boost::apply_visitor(geometry_type_visitor(),geom);
int type = mapnik::util::apply_visitor(geometry_type_visitor(),geom);
if (type > 0)
{
if (multi_type > 0 && multi_type != type)

View file

@ -371,7 +371,7 @@ mapnik::feature_ptr topojson_featureset::next()
if ( index < topo_.geometries.size())
{
mapnik::topojson::geometry const& geom = topo_.geometries[index];
mapnik::feature_ptr feature = boost::apply_visitor(
mapnik::feature_ptr feature = mapnik::util::apply_visitor(
mapnik::topojson::feature_generator<mapnik::context_ptr>(ctx_, tr_, topo_, feature_id_++),
geom);
return feature;