Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

+ template vertex_iterator on path_type

+ rename vertex_iterator to path_iterator
  • Loading branch information...
commit b9fed932b93e4f40daad54d44b287dd04f3fcaca 1 parent 2714bdc
@artemp artemp authored
View
54 include/mapnik/json/geometry_generator_grammar.hpp
@@ -26,7 +26,7 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/geometry.hpp>
-#include <mapnik/util/vertex_iterator.hpp>
+#include <mapnik/util/path_iterator.hpp>
#include <mapnik/util/container_adapter.hpp>
// boost
@@ -137,14 +137,14 @@ struct geometry_generator_grammar :
using boost::spirit::karma::_r1;
using boost::spirit::karma::eps;
using boost::spirit::karma::string;
-
+
coordinates = point | linestring | polygon
;
-
+
point = &uint_(mapnik::Point)[_1 = _type(_val)]
<< point_coord [_1 = _first(_val)]
;
-
+
linestring = &uint_(mapnik::LineString)[_1 = _type(_val)]
<< lit('[')
<< coords
@@ -156,13 +156,13 @@ struct geometry_generator_grammar :
<< coords2
<< lit("]]")
;
-
- point_coord = &uint_
- << lit('[')
+
+ point_coord = &uint_
+ << lit('[')
<< coord_type << lit(',') << coord_type
<< lit("]")
;
-
+
polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1]
<< string[ if_ (_r1 > 1) [_1 = "],["]
.else_[_1 = '[' ]] | &uint_ << lit(','))
@@ -170,25 +170,25 @@ struct geometry_generator_grammar :
<< lit(',')
<< coord_type << lit(']')
;
-
+
coords2 %= *polygon_coord(_a)
;
-
+
coords = point_coord % lit(',')
;
-
+
}
// rules
karma::rule<OutputIterator, geometry_type const& ()> coordinates;
karma::rule<OutputIterator, geometry_type const& ()> point;
karma::rule<OutputIterator, geometry_type const& ()> linestring;
karma::rule<OutputIterator, geometry_type const& ()> polygon;
-
+
karma::rule<OutputIterator, geometry_type const& ()> coords;
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 (unsigned& )> polygon_coord;
-
+
// phoenix functions
phoenix::function<get_type > _type;
phoenix::function<get_first> _first;
@@ -200,7 +200,7 @@ struct geometry_generator_grammar :
template <typename OutputIterator>
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& ()>
{
@@ -223,36 +223,36 @@ struct multi_geometry_generator_grammar :
(mapnik::LineString + 3,"\"MultiLineString\"")
(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\":[")
<< geometry_collection << lit("]}")
|
- geometry)
+ geometry)
;
-
+
geometry_collection = -(geometry2 % lit(','))
;
-
- geometry = (lit("{\"type\":")
- << geometry_types[_1 = phoenix::at_c<0>(_a)][_a = _multi_type(_val)]
+
+ geometry = (lit("{\"type\":")
+ << geometry_types[_1 = phoenix::at_c<0>(_a)][_a = _multi_type(_val)]
<< lit(",\"coordinates\":")
<< string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = '[']]
<< coordinates
<< 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)]
<< lit(",\"coordinates\":")
<< path
- << lit('}')
+ << lit('}')
;
-
+
coordinates %= path % lit(',')
;
-
+
}
// rules
karma::rule<OutputIterator, karma::locals<boost::tuple<unsigned,bool> >,
View
12 include/mapnik/util/container_adapter.hpp
@@ -26,7 +26,7 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/geometry.hpp>
-#include <mapnik/util/vertex_iterator.hpp>
+#include <mapnik/util/path_iterator.hpp>
// boost
#include <boost/tuple/tuple.hpp>
@@ -40,26 +40,26 @@ struct is_container<mapnik::geometry_type const> : mpl::true_ {} ;
template <>
struct container_iterator<mapnik::geometry_type const>
{
- typedef mapnik::util::vertex_iterator<double> type;
+ typedef mapnik::util::path_iterator<mapnik::geometry_type> type;
};
template <>
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)
{
- return mapnik::util::vertex_iterator<double>(g.data());
+ return mapnik::util::path_iterator<mapnik::geometry_type>(g);
}
};
template <>
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)
{
- return mapnik::util::vertex_iterator<double>();
+ return mapnik::util::path_iterator<mapnik::geometry_type>();
}
};
View
2  include/mapnik/util/geometry_svg_generator.hpp
@@ -26,7 +26,7 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/geometry.hpp>
-#include <mapnik/util/vertex_iterator.hpp>
+#include <mapnik/util/path_iterator.hpp>
#include <mapnik/util/container_adapter.hpp>
// boost
View
1  include/mapnik/util/geometry_to_svg.hpp
@@ -26,7 +26,6 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/geometry.hpp>
-#include <mapnik/util/vertex_iterator.hpp>
#include <mapnik/util/geometry_svg_generator.hpp>
// boost
View
1  include/mapnik/util/geometry_to_wkt.hpp
@@ -26,7 +26,6 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/geometry.hpp>
-#include <mapnik/util/vertex_iterator.hpp>
#include <mapnik/util/geometry_wkt_generator.hpp>
// boost
View
30 include/mapnik/util/vertex_iterator.hpp → include/mapnik/util/path_iterator.hpp
@@ -25,7 +25,6 @@
// mapnik
#include <mapnik/global.hpp>
-#include <mapnik/vertex_vector.hpp>
// boost
#include <boost/tuple/tuple.hpp>
@@ -34,27 +33,26 @@
namespace mapnik { namespace util {
template <typename T>
-class vertex_iterator
- : public boost::iterator_facade< vertex_iterator<T>,
- typename boost::tuple<unsigned,T,T> const,
+class path_iterator
+ : public boost::iterator_facade< path_iterator<T>,
+ boost::tuple<unsigned,double,double> const,
boost::forward_traversal_tag
>
{
public:
- typedef typename boost::tuple<unsigned, T, T> value_type;
- typedef vertex_vector<T> container_type;
+ typedef T path_type;
+ typedef typename boost::tuple<unsigned, double, double> value_type;
- vertex_iterator()
- : v_(SEG_END,0,0),
- vertices_(),
- pos_(0)
+ path_iterator()
+ : v_(mapnik::SEG_END,0,0),
+ vertices_()
{}
- explicit vertex_iterator(container_type const& vertices)
- : vertices_(&vertices),
- pos_(0)
+ explicit path_iterator(path_type const& vertices)
+ : vertices_(&vertices)
{
+ vertices_->rewind(0);
increment();
}
@@ -63,10 +61,10 @@ class vertex_iterator
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_);
}
@@ -77,7 +75,7 @@ class vertex_iterator
}
value_type v_;
- container_type const *vertices_;
+ const path_type *vertices_;
unsigned pos_;
};
View
2  src/wkt/wkt_generator.cpp
@@ -26,7 +26,7 @@
#include <mapnik/geometry.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>
namespace mapnik { namespace util {
Please sign in to comment.
Something went wrong with that request. Please try again.