From dc57849b7dd11dd702804147ca34e909eb755fd3 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 18:40:57 -0700 Subject: [PATCH] geometry container typedef fixing --- bindings/python/mapnik_feature.cpp | 4 +- bindings/python/mapnik_geometry.cpp | 2 +- include/mapnik/feature.hpp | 1 + include/mapnik/geometry.hpp | 6 --- include/mapnik/geometry_container.hpp | 35 ++++++++++++++++ .../mapnik/json/feature_generator_grammar.hpp | 1 + include/mapnik/json/feature_grammar.hpp | 1 + include/mapnik/json/geometry_parser.hpp | 3 +- include/mapnik/util/container_adapter.hpp | 5 +-- include/mapnik/util/geometry_to_svg.hpp | 1 + include/mapnik/util/geometry_to_wkb.hpp | 9 ++-- include/mapnik/util/geometry_to_wkt.hpp | 1 + include/mapnik/wkb.hpp | 1 + include/mapnik/wkt/wkt_factory.hpp | 1 + include/mapnik/wkt/wkt_grammar.hpp | 1 + src/wkb.cpp | 42 +++++++++---------- utils/geometry_to_wkb/main.cpp | 2 +- 17 files changed, 77 insertions(+), 39 deletions(-) create mode 100644 include/mapnik/geometry_container.hpp diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index f5c80c579..b12bd1570 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -30,11 +30,9 @@ #include #include #include - #include // mapnik - #include #include #include @@ -56,7 +54,7 @@ using mapnik::context_ptr; using mapnik::feature_kv_iterator; mapnik::geometry_type const& (mapnik::feature_impl::*get_geometry_by_const_ref)(std::size_t) const = &mapnik::feature_impl::get_geometry; -boost::ptr_vector const& (mapnik::feature_impl::*get_paths_by_const_ref)() const = &mapnik::feature_impl::paths; +mapnik::geometry_container const& (mapnik::feature_impl::*get_paths_by_const_ref)() const = &mapnik::feature_impl::paths; void feature_add_geometries_from_wkb(mapnik::feature_impl & feature, std::string wkb) { diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index 2084dd888..1594c86a7 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -28,12 +28,12 @@ #include #include #include -#include #include #include // mapnik #include +#include #include // from_wkt #include #include // from_geojson diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index 9547ba86b..9a600b0f4 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index b78f89aa3..471e043e8 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -28,10 +28,6 @@ #include #include -// boost -#include -#include - namespace mapnik { template class Container=vertex_vector> @@ -154,8 +150,6 @@ public: }; using geometry_type = geometry; -using geometry_ptr = std::shared_ptr; -using geometry_container = boost::ptr_vector; } diff --git a/include/mapnik/geometry_container.hpp b/include/mapnik/geometry_container.hpp new file mode 100644 index 000000000..c56eaa734 --- /dev/null +++ b/include/mapnik/geometry_container.hpp @@ -0,0 +1,35 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2011 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_GEOMETRY_CONTAINER_HPP +#define MAPNIK_GEOMETRY_CONTAINER_HPP + +// boost +#include + +namespace mapnik { + +using geometry_container = boost::ptr_vector; + +} + +#endif // MAPNIK_GEOMETRY_CONTAINER_HPP diff --git a/include/mapnik/json/feature_generator_grammar.hpp b/include/mapnik/json/feature_generator_grammar.hpp index d909f6a84..973c68243 100644 --- a/include/mapnik/json/feature_generator_grammar.hpp +++ b/include/mapnik/json/feature_generator_grammar.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp index 104c6b2e7..90f65b004 100644 --- a/include/mapnik/json/feature_grammar.hpp +++ b/include/mapnik/json/feature_grammar.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/include/mapnik/json/geometry_parser.hpp b/include/mapnik/json/geometry_parser.hpp index e40791fb9..57f5ac6c0 100644 --- a/include/mapnik/json/geometry_parser.hpp +++ b/include/mapnik/json/geometry_parser.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include #include // boost @@ -33,7 +34,7 @@ namespace mapnik { namespace json { -inline bool from_geojson(std::string const& json, boost::ptr_vector & paths) +inline bool from_geojson(std::string const& json, geometry_container & paths) { using namespace boost::spirit; static const geometry_grammar g; diff --git a/include/mapnik/util/container_adapter.hpp b/include/mapnik/util/container_adapter.hpp index cdd374bb5..8416e6093 100644 --- a/include/mapnik/util/container_adapter.hpp +++ b/include/mapnik/util/container_adapter.hpp @@ -25,11 +25,11 @@ // mapnik #include +#include #include // boost #include -#include namespace boost { namespace spirit { namespace traits { @@ -60,9 +60,8 @@ template <> struct end_container { static mapnik::util::path_iterator - call (mapnik::geometry_type const& g) + call (mapnik::geometry_type const&) { - boost::ignore_unused_variable_warning(g); return mapnik::util::path_iterator(); } }; diff --git a/include/mapnik/util/geometry_to_svg.hpp b/include/mapnik/util/geometry_to_svg.hpp index e18bc2ce7..6e207dbd8 100644 --- a/include/mapnik/util/geometry_to_svg.hpp +++ b/include/mapnik/util/geometry_to_svg.hpp @@ -26,6 +26,7 @@ // mapnik #include #include +#include #include // boost diff --git a/include/mapnik/util/geometry_to_wkb.hpp b/include/mapnik/util/geometry_to_wkb.hpp index 0f5ff9a13..bd90161b9 100644 --- a/include/mapnik/util/geometry_to_wkb.hpp +++ b/include/mapnik/util/geometry_to_wkb.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include // stl @@ -187,7 +188,7 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order) using point_type = std::pair; using linear_ring = std::vector; - boost::ptr_vector rings; + std::vector rings; double x = 0; double y = 0; @@ -197,8 +198,10 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order) unsigned command = g.vertex(i,&x,&y); if (command == SEG_MOVETO) { - rings.push_back(new linear_ring); // start new loop - rings.back().emplace_back(x,y); + linear_ring ring; + ring.reserve(1); + ring.emplace_back(x,y); + rings.push_back(std::move(ring)); // start new loop size += 4; // num_points size += 2 * 8; // point } diff --git a/include/mapnik/util/geometry_to_wkt.hpp b/include/mapnik/util/geometry_to_wkt.hpp index b861c1a33..5d4967fd0 100644 --- a/include/mapnik/util/geometry_to_wkt.hpp +++ b/include/mapnik/util/geometry_to_wkt.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include #include namespace mapnik { namespace util { diff --git a/include/mapnik/wkb.hpp b/include/mapnik/wkb.hpp index 7474a0182..2f3052c66 100644 --- a/include/mapnik/wkb.hpp +++ b/include/mapnik/wkb.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include #include namespace mapnik diff --git a/include/mapnik/wkt/wkt_factory.hpp b/include/mapnik/wkt/wkt_factory.hpp index 7fbbaf28d..c546d5953 100644 --- a/include/mapnik/wkt/wkt_factory.hpp +++ b/include/mapnik/wkt/wkt_factory.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include #include // stl diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index 370b83c78..badaa720f 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -29,6 +29,7 @@ // mapnik #include +#include #include namespace mapnik { namespace wkt { diff --git a/src/wkb.cpp b/src/wkb.cpp index b85d1532b..2f028a5c2 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -128,7 +128,7 @@ public: needSwap_ = byteOrder_ ? wkbXDR : wkbNDR; } - void read(boost::ptr_vector & paths) + void read(geometry_container & paths) { int type = read_integer(); @@ -307,7 +307,7 @@ private: } } - void read_point(boost::ptr_vector & paths) + void read_point(geometry_container & paths) { double x = read_double(); double y = read_double(); @@ -316,7 +316,7 @@ private: paths.push_back(pt.release()); } - void read_multipoint(boost::ptr_vector & paths) + void read_multipoint(geometry_container & paths) { int num_points = read_integer(); for (int i = 0; i < num_points; ++i) @@ -326,7 +326,7 @@ private: } } - void read_point_xyz(boost::ptr_vector & paths) + void read_point_xyz(geometry_container & paths) { double x = read_double(); double y = read_double(); @@ -336,7 +336,7 @@ private: paths.push_back(pt.release()); } - void read_point_xyzm(boost::ptr_vector & paths) + void read_point_xyzm(geometry_container & paths) { double x = read_double(); double y = read_double(); @@ -346,7 +346,7 @@ private: paths.push_back(pt.release()); } - void read_multipoint_xyz(boost::ptr_vector & paths) + void read_multipoint_xyz(geometry_container & paths) { int num_points = read_integer(); for (int i = 0; i < num_points; ++i) @@ -356,7 +356,7 @@ private: } } - void read_multipoint_xyzm(boost::ptr_vector & paths) + void read_multipoint_xyzm(geometry_container & paths) { int num_points = read_integer(); for (int i = 0; i < num_points; ++i) @@ -366,7 +366,7 @@ private: } } - void read_linestring(boost::ptr_vector & paths) + void read_linestring(geometry_container & paths) { int num_points = read_integer(); if (num_points > 0) @@ -383,7 +383,7 @@ private: } } - void read_multilinestring(boost::ptr_vector & paths) + void read_multilinestring(geometry_container & paths) { int num_lines = read_integer(); for (int i = 0; i < num_lines; ++i) @@ -393,7 +393,7 @@ private: } } - void read_linestring_xyz(boost::ptr_vector & paths) + void read_linestring_xyz(geometry_container & paths) { int num_points = read_integer(); if (num_points > 0) @@ -410,7 +410,7 @@ private: } } - void read_linestring_xyzm(boost::ptr_vector & paths) + void read_linestring_xyzm(geometry_container & paths) { int num_points = read_integer(); if (num_points > 0) @@ -427,7 +427,7 @@ private: } } - void read_multilinestring_xyz(boost::ptr_vector & paths) + void read_multilinestring_xyz(geometry_container & paths) { int num_lines = read_integer(); for (int i = 0; i < num_lines; ++i) @@ -437,7 +437,7 @@ private: } } - void read_multilinestring_xyzm(boost::ptr_vector & paths) + void read_multilinestring_xyzm(geometry_container & paths) { int num_lines = read_integer(); for (int i = 0; i < num_lines; ++i) @@ -447,7 +447,7 @@ private: } } - void read_polygon(boost::ptr_vector & paths) + void read_polygon(geometry_container & paths) { int num_rings = read_integer(); if (num_rings > 0) @@ -473,7 +473,7 @@ private: } } - void read_multipolygon(boost::ptr_vector & paths) + void read_multipolygon(geometry_container & paths) { int num_polys = read_integer(); for (int i = 0; i < num_polys; ++i) @@ -483,7 +483,7 @@ private: } } - void read_polygon_xyz(boost::ptr_vector & paths) + void read_polygon_xyz(geometry_container & paths) { int num_rings = read_integer(); if (num_rings > 0) @@ -509,7 +509,7 @@ private: } } - void read_polygon_xyzm(boost::ptr_vector & paths) + void read_polygon_xyzm(geometry_container & paths) { int num_rings = read_integer(); if (num_rings > 0) @@ -535,7 +535,7 @@ private: } } - void read_multipolygon_xyz(boost::ptr_vector & paths) + void read_multipolygon_xyz(geometry_container & paths) { int num_polys = read_integer(); for (int i = 0; i < num_polys; ++i) @@ -545,7 +545,7 @@ private: } } - void read_multipolygon_xyzm(boost::ptr_vector & paths) + void read_multipolygon_xyzm(geometry_container & paths) { int num_polys = read_integer(); for (int i = 0; i < num_polys; ++i) @@ -555,7 +555,7 @@ private: } } - void read_collection(boost::ptr_vector & paths) + void read_collection(geometry_container & paths) { int num_geometries = read_integer(); for (int i = 0; i < num_geometries; ++i) @@ -607,7 +607,7 @@ private: }; -bool geometry_utils::from_wkb(boost::ptr_vector& paths, +bool geometry_utils::from_wkb(geometry_container& paths, const char* wkb, unsigned size, wkbFormat format) diff --git a/utils/geometry_to_wkb/main.cpp b/utils/geometry_to_wkb/main.cpp index b8048f283..76396ff24 100644 --- a/utils/geometry_to_wkb/main.cpp +++ b/utils/geometry_to_wkb/main.cpp @@ -81,7 +81,7 @@ int main (int argc, char ** argv ) while(f) { std::cerr << *f << std::endl; - boost::ptr_vector & paths = f->paths(); + mapnik::geometry_container const& paths = f->paths(); for (mapnik::geometry_type const& geom : paths) { // NDR