Merge branch 'master' into conv_simplify
This commit is contained in:
commit
30f14e0878
7 changed files with 49 additions and 53 deletions
|
@ -26,7 +26,7 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/global.hpp>
|
#include <mapnik/global.hpp>
|
||||||
#include <mapnik/geometry.hpp>
|
#include <mapnik/geometry.hpp>
|
||||||
#include <mapnik/util/vertex_iterator.hpp>
|
#include <mapnik/util/path_iterator.hpp>
|
||||||
#include <mapnik/util/container_adapter.hpp>
|
#include <mapnik/util/container_adapter.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
|
@ -137,14 +137,14 @@ struct geometry_generator_grammar :
|
||||||
using boost::spirit::karma::_r1;
|
using boost::spirit::karma::_r1;
|
||||||
using boost::spirit::karma::eps;
|
using boost::spirit::karma::eps;
|
||||||
using boost::spirit::karma::string;
|
using boost::spirit::karma::string;
|
||||||
|
|
||||||
coordinates = point | linestring | polygon
|
coordinates = point | linestring | polygon
|
||||||
;
|
;
|
||||||
|
|
||||||
point = &uint_(mapnik::Point)[_1 = _type(_val)]
|
point = &uint_(mapnik::Point)[_1 = _type(_val)]
|
||||||
<< point_coord [_1 = _first(_val)]
|
<< point_coord [_1 = _first(_val)]
|
||||||
;
|
;
|
||||||
|
|
||||||
linestring = &uint_(mapnik::LineString)[_1 = _type(_val)]
|
linestring = &uint_(mapnik::LineString)[_1 = _type(_val)]
|
||||||
<< lit('[')
|
<< lit('[')
|
||||||
<< coords
|
<< coords
|
||||||
|
@ -156,13 +156,13 @@ struct geometry_generator_grammar :
|
||||||
<< coords2
|
<< coords2
|
||||||
<< lit("]]")
|
<< lit("]]")
|
||||||
;
|
;
|
||||||
|
|
||||||
point_coord = &uint_
|
point_coord = &uint_
|
||||||
<< lit('[')
|
<< lit('[')
|
||||||
<< coord_type << lit(',') << coord_type
|
<< coord_type << lit(',') << coord_type
|
||||||
<< lit("]")
|
<< lit("]")
|
||||||
;
|
;
|
||||||
|
|
||||||
polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1]
|
polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1]
|
||||||
<< string[ if_ (_r1 > 1) [_1 = "],["]
|
<< string[ if_ (_r1 > 1) [_1 = "],["]
|
||||||
.else_[_1 = '[' ]] | &uint_ << lit(','))
|
.else_[_1 = '[' ]] | &uint_ << lit(','))
|
||||||
|
@ -170,25 +170,25 @@ struct geometry_generator_grammar :
|
||||||
<< lit(',')
|
<< lit(',')
|
||||||
<< coord_type << lit(']')
|
<< coord_type << lit(']')
|
||||||
;
|
;
|
||||||
|
|
||||||
coords2 %= *polygon_coord(_a)
|
coords2 %= *polygon_coord(_a)
|
||||||
;
|
;
|
||||||
|
|
||||||
coords = point_coord % lit(',')
|
coords = point_coord % lit(',')
|
||||||
;
|
;
|
||||||
|
|
||||||
}
|
}
|
||||||
// rules
|
// rules
|
||||||
karma::rule<OutputIterator, geometry_type const& ()> coordinates;
|
karma::rule<OutputIterator, geometry_type const& ()> coordinates;
|
||||||
karma::rule<OutputIterator, geometry_type const& ()> point;
|
karma::rule<OutputIterator, geometry_type const& ()> point;
|
||||||
karma::rule<OutputIterator, geometry_type const& ()> linestring;
|
karma::rule<OutputIterator, geometry_type const& ()> linestring;
|
||||||
karma::rule<OutputIterator, geometry_type const& ()> polygon;
|
karma::rule<OutputIterator, geometry_type const& ()> polygon;
|
||||||
|
|
||||||
karma::rule<OutputIterator, geometry_type const& ()> coords;
|
karma::rule<OutputIterator, geometry_type const& ()> coords;
|
||||||
karma::rule<OutputIterator, karma::locals<unsigned>, geometry_type const& ()> coords2;
|
karma::rule<OutputIterator, karma::locals<unsigned>, geometry_type const& ()> coords2;
|
||||||
karma::rule<OutputIterator, geometry_type::value_type ()> point_coord;
|
karma::rule<OutputIterator, geometry_type::value_type ()> point_coord;
|
||||||
karma::rule<OutputIterator, geometry_type::value_type (unsigned& )> polygon_coord;
|
karma::rule<OutputIterator, geometry_type::value_type (unsigned& )> polygon_coord;
|
||||||
|
|
||||||
// phoenix functions
|
// phoenix functions
|
||||||
phoenix::function<get_type > _type;
|
phoenix::function<get_type > _type;
|
||||||
phoenix::function<get_first> _first;
|
phoenix::function<get_first> _first;
|
||||||
|
@ -200,7 +200,7 @@ struct geometry_generator_grammar :
|
||||||
|
|
||||||
template <typename OutputIterator>
|
template <typename OutputIterator>
|
||||||
struct multi_geometry_generator_grammar :
|
struct multi_geometry_generator_grammar :
|
||||||
karma::grammar<OutputIterator, karma::locals<boost::tuple<unsigned,bool> >,
|
karma::grammar<OutputIterator, karma::locals<boost::tuple<unsigned,bool> >,
|
||||||
geometry_container const& ()>
|
geometry_container const& ()>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -223,36 +223,36 @@ struct multi_geometry_generator_grammar :
|
||||||
(mapnik::LineString + 3,"\"MultiLineString\"")
|
(mapnik::LineString + 3,"\"MultiLineString\"")
|
||||||
(mapnik::Polygon + 3,"\"MultiPolygon\"")
|
(mapnik::Polygon + 3,"\"MultiPolygon\"")
|
||||||
;
|
;
|
||||||
|
|
||||||
start %= ( eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)]
|
start %= ( eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)]
|
||||||
<< lit("{\"type\":\"GeometryCollection\",\"geometries\":[")
|
<< lit("{\"type\":\"GeometryCollection\",\"geometries\":[")
|
||||||
<< geometry_collection << lit("]}")
|
<< geometry_collection << lit("]}")
|
||||||
|
|
|
|
||||||
geometry)
|
geometry)
|
||||||
;
|
;
|
||||||
|
|
||||||
geometry_collection = -(geometry2 % lit(','))
|
geometry_collection = -(geometry2 % lit(','))
|
||||||
;
|
;
|
||||||
|
|
||||||
geometry = (lit("{\"type\":")
|
geometry = (lit("{\"type\":")
|
||||||
<< geometry_types[_1 = phoenix::at_c<0>(_a)][_a = _multi_type(_val)]
|
<< geometry_types[_1 = phoenix::at_c<0>(_a)][_a = _multi_type(_val)]
|
||||||
<< lit(",\"coordinates\":")
|
<< lit(",\"coordinates\":")
|
||||||
<< string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = '[']]
|
<< string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = '[']]
|
||||||
<< coordinates
|
<< coordinates
|
||||||
<< string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = ']']]
|
<< string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = ']']]
|
||||||
<< lit('}')) | lit("null")
|
<< lit('}')) | lit("null")
|
||||||
;
|
;
|
||||||
|
|
||||||
geometry2 = lit("{\"type\":")
|
geometry2 = lit("{\"type\":")
|
||||||
<< geometry_types[_1 = _a][_a = type_(_val)]
|
<< geometry_types[_1 = _a][_a = type_(_val)]
|
||||||
<< lit(",\"coordinates\":")
|
<< lit(",\"coordinates\":")
|
||||||
<< path
|
<< path
|
||||||
<< lit('}')
|
<< lit('}')
|
||||||
;
|
;
|
||||||
|
|
||||||
coordinates %= path % lit(',')
|
coordinates %= path % lit(',')
|
||||||
;
|
;
|
||||||
|
|
||||||
}
|
}
|
||||||
// rules
|
// rules
|
||||||
karma::rule<OutputIterator, karma::locals<boost::tuple<unsigned,bool> >,
|
karma::rule<OutputIterator, karma::locals<boost::tuple<unsigned,bool> >,
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/global.hpp>
|
#include <mapnik/global.hpp>
|
||||||
#include <mapnik/geometry.hpp>
|
#include <mapnik/geometry.hpp>
|
||||||
#include <mapnik/util/vertex_iterator.hpp>
|
#include <mapnik/util/path_iterator.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
|
@ -40,26 +40,26 @@ struct is_container<mapnik::geometry_type const> : mpl::true_ {} ;
|
||||||
template <>
|
template <>
|
||||||
struct container_iterator<mapnik::geometry_type const>
|
struct container_iterator<mapnik::geometry_type const>
|
||||||
{
|
{
|
||||||
typedef mapnik::util::vertex_iterator<double> type;
|
typedef mapnik::util::path_iterator<mapnik::geometry_type> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct begin_container<mapnik::geometry_type const>
|
struct begin_container<mapnik::geometry_type const>
|
||||||
{
|
{
|
||||||
static mapnik::util::vertex_iterator<double>
|
static mapnik::util::path_iterator<mapnik::geometry_type>
|
||||||
call (mapnik::geometry_type const& g)
|
call (mapnik::geometry_type const& g)
|
||||||
{
|
{
|
||||||
return mapnik::util::vertex_iterator<double>(g.data());
|
return mapnik::util::path_iterator<mapnik::geometry_type>(g);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct end_container<mapnik::geometry_type const>
|
struct end_container<mapnik::geometry_type const>
|
||||||
{
|
{
|
||||||
static mapnik::util::vertex_iterator<double>
|
static mapnik::util::path_iterator<mapnik::geometry_type>
|
||||||
call (mapnik::geometry_type const& g)
|
call (mapnik::geometry_type const& g)
|
||||||
{
|
{
|
||||||
return mapnik::util::vertex_iterator<double>();
|
return mapnik::util::path_iterator<mapnik::geometry_type>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/global.hpp>
|
#include <mapnik/global.hpp>
|
||||||
#include <mapnik/geometry.hpp>
|
#include <mapnik/geometry.hpp>
|
||||||
#include <mapnik/util/vertex_iterator.hpp>
|
#include <mapnik/util/path_iterator.hpp>
|
||||||
#include <mapnik/util/container_adapter.hpp>
|
#include <mapnik/util/container_adapter.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/global.hpp>
|
#include <mapnik/global.hpp>
|
||||||
#include <mapnik/geometry.hpp>
|
#include <mapnik/geometry.hpp>
|
||||||
#include <mapnik/util/vertex_iterator.hpp>
|
|
||||||
#include <mapnik/util/geometry_svg_generator.hpp>
|
#include <mapnik/util/geometry_svg_generator.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/global.hpp>
|
#include <mapnik/global.hpp>
|
||||||
#include <mapnik/geometry.hpp>
|
#include <mapnik/geometry.hpp>
|
||||||
#include <mapnik/util/vertex_iterator.hpp>
|
|
||||||
#include <mapnik/util/geometry_wkt_generator.hpp>
|
#include <mapnik/util/geometry_wkt_generator.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/global.hpp>
|
#include <mapnik/global.hpp>
|
||||||
#include <mapnik/vertex_vector.hpp>
|
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
|
@ -34,27 +33,26 @@
|
||||||
namespace mapnik { namespace util {
|
namespace mapnik { namespace util {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class vertex_iterator
|
class path_iterator
|
||||||
: public boost::iterator_facade< vertex_iterator<T>,
|
: public boost::iterator_facade< path_iterator<T>,
|
||||||
typename boost::tuple<unsigned,T,T> const,
|
boost::tuple<unsigned,double,double> const,
|
||||||
boost::forward_traversal_tag
|
boost::forward_traversal_tag
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename boost::tuple<unsigned, T, T> value_type;
|
typedef T path_type;
|
||||||
typedef vertex_vector<T> container_type;
|
typedef typename boost::tuple<unsigned, double, double> value_type;
|
||||||
|
|
||||||
vertex_iterator()
|
path_iterator()
|
||||||
: v_(SEG_END,0,0),
|
: v_(mapnik::SEG_END,0,0),
|
||||||
vertices_(),
|
vertices_()
|
||||||
pos_(0)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
explicit vertex_iterator(container_type const& vertices)
|
explicit path_iterator(path_type const& vertices)
|
||||||
: vertices_(&vertices),
|
: vertices_(&vertices)
|
||||||
pos_(0)
|
|
||||||
{
|
{
|
||||||
|
vertices_->rewind(0);
|
||||||
increment();
|
increment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,10 +61,10 @@ private:
|
||||||
|
|
||||||
void increment()
|
void increment()
|
||||||
{
|
{
|
||||||
boost::get<0>(v_) = vertices_->get_vertex(pos_++, &boost::get<1>(v_), &boost::get<2>(v_));
|
boost::get<0>(v_) = vertices_->vertex( &boost::get<1>(v_), &boost::get<2>(v_));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool equal( vertex_iterator const& other) const
|
bool equal( path_iterator const& other) const
|
||||||
{
|
{
|
||||||
return boost::get<0>(v_) == boost::get<0>(other.v_);
|
return boost::get<0>(v_) == boost::get<0>(other.v_);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +75,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
value_type v_;
|
value_type v_;
|
||||||
container_type const *vertices_;
|
const path_type *vertices_;
|
||||||
unsigned pos_;
|
unsigned pos_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#include <mapnik/geometry.hpp>
|
#include <mapnik/geometry.hpp>
|
||||||
#include <mapnik/util/geometry_wkt_generator.hpp>
|
#include <mapnik/util/geometry_wkt_generator.hpp>
|
||||||
#include <mapnik/util/vertex_iterator.hpp>
|
#include <mapnik/util/path_iterator.hpp>
|
||||||
#include <mapnik/util/container_adapter.hpp>
|
#include <mapnik/util/container_adapter.hpp>
|
||||||
|
|
||||||
namespace mapnik { namespace util {
|
namespace mapnik { namespace util {
|
||||||
|
|
Loading…
Reference in a new issue