From b9fed932b93e4f40daad54d44b287dd04f3fcaca Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 1 Oct 2012 10:20:10 +0100 Subject: [PATCH] + template vertex_iterator on path_type + rename vertex_iterator to path_iterator --- .../json/geometry_generator_grammar.hpp | 54 +++++++++---------- include/mapnik/util/container_adapter.hpp | 12 ++--- .../mapnik/util/geometry_svg_generator.hpp | 2 +- include/mapnik/util/geometry_to_svg.hpp | 1 - include/mapnik/util/geometry_to_wkt.hpp | 1 - ...{vertex_iterator.hpp => path_iterator.hpp} | 30 +++++------ src/wkt/wkt_generator.cpp | 2 +- 7 files changed, 49 insertions(+), 53 deletions(-) rename include/mapnik/util/{vertex_iterator.hpp => path_iterator.hpp} (71%) diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index a1915b062..408bbf212 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -26,7 +26,7 @@ // mapnik #include #include -#include +#include #include // 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 coordinates; karma::rule point; karma::rule linestring; karma::rule polygon; - + karma::rule coords; karma::rule, geometry_type const& ()> coords2; karma::rule point_coord; karma::rule polygon_coord; - + // phoenix functions phoenix::function _type; phoenix::function _first; @@ -200,7 +200,7 @@ struct geometry_generator_grammar : template struct multi_geometry_generator_grammar : - karma::grammar >, + karma::grammar >, 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 >, diff --git a/include/mapnik/util/container_adapter.hpp b/include/mapnik/util/container_adapter.hpp index 2cac51f28..ae985a837 100644 --- a/include/mapnik/util/container_adapter.hpp +++ b/include/mapnik/util/container_adapter.hpp @@ -26,7 +26,7 @@ // mapnik #include #include -#include +#include // boost #include @@ -40,26 +40,26 @@ struct is_container : mpl::true_ {} ; template <> struct container_iterator { - typedef mapnik::util::vertex_iterator type; + typedef mapnik::util::path_iterator type; }; template <> struct begin_container { - static mapnik::util::vertex_iterator + static mapnik::util::path_iterator call (mapnik::geometry_type const& g) { - return mapnik::util::vertex_iterator(g.data()); + return mapnik::util::path_iterator(g); } }; template <> struct end_container { - static mapnik::util::vertex_iterator + static mapnik::util::path_iterator call (mapnik::geometry_type const& g) { - return mapnik::util::vertex_iterator(); + return mapnik::util::path_iterator(); } }; diff --git a/include/mapnik/util/geometry_svg_generator.hpp b/include/mapnik/util/geometry_svg_generator.hpp index 11a7994b0..b229e73c1 100644 --- a/include/mapnik/util/geometry_svg_generator.hpp +++ b/include/mapnik/util/geometry_svg_generator.hpp @@ -26,7 +26,7 @@ // mapnik #include #include -#include +#include #include // boost diff --git a/include/mapnik/util/geometry_to_svg.hpp b/include/mapnik/util/geometry_to_svg.hpp index 018545cc9..d65d14d6c 100644 --- a/include/mapnik/util/geometry_to_svg.hpp +++ b/include/mapnik/util/geometry_to_svg.hpp @@ -26,7 +26,6 @@ // mapnik #include #include -#include #include // boost diff --git a/include/mapnik/util/geometry_to_wkt.hpp b/include/mapnik/util/geometry_to_wkt.hpp index 31cd67802..e49423ece 100644 --- a/include/mapnik/util/geometry_to_wkt.hpp +++ b/include/mapnik/util/geometry_to_wkt.hpp @@ -26,7 +26,6 @@ // mapnik #include #include -#include #include // boost diff --git a/include/mapnik/util/vertex_iterator.hpp b/include/mapnik/util/path_iterator.hpp similarity index 71% rename from include/mapnik/util/vertex_iterator.hpp rename to include/mapnik/util/path_iterator.hpp index 256903463..f62624ab5 100644 --- a/include/mapnik/util/vertex_iterator.hpp +++ b/include/mapnik/util/path_iterator.hpp @@ -25,7 +25,6 @@ // mapnik #include -#include // boost #include @@ -34,27 +33,26 @@ namespace mapnik { namespace util { template -class vertex_iterator - : public boost::iterator_facade< vertex_iterator, - typename boost::tuple const, +class path_iterator + : public boost::iterator_facade< path_iterator, + boost::tuple const, boost::forward_traversal_tag > { public: - typedef typename boost::tuple value_type; - typedef vertex_vector container_type; + typedef T path_type; + typedef typename boost::tuple 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 @@ private: 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 @@ private: } value_type v_; - container_type const *vertices_; + const path_type *vertices_; unsigned pos_; }; diff --git a/src/wkt/wkt_generator.cpp b/src/wkt/wkt_generator.cpp index e4c82e0a5..9e04640b1 100644 --- a/src/wkt/wkt_generator.cpp +++ b/src/wkt/wkt_generator.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include namespace mapnik { namespace util {