From 2a3af1eb409599ecaa934174bea1900ffdfc450a Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 26 Jan 2015 10:37:09 +0100 Subject: [PATCH] move boost.geometry <-- mapnik::box2d into separate header for better modularity and code re-use --- include/mapnik/polygon_clipper.hpp | 52 +------------ .../mapnik/util/boost_geometry_adapters.hpp | 77 +++++++++++++++++++ plugins/input/geojson/geojson_datasource.cpp | 2 +- 3 files changed, 81 insertions(+), 50 deletions(-) create mode 100644 include/mapnik/util/boost_geometry_adapters.hpp diff --git a/include/mapnik/polygon_clipper.hpp b/include/mapnik/polygon_clipper.hpp index 57c758e1e..91f467051 100644 --- a/include/mapnik/polygon_clipper.hpp +++ b/include/mapnik/polygon_clipper.hpp @@ -17,7 +17,8 @@ * 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_CLIPPER_HPP #define MAPNIK_POLYGON_CLIPPER_HPP @@ -31,57 +32,10 @@ #include #include #include +#include // boost #include -#include -#include -#include -#include - -BOOST_GEOMETRY_REGISTER_POINT_2D(mapnik::coord2d, double, cs::cartesian, x, y) - -// register mapnik::box2d -namespace boost { namespace geometry { namespace traits -{ - -template<> struct tag > { using type = box_tag; }; - -template<> struct point_type > { using type = mapnik::coord2d; }; - -template <> -struct indexed_access, min_corner, 0> -{ - using ct = coordinate_type::type; - static inline ct get(mapnik::box2d const& b) { return b.minx();} - static inline void set(mapnik::box2d &b, ct const& value) { b.set_minx(value); } -}; - -template <> -struct indexed_access, min_corner, 1> -{ - using ct = coordinate_type::type; - static inline ct get(mapnik::box2d const& b) { return b.miny();} - static inline void set(mapnik::box2d &b, ct const& value) { b.set_miny(value); } -}; - -template <> -struct indexed_access, max_corner, 0> -{ - using ct = coordinate_type::type; - static inline ct get(mapnik::box2d const& b) { return b.maxx();} - static inline void set(mapnik::box2d &b, ct const& value) { b.set_maxx(value); } -}; - -template <> -struct indexed_access, max_corner, 1> -{ - using ct = coordinate_type::type; - static inline ct get(mapnik::box2d const& b) { return b.maxy();} - static inline void set(mapnik::box2d &b , ct const& value) { b.set_maxy(value); } -}; - -}}} namespace mapnik { diff --git a/include/mapnik/util/boost_geometry_adapters.hpp b/include/mapnik/util/boost_geometry_adapters.hpp new file mode 100644 index 000000000..ca99fbc84 --- /dev/null +++ b/include/mapnik/util/boost_geometry_adapters.hpp @@ -0,0 +1,77 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2015 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 BOOST_GEOMETRY_ADAPTERS_HPP +#define BOOST_GEOMETRY_ADAPTERS_HPP + +// boost +#include +#include +#include +#include + +BOOST_GEOMETRY_REGISTER_POINT_2D(mapnik::coord2d, double, cs::cartesian, x, y) + +// register mapnik::box2d +namespace boost { namespace geometry { namespace traits +{ + +template<> struct tag > { using type = box_tag; }; + +template<> struct point_type > { using type = mapnik::coord2d; }; + +template <> +struct indexed_access, min_corner, 0> +{ + using ct = coordinate_type::type; + static inline ct get(mapnik::box2d const& b) { return b.minx();} + static inline void set(mapnik::box2d &b, ct const& value) { b.set_minx(value); } +}; + +template <> +struct indexed_access, min_corner, 1> +{ + using ct = coordinate_type::type; + static inline ct get(mapnik::box2d const& b) { return b.miny();} + static inline void set(mapnik::box2d &b, ct const& value) { b.set_miny(value); } +}; + +template <> +struct indexed_access, max_corner, 0> +{ + using ct = coordinate_type::type; + static inline ct get(mapnik::box2d const& b) { return b.maxx();} + static inline void set(mapnik::box2d &b, ct const& value) { b.set_maxx(value); } +}; + +template <> +struct indexed_access, max_corner, 1> +{ + using ct = coordinate_type::type; + static inline ct get(mapnik::box2d const& b) { return b.maxy();} + static inline void set(mapnik::box2d &b , ct const& value) { b.set_maxy(value); } +}; + +}}} + + +#endif //BOOST_GEOMETRY_ADAPTERS_HPP diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index 6ce625dcf..3fa68ac98 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -47,7 +47,7 @@ #include #include #include -#include // boost::geometry - register box2d +#include // boost.geometry - register box2d using mapnik::datasource; using mapnik::parameters;