mirror of
https://github.com/mapnik/mapnik.git
synced 2025-12-08 20:13:09 +00:00
move boost.geometry <-- mapnik::box2d<double> into separate header for better modularity and code re-use
This commit is contained in:
parent
1263bc9c2e
commit
2a3af1eb40
@ -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 <mapnik/box2d.hpp>
|
||||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/util/boost_geometry_adapters.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/box.hpp>
|
||||
#include <boost/geometry/geometries/polygon.hpp>
|
||||
#include <boost/geometry/geometries/register/point.hpp>
|
||||
|
||||
BOOST_GEOMETRY_REGISTER_POINT_2D(mapnik::coord2d, double, cs::cartesian, x, y)
|
||||
|
||||
// register mapnik::box2d<double>
|
||||
namespace boost { namespace geometry { namespace traits
|
||||
{
|
||||
|
||||
template<> struct tag<mapnik::box2d<double> > { using type = box_tag; };
|
||||
|
||||
template<> struct point_type<mapnik::box2d<double> > { using type = mapnik::coord2d; };
|
||||
|
||||
template <>
|
||||
struct indexed_access<mapnik::box2d<double>, min_corner, 0>
|
||||
{
|
||||
using ct = coordinate_type<mapnik::coord2d>::type;
|
||||
static inline ct get(mapnik::box2d<double> const& b) { return b.minx();}
|
||||
static inline void set(mapnik::box2d<double> &b, ct const& value) { b.set_minx(value); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct indexed_access<mapnik::box2d<double>, min_corner, 1>
|
||||
{
|
||||
using ct = coordinate_type<mapnik::coord2d>::type;
|
||||
static inline ct get(mapnik::box2d<double> const& b) { return b.miny();}
|
||||
static inline void set(mapnik::box2d<double> &b, ct const& value) { b.set_miny(value); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct indexed_access<mapnik::box2d<double>, max_corner, 0>
|
||||
{
|
||||
using ct = coordinate_type<mapnik::coord2d>::type;
|
||||
static inline ct get(mapnik::box2d<double> const& b) { return b.maxx();}
|
||||
static inline void set(mapnik::box2d<double> &b, ct const& value) { b.set_maxx(value); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct indexed_access<mapnik::box2d<double>, max_corner, 1>
|
||||
{
|
||||
using ct = coordinate_type<mapnik::coord2d>::type;
|
||||
static inline ct get(mapnik::box2d<double> const& b) { return b.maxy();}
|
||||
static inline void set(mapnik::box2d<double> &b , ct const& value) { b.set_maxy(value); }
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
||||
77
include/mapnik/util/boost_geometry_adapters.hpp
Normal file
77
include/mapnik/util/boost_geometry_adapters.hpp
Normal file
@ -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 <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/box.hpp>
|
||||
#include <boost/geometry/geometries/polygon.hpp>
|
||||
#include <boost/geometry/geometries/register/point.hpp>
|
||||
|
||||
BOOST_GEOMETRY_REGISTER_POINT_2D(mapnik::coord2d, double, cs::cartesian, x, y)
|
||||
|
||||
// register mapnik::box2d<double>
|
||||
namespace boost { namespace geometry { namespace traits
|
||||
{
|
||||
|
||||
template<> struct tag<mapnik::box2d<double> > { using type = box_tag; };
|
||||
|
||||
template<> struct point_type<mapnik::box2d<double> > { using type = mapnik::coord2d; };
|
||||
|
||||
template <>
|
||||
struct indexed_access<mapnik::box2d<double>, min_corner, 0>
|
||||
{
|
||||
using ct = coordinate_type<mapnik::coord2d>::type;
|
||||
static inline ct get(mapnik::box2d<double> const& b) { return b.minx();}
|
||||
static inline void set(mapnik::box2d<double> &b, ct const& value) { b.set_minx(value); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct indexed_access<mapnik::box2d<double>, min_corner, 1>
|
||||
{
|
||||
using ct = coordinate_type<mapnik::coord2d>::type;
|
||||
static inline ct get(mapnik::box2d<double> const& b) { return b.miny();}
|
||||
static inline void set(mapnik::box2d<double> &b, ct const& value) { b.set_miny(value); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct indexed_access<mapnik::box2d<double>, max_corner, 0>
|
||||
{
|
||||
using ct = coordinate_type<mapnik::coord2d>::type;
|
||||
static inline ct get(mapnik::box2d<double> const& b) { return b.maxx();}
|
||||
static inline void set(mapnik::box2d<double> &b, ct const& value) { b.set_maxx(value); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct indexed_access<mapnik::box2d<double>, max_corner, 1>
|
||||
{
|
||||
using ct = coordinate_type<mapnik::coord2d>::type;
|
||||
static inline ct get(mapnik::box2d<double> const& b) { return b.maxy();}
|
||||
static inline void set(mapnik::box2d<double> &b , ct const& value) { b.set_maxy(value); }
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
|
||||
#endif //BOOST_GEOMETRY_ADAPTERS_HPP
|
||||
@ -47,7 +47,7 @@
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/json/feature_collection_grammar.hpp>
|
||||
#include <mapnik/json/extract_bounding_box_grammar_impl.hpp>
|
||||
#include <mapnik/polygon_clipper.hpp> // boost::geometry - register box2d<double>
|
||||
#include <mapnik/util/boost_geometry_adapters.hpp> // boost.geometry - register box2d<double>
|
||||
|
||||
using mapnik::datasource;
|
||||
using mapnik::parameters;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user