diff --git a/include/mapnik/geometry/multi_polygon.hpp b/include/mapnik/geometry/multi_polygon.hpp index fdf28437a..735df3c44 100644 --- a/include/mapnik/geometry/multi_polygon.hpp +++ b/include/mapnik/geometry/multi_polygon.hpp @@ -24,12 +24,19 @@ #define MAPNIK_GEOMETRY_MULTI_POLYGON_HPP // geometry -#include +#include namespace mapnik { namespace geometry { -template -using multi_polygon = mapbox::geometry::multi_polygon; +template class Cont = std::vector> +struct multi_polygon : Cont> +{ + using coordinate_type = T; + using polygon_type = polygon; + using container_type = Cont; + using container_type::container_type; +}; + }} diff --git a/include/mapnik/geometry/polygon.hpp b/include/mapnik/geometry/polygon.hpp index 378e8ae8d..e1431d562 100644 --- a/include/mapnik/geometry/polygon.hpp +++ b/include/mapnik/geometry/polygon.hpp @@ -26,48 +26,82 @@ // geometry #include -// stl -//#include - namespace mapnik { namespace geometry { template using linear_ring = mapbox::geometry::linear_ring; template -using polygon = mapbox::geometry::polygon; - - -/* -template -using rings_container = std::vector>; - -template class InteriorRings = rings_container> -struct polygon +struct polygon : mapbox::geometry::polygon { using coordinate_type = T; - using rings_container = InteriorRings; - linear_ring exterior_ring; - rings_container interior_rings; - - inline void set_exterior_ring(linear_ring && ring) + using base_type = mapbox::geometry::polygon; + using linear_ring_type = linear_ring; + struct interior_rings { - exterior_ring = std::move(ring); + using iterator = typename base_type::iterator; + using const_iterator = typename base_type::const_iterator; + using value_type = typename base_type::value_type; + interior_rings(polygon & poly) + : poly_(poly) {} + iterator begin() + { + auto itr = poly_.begin(); + std::advance(itr, 1); + return itr; + } + + iterator end() { return poly_.end();} + const_iterator begin() const + { + auto itr = poly_.begin(); + std::advance(itr, 1); + return itr; + } + const_iterator end() const { return poly_.end();} + + void clear() + { + poly_.resize(1); + } + + void resize(std::size_t size) + { + poly_.resize(size + 1); + } + + std::size_t size() const + { + return poly_.empty() ? 0 : poly_.size() - 1; + } + + void push_back(value_type const& val) { poly_.push_back(val); } + value_type& back() { return poly_.back(); } + value_type const& back() const { return poly_.back(); } + polygon & poly_; + }; + + polygon() + : base_type(), + interior_(*this) + { + //this->resize(1); // explicit exterior ring ? } - inline void add_hole(linear_ring && ring) - { - interior_rings.emplace_back(std::move(ring)); - } + polygon(polygon const& other) + : base_type(other), + interior_(*this) {} - inline bool empty() const { return exterior_ring.empty(); } - - inline std::size_t num_rings() const + interior_rings const& interior() const { - return 1 + interior_rings.size(); + return interior_; } + interior_rings & interior() + { + return interior_; + } + interior_rings interior_; }; -*/ }} diff --git a/include/mapnik/geometry_adapters.hpp b/include/mapnik/geometry_adapters.hpp index f0c5506df..770cb630c 100644 --- a/include/mapnik/geometry_adapters.hpp +++ b/include/mapnik/geometry_adapters.hpp @@ -41,7 +41,6 @@ #include #include #include -#include #include // register point @@ -177,13 +176,13 @@ struct ring_mutable_type > template struct interior_const_type > { - using type = boost::iterator_range::const_iterator> const; + using type = typename mapnik::geometry::polygon::interior_rings const&; }; template struct interior_mutable_type > { - using type = mapnik::detail::polygon_interior; + using type = typename mapnik::geometry::polygon::interior_rings& ; }; // exterior @@ -213,14 +212,13 @@ struct interior_rings > static interior_const_type get(mapnik::geometry::polygon const& p) { - return boost::make_iterator_range(p.begin() + 1, p.end()); + return p.interior(); } static interior_mutable_type get(mapnik::geometry::polygon& p) { - return mapnik::detail::polygon_interior(p); + return p.interior(); } - }; }}} diff --git a/include/mapnik/polygon_interior.hpp b/include/mapnik/polygon_interior.hpp deleted file mode 100644 index bb8775d64..000000000 --- a/include/mapnik/polygon_interior.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2016 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_POLYGON_INTERIOR_HPP -#define MAPNIK_POLYGON_INTERIOR_HPP - -#include - - -namespace mapnik { namespace detail { - -template -struct polygon_interior -{ - using coordinate_type = T; - using iterator = typename geometry::polygon::iterator; - using const_iterator = typename geometry::polygon::const_iterator; - using value_type = typename geometry::polygon::value_type; - - polygon_interior(geometry::polygon & poly) - : poly_(poly) {} - - iterator begin() - { - auto itr = poly_.begin(); - std::advance(itr, 1); - return itr; - } - - iterator end() { return poly_.end();} - const_iterator begin() const - { - auto itr = poly_.begin(); - std::advance(itr, 1); - return itr; - } - const_iterator end() const { return poly_.end();} - - void clear() - { - poly_.resize(1); - } - void resize(std::size_t size) - { - poly_.resize(size + 1); - } - - std::size_t size() const - { - return poly_.empty() ? 0 : poly_.size() - 1; - } - - value_type& back() { return poly_.back(); } - value_type const& back() const { return poly_.back(); } - geometry::polygon & poly_; -}; - -}} - -#endif // MAPNIK_POLYGON_INTERIOR_HPP