diff --git a/include/boost/geometry/core/access.hpp b/include/boost/geometry/core/access.hpp new file mode 100644 index 000000000..29f2ded57 --- /dev/null +++ b/include/boost/geometry/core/access.hpp @@ -0,0 +1,324 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_CORE_ACCESS_HPP +#define BOOST_GEOMETRY_CORE_ACCESS_HPP + + +#include + +#include +#include +#include + +#include +#include +#include + + +namespace boost { namespace geometry +{ + +/// Index of minimum corner of the box. +int const min_corner = 0; + +/// Index of maximum corner of the box. +int const max_corner = 1; + +namespace traits +{ + +/*! +\brief Traits class which gives access (get,set) to points. +\ingroup traits +\par Geometries: +/// @li point +\par Specializations should provide, per Dimension +/// @li static inline T get(G const&) +/// @li static inline void set(G&, T const&) +\tparam Geometry geometry-type +\tparam Dimension dimension to access +*/ +template +struct access +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE, (types) + ); +}; + + +/*! +\brief Traits class defining "get" and "set" to get + and set point coordinate values +\tparam Geometry geometry (box, segment) +\tparam Index index (min_corner/max_corner for box, 0/1 for segment) +\tparam Dimension dimension +\par Geometries: + - box + - segment +\par Specializations should provide: + - static inline T get(G const&) + - static inline void set(G&, T const&) +\ingroup traits +*/ +template +struct indexed_access {}; + + +} // namespace traits + + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + +template +< + typename Tag, + typename Geometry, + typename + CoordinateType, std::size_t Dimension +> +struct access +{ + //static inline T get(G const&) {} + //static inline void set(G& g, T const& value) {} +}; + +template +< + typename Tag, + typename Geometry, + typename CoordinateType, + std::size_t Index, + std::size_t Dimension +> +struct indexed_access +{ + //static inline T get(G const&) {} + //static inline void set(G& g, T const& value) {} +}; + +template +struct access +{ + static inline CoordinateType get(Point const& point) + { + return traits::access::get(point); + } + static inline void set(Point& p, CoordinateType const& value) + { + traits::access::set(p, value); + } +}; + +template +< + typename Box, + typename CoordinateType, + std::size_t Index, + std::size_t Dimension +> +struct indexed_access +{ + static inline CoordinateType get(Box const& box) + { + return traits::indexed_access::get(box); + } + static inline void set(Box& b, CoordinateType const& value) + { + traits::indexed_access::set(b, value); + } +}; + +template +< + typename Segment, + typename CoordinateType, + std::size_t Index, + std::size_t Dimension +> +struct indexed_access +{ + static inline CoordinateType get(Segment const& segment) + { + return traits::indexed_access::get(segment); + } + static inline void set(Segment& segment, CoordinateType const& value) + { + traits::indexed_access::set(segment, value); + } +}; + +} // namespace core_dispatch +#endif // DOXYGEN_NO_DISPATCH + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +// Two dummy tags to distinguish get/set variants below. +// They don't have to be specified by the user. The functions are distinguished +// by template signature also, but for e.g. GCC this is not enough. So give them +// a different signature. +struct signature_getset_dimension {}; +struct signature_getset_index_dimension {}; + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +/*! +\brief Get coordinate value of a geometry (usually a point) +\details \details_get_set +\ingroup get +\tparam Dimension \tparam_dimension_required +\tparam Geometry \tparam_geometry (usually a Point Concept) +\param geometry \param_geometry (usually a point) +\param dummy \qbk_skip +\return The coordinate value of specified dimension of specified geometry +\qbk{[include reference/core/get_point.qbk]} +*/ +template +inline typename coordinate_type::type get(Geometry const& geometry + , detail::signature_getset_dimension* dummy = 0 + ) +{ + boost::ignore_unused_variable_warning(dummy); + + typedef typename boost::remove_const::type ncg_type; + + typedef core_dispatch::access + < + typename tag::type, + ncg_type, + typename coordinate_type::type, + Dimension + > coord_access_type; + + return coord_access_type::get(geometry); +} + + +/*! +\brief Set coordinate value of a geometry (usually a point) +\details \details_get_set +\tparam Dimension \tparam_dimension_required +\tparam Geometry \tparam_geometry (usually a Point Concept) +\param geometry geometry to assign coordinate to +\param geometry \param_geometry (usually a point) +\param value The coordinate value to set +\param dummy \qbk_skip +\ingroup set + +\qbk{[include reference/core/set_point.qbk]} +*/ +template +inline void set(Geometry& geometry + , typename coordinate_type::type const& value + , detail::signature_getset_dimension* dummy = 0 + ) +{ + boost::ignore_unused_variable_warning(dummy); + + typedef typename boost::remove_const::type ncg_type; + + typedef core_dispatch::access + < + typename tag::type, + ncg_type, + typename coordinate_type::type, + Dimension + > coord_access_type; + + coord_access_type::set(geometry, value); +} + + +/*! +\brief get coordinate value of a Box or Segment +\details \details_get_set +\tparam Index \tparam_index_required +\tparam Dimension \tparam_dimension_required +\tparam Geometry \tparam_box_or_segment +\param geometry \param_geometry +\param dummy \qbk_skip +\return coordinate value +\ingroup get + +\qbk{distinguish,with index} +\qbk{[include reference/core/get_box.qbk]} +*/ +template +inline typename coordinate_type::type get(Geometry const& geometry + , detail::signature_getset_index_dimension* dummy = 0 + ) +{ + boost::ignore_unused_variable_warning(dummy); + + typedef typename boost::remove_const::type ncg_type; + + typedef core_dispatch::indexed_access + < + typename tag::type, + ncg_type, + typename coordinate_type::type, + Index, + Dimension + > coord_access_type; + + return coord_access_type::get(geometry); +} + +/*! +\brief set coordinate value of a Box / Segment +\details \details_get_set +\tparam Index \tparam_index_required +\tparam Dimension \tparam_dimension_required +\tparam Geometry \tparam_box_or_segment +\param geometry geometry to assign coordinate to +\param geometry \param_geometry +\param value The coordinate value to set +\param dummy \qbk_skip +\ingroup set + +\qbk{distinguish,with index} +\qbk{[include reference/core/set_box.qbk]} +*/ +template +inline void set(Geometry& geometry + , typename coordinate_type::type const& value + , detail::signature_getset_index_dimension* dummy = 0 + ) +{ + boost::ignore_unused_variable_warning(dummy); + + typedef typename boost::remove_const::type ncg_type; + + typedef core_dispatch::indexed_access + < + typename tag::type, ncg_type, + typename coordinate_type::type, + Index, + Dimension + > coord_access_type; + + coord_access_type::set(geometry, value); +} + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_CORE_ACCESS_HPP diff --git a/include/boost/geometry/core/closure.hpp b/include/boost/geometry/core/closure.hpp new file mode 100644 index 000000000..858ac906d --- /dev/null +++ b/include/boost/geometry/core/closure.hpp @@ -0,0 +1,175 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_CORE_CLOSURE_HPP +#define BOOST_GEOMETRY_CORE_CLOSURE_HPP + + +#include +#include +#include +#include + +#include +#include +#include + +namespace boost { namespace geometry +{ + + +/*! +\brief Enumerates options for defining if polygons are open or closed +\ingroup enum +\details The enumeration closure_selector describes options for if a polygon is + open or closed. In a closed polygon the very first point (per ring) should be + equal to the very last point. + The specific closing property of a polygon type is defined by the closure metafunction. + The closure metafunction defines a value, which is one of the values enumerated + in the closure_selector + +\qbk{ +[heading See also] +[link geometry.reference.core.closure The closure metafunction] +} +*/ +enum closure_selector +{ + open = 0, + closed = 1, + closure_undertermined = -1 +}; + +namespace traits +{ + +/*! + \brief Traits class indicating if points within a + ring or (multi)polygon are closed (last point == first point), + open or not known. + \ingroup traits + \par Geometries: + - ring + \tparam G geometry +*/ +template +struct closure +{ + static const closure_selector value = closed; +}; + + +} // namespace traits + + +#ifndef DOXYGEN_NO_DETAIL +namespace core_detail { namespace closure +{ + +struct closed +{ + static const closure_selector value = geometry::closed; +}; + + +/// Metafunction to define the minimum size of a ring: +/// 3 for open rings, 4 for closed rings +template +struct minimum_ring_size {}; + +template <> +struct minimum_ring_size : boost::mpl::int_<4> {}; + +template <> +struct minimum_ring_size : boost::mpl::int_<3> {}; + + +}} // namespace detail::point_order +#endif // DOXYGEN_NO_DETAIL + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + +template +struct closure +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE + , (types) + ); +}; + +template +struct closure : public core_detail::closure::closed {}; + +template +struct closure : public core_detail::closure::closed {}; + +template +struct closure : public core_detail::closure::closed {}; + +template +struct closure : public core_detail::closure::closed {}; + + +template +struct closure +{ + static const closure_selector value = geometry::traits::closure::value; +}; + +// Specialization for polygon: the closure is the closure of its rings +template +struct closure +{ + static const closure_selector value = core_dispatch::closure + < + ring_tag, + typename ring_type::type + >::value ; +}; + + +} // namespace core_dispatch +#endif // DOXYGEN_NO_DISPATCH + + +/*! +\brief Meta-function which defines closure of a geometry type +\ingroup core +\details + +\qbk{ +[heading See also] +[link geometry.reference.enumerations.order_selector The order_selector enumeration] +} +*/ +template +struct closure +{ + static const closure_selector value = core_dispatch::closure + < + typename tag::type, + typename boost::remove_const::type + >::value; +}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_CORE_CLOSURE_HPP diff --git a/include/boost/geometry/core/coordinate_dimension.hpp b/include/boost/geometry/core/coordinate_dimension.hpp new file mode 100644 index 000000000..8d7ebe3d0 --- /dev/null +++ b/include/boost/geometry/core/coordinate_dimension.hpp @@ -0,0 +1,124 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_CORE_COORDINATE_DIMENSION_HPP +#define BOOST_GEOMETRY_CORE_COORDINATE_DIMENSION_HPP + + +#include + +#include +#include +#include +#include + +#include +#include + +namespace boost { namespace geometry +{ + +namespace traits +{ + +/*! +\brief Traits class indicating the number of dimensions of a point +\par Geometries: + - point +\par Specializations should provide: + - value (should be derived from boost::mpl::int_ +\ingroup traits +*/ +template +struct dimension +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE, (types) + ); +}; + +} // namespace traits + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + +// Base class derive from its own specialization of point-tag +template +struct dimension : dimension::type> {}; + +template +struct dimension : traits::dimension

{}; + +} // namespace core_dispatch +#endif + +/*! + \brief Meta-function which defines coordinate dimensions, i.e. the number of axes of any geometry + \ingroup core +*/ +template +struct dimension + : core_dispatch::dimension + < + typename tag::type, + typename boost::remove_const::type + > +{}; + +/*! + \brief assert_dimension, enables compile-time checking if coordinate dimensions are as expected + \ingroup utility +*/ +template +inline void assert_dimension() +{ + BOOST_STATIC_ASSERT(( + boost::mpl::equal_to + < + geometry::dimension, + boost::mpl::int_ + >::type::value + )); +} + +/*! + \brief assert_dimension, enables compile-time checking if coordinate dimensions are as expected + \ingroup utility +*/ +template +inline void assert_dimension_less_equal() +{ + BOOST_STATIC_ASSERT(( dimension::type::value <= D )); +} + +template +inline void assert_dimension_greater_equal() +{ + BOOST_STATIC_ASSERT(( dimension::type::value >= D )); +} + +/*! + \brief assert_dimension_equal, enables compile-time checking if coordinate dimensions of two geometries are equal + \ingroup utility +*/ +template +inline void assert_dimension_equal() +{ + BOOST_STATIC_ASSERT(( dimension::type::value == dimension::type::value )); +} + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_CORE_COORDINATE_DIMENSION_HPP diff --git a/include/boost/geometry/core/coordinate_system.hpp b/include/boost/geometry/core/coordinate_system.hpp new file mode 100644 index 000000000..e3b5718a9 --- /dev/null +++ b/include/boost/geometry/core/coordinate_system.hpp @@ -0,0 +1,94 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_CORE_COORDINATE_SYSTEM_HPP +#define BOOST_GEOMETRY_CORE_COORDINATE_SYSTEM_HPP + + +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +namespace traits +{ + +/*! +\brief Traits class defining the coordinate system of a point, important for strategy selection +\ingroup traits +\par Geometries: + - point +\par Specializations should provide: + - typedef CS type; (cs::cartesian, cs::spherical, etc) +*/ +template +struct coordinate_system +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE, (types) + ); +}; + +} // namespace traits + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + template + struct coordinate_system + { + typedef typename point_type::type P; + + // Call its own specialization on point-tag + typedef typename coordinate_system::type type; + }; + + + template + struct coordinate_system + { + typedef typename traits::coordinate_system

::type type; + }; + + +} // namespace core_dispatch +#endif + + +/*! + \brief Meta-function which defines coordinate system for any geometry + \ingroup core +*/ +template +struct coordinate_system +{ + typedef typename boost::remove_const::type ncg; + typedef typename core_dispatch::coordinate_system + < + typename tag::type, + ncg + >::type type; +}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_CORE_COORDINATE_SYSTEM_HPP diff --git a/include/boost/geometry/core/coordinate_type.hpp b/include/boost/geometry/core/coordinate_type.hpp new file mode 100644 index 000000000..720ec9128 --- /dev/null +++ b/include/boost/geometry/core/coordinate_type.hpp @@ -0,0 +1,99 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_CORE_COORDINATE_TYPE_HPP +#define BOOST_GEOMETRY_CORE_COORDINATE_TYPE_HPP + + +#include +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace traits +{ + +/*! +\brief Traits class which indicate the coordinate type (double,float,...) of a point +\ingroup traits +\par Geometries: + - point +\par Specializations should provide: + - typedef T type; (double,float,int,etc) +*/ +template +struct coordinate_type +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE, (types) + ); +}; + +} // namespace traits + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + +template +struct coordinate_type +{ + typedef typename point_type::type point_type; + + // Call its own specialization on point-tag + typedef typename coordinate_type::type type; +}; + +template +struct coordinate_type +{ + typedef typename traits::coordinate_type::type type; +}; + +} // namespace core_dispatch +#endif // DOXYGEN_NO_DISPATCH + +/*! + \brief Meta-function which defines coordinate type (int, float, double, etc) of any geometry + \ingroup core +*/ +template +struct coordinate_type +{ + typedef typename core_dispatch::coordinate_type + < + typename tag::type, + typename boost::remove_const::type + >::type type; +}; + +template +struct fp_coordinate_type +{ + typedef typename promote_floating_point + < + typename coordinate_type::type + >::type type; +}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_CORE_COORDINATE_TYPE_HPP diff --git a/include/boost/geometry/core/cs.hpp b/include/boost/geometry/core/cs.hpp new file mode 100644 index 000000000..fcbad5ae2 --- /dev/null +++ b/include/boost/geometry/core/cs.hpp @@ -0,0 +1,190 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_CORE_CS_HPP +#define BOOST_GEOMETRY_CORE_CS_HPP + +#include + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +/*! +\brief Unit of plane angle: Degrees +\ingroup cs +\note Might be replaced by Boost.Units +*/ +struct degree {}; + + +/*! +\brief Unit of plane angle: Radians +\ingroup cs +\note Might be replaced by Boost.Units +*/ +struct radian {}; + + +namespace cs +{ + +/*! +\brief Cartesian coordinate system +\details Defines the Cartesian or rectangular coordinate system + where points are defined in 2 or 3 (or more) +dimensions and usually (but not always) known as x,y,z +\see http://en.wikipedia.org/wiki/Cartesian_coordinate_system +\ingroup cs +*/ +struct cartesian {}; + + + + +/*! +\brief Geographic coordinate system, in degree or in radian +\details Defines the geographic coordinate system where points + are defined in two angles and usually +known as lat,long or lo,la or phi,lambda +\see http://en.wikipedia.org/wiki/Geographic_coordinate_system +\ingroup cs +\note might be moved to extensions/gis/geographic +*/ +template +struct geographic +{ + typedef DegreeOrRadian units; +}; + + + +/*! +\brief Spherical coordinate system, in degree or in radian +\details Defines the spherical coordinate system where points are + defined in two angles + and an optional radius usually known as r, theta, phi +\par Coordinates: +- coordinate 0: + 0 <= phi < 2pi is the angle between the positive x-axis and the + line from the origin to the P projected onto the xy-plane. +- coordinate 1: + 0 <= theta <= pi is the angle between the positive z-axis and the + line formed between the origin and P. +- coordinate 2 (if specified): + r >= 0 is the distance from the origin to a given point P. + +\see http://en.wikipedia.org/wiki/Spherical_coordinates +\ingroup cs +*/ +template +struct spherical +{ + typedef DegreeOrRadian units; +}; + +/*! +\brief Polar coordinate system +\details Defines the polar coordinate system "in which each point + on a plane is determined by an angle and a distance" +\see http://en.wikipedia.org/wiki/Polar_coordinates +\ingroup cs +*/ +template +struct polar +{ + typedef DegreeOrRadian units; +}; + + +} // namespace cs + + +namespace traits +{ + +/*! +\brief Traits class defining coordinate system tag, bound to coordinate system +\ingroup traits +\tparam CoordinateSystem coordinate system +*/ +template +struct cs_tag +{ +}; + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS + +template +struct cs_tag > +{ + typedef geographic_tag type; +}; + +template +struct cs_tag > +{ + typedef spherical_tag type; +}; + +template<> +struct cs_tag +{ + typedef cartesian_tag type; +}; + + +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS +} // namespace traits + +/*! +\brief Meta-function returning coordinate system tag (cs family) of any geometry +\ingroup core +*/ +template +struct cs_tag +{ + typedef typename traits::cs_tag + < + typename geometry::coordinate_system::type + >::type type; +}; + + +/*! +\brief Meta-function to verify if a coordinate system is radian +\ingroup core +*/ +template +struct is_radian : boost::true_type {}; + + +#ifndef DOXYGEN_NO_SPECIALIZATIONS + +// Specialization for any degree coordinate systems +template class CoordinateSystem> +struct is_radian< CoordinateSystem > : boost::false_type +{ +}; + +#endif // DOXYGEN_NO_SPECIALIZATIONS + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_CORE_CS_HPP diff --git a/include/boost/geometry/core/exception.hpp b/include/boost/geometry/core/exception.hpp new file mode 100644 index 000000000..4f60e67aa --- /dev/null +++ b/include/boost/geometry/core/exception.hpp @@ -0,0 +1,34 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_CORE_EXCEPTION_HPP +#define BOOST_GEOMETRY_CORE_EXCEPTION_HPP + +#include + +namespace boost { namespace geometry +{ + +/*! +\brief Base exception class for Boost.Geometry algorithms +\ingroup core +\details This class is never thrown. All exceptions thrown in Boost.Geometry + are derived from exception, so it might be convenient to catch it. +*/ +class exception : public std::exception +{}; + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_CORE_EXCEPTION_HPP diff --git a/include/boost/geometry/core/exterior_ring.hpp b/include/boost/geometry/core/exterior_ring.hpp new file mode 100644 index 000000000..894a9000e --- /dev/null +++ b/include/boost/geometry/core/exterior_ring.hpp @@ -0,0 +1,144 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_CORE_EXTERIOR_RING_HPP +#define BOOST_GEOMETRY_CORE_EXTERIOR_RING_HPP + + +#include +#include + + +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + +namespace traits +{ + + +/*! + \brief Traits class defining access to exterior_ring of a polygon + \details Should define const and non const access + \ingroup traits + \tparam Polygon the polygon type + \par Geometries: + - polygon + \par Specializations should provide: + - static inline RING& get(POLY& ) + - static inline RING const& get(POLY const& ) +*/ +template +struct exterior_ring +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_POLYGON_TYPE + , (types) + ); +}; + + +} // namespace traits + + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + + +template +struct exterior_ring +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE + , (types) + ); +}; + + +template +struct exterior_ring +{ + static + typename geometry::ring_return_type::type + apply(typename add_const_if_c + < + boost::is_const::type::value, + Polygon + >::type& polygon) + { + return traits::exterior_ring + < + typename boost::remove_const::type + >::get(polygon); + } +}; + + +} // namespace core_dispatch +#endif // DOXYGEN_NO_DISPATCH + + +/*! + \brief Function to get the exterior_ring ring of a polygon + \ingroup exterior_ring + \note OGC compliance: instead of ExteriorRing + \tparam P polygon type + \param polygon the polygon to get the exterior ring from + \return a reference to the exterior ring +*/ +template +inline typename ring_return_type::type exterior_ring(Polygon& polygon) +{ + return core_dispatch::exterior_ring + < + typename tag::type, + Polygon + >::apply(polygon); +} + + +/*! +\brief Function to get the exterior ring of a polygon (const version) +\ingroup exterior_ring +\note OGC compliance: instead of ExteriorRing +\tparam Polygon polygon type +\param polygon the polygon to get the exterior ring from +\return a const reference to the exterior ring + +\qbk{distinguish,const version} +*/ +template +inline typename ring_return_type::type exterior_ring( + Polygon const& polygon) +{ + return core_dispatch::exterior_ring + < + typename tag::type, + Polygon const + >::apply(polygon); +} + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_CORE_EXTERIOR_RING_HPP diff --git a/include/boost/geometry/core/geometry_id.hpp b/include/boost/geometry/core/geometry_id.hpp new file mode 100644 index 000000000..873017f15 --- /dev/null +++ b/include/boost/geometry/core/geometry_id.hpp @@ -0,0 +1,94 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_CORE_GEOMETRY_ID_HPP +#define BOOST_GEOMETRY_CORE_GEOMETRY_ID_HPP + + +#include +#include +#include + + +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + +template +struct geometry_id +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE + , (types) + ); +}; + + +template <> +struct geometry_id : boost::mpl::int_<1> {}; + + +template <> +struct geometry_id : boost::mpl::int_<2> {}; + + +template <> +struct geometry_id : boost::mpl::int_<3> {}; + + +template <> +struct geometry_id : boost::mpl::int_<92> {}; + + +template <> +struct geometry_id : boost::mpl::int_<93> {}; + + +template <> +struct geometry_id : boost::mpl::int_<94> {}; + + + +} // namespace core_dispatch +#endif + + + +/*! +\brief Meta-function returning the id of a geometry type +\details The meta-function geometry_id defines a numerical ID (based on + boost::mpl::int_<...> ) for each geometry concept. A numerical ID is + sometimes useful, and within Boost.Geometry it is used for the + reverse_dispatch metafuntion. +\note Used for e.g. reverse meta-function +\ingroup core +*/ +template +struct geometry_id : core_dispatch::geometry_id::type> +{}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_CORE_GEOMETRY_ID_HPP diff --git a/include/boost/geometry/core/interior_rings.hpp b/include/boost/geometry/core/interior_rings.hpp new file mode 100644 index 000000000..cdb1305d9 --- /dev/null +++ b/include/boost/geometry/core/interior_rings.hpp @@ -0,0 +1,139 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_CORE_INTERIOR_RINGS_HPP +#define BOOST_GEOMETRY_CORE_INTERIOR_RINGS_HPP + +#include + +#include +#include +#include + +#include +#include +#include + +namespace boost { namespace geometry +{ + +namespace traits +{ + + +/*! + \brief Traits class defining access to interior_rings of a polygon + \details defines access (const and non const) to interior ring + \ingroup traits + \par Geometries: + - polygon + \par Specializations should provide: + - static inline INTERIOR& get(POLY&) + - static inline const INTERIOR& get(POLY const&) + \tparam Geometry geometry +*/ +template +struct interior_rings +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE + , (types) + ); +}; + + +} // namespace traits + + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + +template +< + typename GeometryTag, + typename Geometry +> +struct interior_rings {}; + + +template +struct interior_rings +{ + static inline + typename geometry::interior_return_type::type + apply(Polygon& polygon) + { + return traits::interior_rings + < + typename boost::remove_const::type + >::get(polygon); + } +}; + + +} // namespace core_dispatch +#endif + + + +/*! +\brief Function to get the interior rings of a polygon (non const version) +\ingroup interior_rings +\note OGC compliance: instead of InteriorRingN +\tparam Polygon polygon type +\param polygon the polygon to get the interior rings from +\return the interior rings (possibly a reference) +*/ + +template +inline typename interior_return_type::type interior_rings(Polygon& polygon) +{ + return core_dispatch::interior_rings + < + typename tag::type, + Polygon + >::apply(polygon); +} + + +/*! +\brief Function to get the interior rings of a polygon (const version) +\ingroup interior_rings +\note OGC compliance: instead of InteriorRingN +\tparam Polygon polygon type +\param polygon the polygon to get the interior rings from +\return the interior rings (possibly a const reference) + +\qbk{distinguish,const version} +*/ +template +inline typename interior_return_type::type interior_rings( + Polygon const& polygon) +{ + return core_dispatch::interior_rings + < + typename tag::type, + Polygon const + >::apply(polygon); +} + + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_CORE_INTERIOR_RINGS_HPP diff --git a/include/boost/geometry/core/interior_type.hpp b/include/boost/geometry/core/interior_type.hpp new file mode 100644 index 000000000..0b3aa5057 --- /dev/null +++ b/include/boost/geometry/core/interior_type.hpp @@ -0,0 +1,158 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_CORE_INTERIOR_TYPE_HPP +#define BOOST_GEOMETRY_CORE_INTERIOR_TYPE_HPP + + +#include +#include + +#include +#include + +namespace boost { namespace geometry +{ + +namespace traits +{ + +/*! +\brief Traits class indicating interior container type of a polygon +\details defines inner container type, so the container containing + the interior rings +\ingroup traits +\par Geometries: + - polygon +\par Specializations should provide: + - typedef X type ( e.g. std::vector<myring<P>> ) +\tparam Geometry geometry +*/ +template +struct interior_const_type +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE + , (types) + ); +}; + +template +struct interior_mutable_type +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE + , (types) + ); +}; + + +} // namespace traits + + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + + +template +struct interior_return_type +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE + , (types) + ); +}; + + +template +struct interior_return_type +{ + typedef typename boost::remove_const::type nc_polygon_type; + + typedef typename mpl::if_ + < + boost::is_const, + typename traits::interior_const_type::type, + typename traits::interior_mutable_type::type + >::type type; +}; + + + + +template +struct interior_type +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE + , (types) + ); +}; + + +template +struct interior_type +{ + typedef typename boost::remove_reference + < + typename interior_return_type::type + > type; +}; + + +} // namespace core_dispatch +#endif + + +/*! + \brief Meta-function defining container type + of inner rings of (multi)polygon geometriy + \details the interior rings should be organized as a container + (std::vector, std::deque, boost::array) with + boost range support. This meta function defines the type + of that container. + \ingroup core +*/ +template +struct interior_type +{ + typedef typename core_dispatch::interior_type + < + typename tag::type, + Geometry + >::type type; +}; + +template +struct interior_return_type +{ + typedef typename core_dispatch::interior_return_type + < + typename tag::type, + Geometry + >::type type; +}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_CORE_INTERIOR_TYPE_HPP diff --git a/include/boost/geometry/core/is_areal.hpp b/include/boost/geometry/core/is_areal.hpp new file mode 100644 index 000000000..3fe2185ca --- /dev/null +++ b/include/boost/geometry/core/is_areal.hpp @@ -0,0 +1,60 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_CORE_IS_AREAL_HPP +#define BOOST_GEOMETRY_CORE_IS_AREAL_HPP + + +#include + + +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + +template struct is_areal : boost::false_type {}; + +template <> struct is_areal : boost::true_type {}; +template <> struct is_areal : boost::true_type {}; +template <> struct is_areal : boost::true_type {}; + + +} // namespace core_dispatch +#endif + + + +/*! + \brief Meta-function defining "true" for areal types (box, (multi)polygon, ring), + \note Used for tag dispatching and meta-function finetuning + \note Also a "ring" has areal properties within Boost.Geometry + \ingroup core +*/ +template +struct is_areal : core_dispatch::is_areal::type> +{}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_CORE_IS_AREAL_HPP diff --git a/include/boost/geometry/core/mutable_range.hpp b/include/boost/geometry/core/mutable_range.hpp new file mode 100644 index 000000000..04bc6c192 --- /dev/null +++ b/include/boost/geometry/core/mutable_range.hpp @@ -0,0 +1,98 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_CORE_MUTABLE_RANGE_HPP +#define BOOST_GEOMETRY_CORE_MUTABLE_RANGE_HPP + + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + + +namespace traits +{ + +/*! +\brief Metafunction to define the argument passed to the three + traits classes clear, push_back and resize +\ingroup mutable_range + */ +template +struct rvalue_type +{ + typedef typename boost::remove_reference::type& type; +}; + + +/*! +\brief Traits class to clear a geometry +\ingroup mutable_range + */ +template +struct clear +{ + static inline void apply(typename rvalue_type::type range) + { + range.clear(); + } +}; + + +/*! +\brief Traits class to append a point to a range (ring, linestring, multi*) +\ingroup mutable_range + */ +template +struct push_back +{ + typedef typename boost::range_value + < + typename boost::remove_reference::type + >::type item_type; + + static inline void apply(typename rvalue_type::type range, + item_type const& item) + { + range.push_back(item); + } +}; + + +/*! +\brief Traits class to append a point to a range (ring, linestring, multi*) +\ingroup mutable_range + */ +template +struct resize +{ + static inline void apply(typename rvalue_type::type range, + std::size_t new_size) + { + range.resize(new_size); + } +}; + + +} // namespace traits + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_CORE_MUTABLE_RANGE_HPP diff --git a/include/boost/geometry/core/point_order.hpp b/include/boost/geometry/core/point_order.hpp new file mode 100644 index 000000000..7dd55634b --- /dev/null +++ b/include/boost/geometry/core/point_order.hpp @@ -0,0 +1,163 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_CORE_POINT_ORDER_HPP +#define BOOST_GEOMETRY_CORE_POINT_ORDER_HPP + + +#include +#include +#include + +#include +#include +#include + +namespace boost { namespace geometry +{ + +/*! +\brief Enumerates options for the order of points within polygons +\ingroup enum +\details The enumeration order_selector describes options for the order of points + within a polygon. Polygons can be ordered either clockwise or counterclockwise. + The specific order of a polygon type is defined by the point_order metafunction. + The point_order metafunction defines a value, which is one of the values enumerated + in the order_selector + +\qbk{ +[heading See also] +[link geometry.reference.core.point_order The point_order metafunction] +} +*/ +enum order_selector +{ + /// Points are ordered clockwise + clockwise = 1, + /// Points are ordered counter clockwise + counterclockwise = 2, + /// Points might be stored in any order, the algorithm will find out (not yet supported) + order_undetermined = 0 +}; + +namespace traits +{ + +/*! +\brief Traits class indicating the order of contained points within a + ring or (multi)polygon, clockwise, counter clockwise or not known. +\ingroup traits +\tparam Ring ring +*/ +template +struct point_order +{ + static const order_selector value = clockwise; +}; + + +} // namespace traits + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace point_order +{ + +struct clockwise +{ + static const order_selector value = geometry::clockwise; +}; + + +}} // namespace detail::point_order +#endif // DOXYGEN_NO_DETAIL + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + +template +struct point_order +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE + , (types) + ); +}; + +template +struct point_order + : public detail::point_order::clockwise {}; + +template +struct point_order + : public detail::point_order::clockwise {}; + + +template +struct point_order + : public detail::point_order::clockwise {}; + +template +struct point_order + : public detail::point_order::clockwise {}; + + +template +struct point_order +{ + static const order_selector value = geometry::traits::point_order::value; +}; + +// Specialization for polygon: the order is the order of its rings +template +struct point_order +{ + static const order_selector value = core_dispatch::point_order + < + ring_tag, + typename ring_type::type + >::value ; +}; + +} // namespace core_dispatch +#endif // DOXYGEN_NO_DISPATCH + + +/*! +\brief Metafunction which defines point order of a geometry type +\ingroup core +\details + +\qbk{ +[heading See also] +[link geometry.reference.enumerations.closure_selector The closure_selector enumeration] +} +*/ +template +struct point_order +{ + /// metafunction implementation + static const order_selector value = core_dispatch::point_order + < + typename tag::type, + typename boost::remove_const::type + >::value; +}; + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_CORE_POINT_ORDER_HPP diff --git a/include/boost/geometry/core/point_type.hpp b/include/boost/geometry/core/point_type.hpp new file mode 100644 index 000000000..efaaead92 --- /dev/null +++ b/include/boost/geometry/core/point_type.hpp @@ -0,0 +1,127 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_CORE_POINT_TYPE_HPP +#define BOOST_GEOMETRY_CORE_POINT_TYPE_HPP + + +#include +#include +#include + +#include +#include +#include + +namespace boost { namespace geometry +{ + +namespace traits +{ + +/*! +\brief Traits class indicating the type of contained points +\ingroup traits +\par Geometries: + - all geometries except point +\par Specializations should provide: + - typedef P type (where P should fulfil the Point concept) +\tparam Geometry geometry +*/ +template +struct point_type +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE, (types) + ); +}; + + +} // namespace traits + + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + +template +struct point_type +{ + // Default: call traits to get point type + typedef typename boost::remove_const + < + typename traits::point_type::type + >::type type; +}; + + +// Specialization for point: the point itself +template +struct point_type +{ + typedef Point type; +}; + + +// Specializations for linestring/ring, via boost::range +template +struct point_type +{ + typedef typename boost::range_value::type type; +}; + + +template +struct point_type +{ + typedef typename boost::range_value::type type; +}; + + +// Specialization for polygon: the point-type is the point-type of its rings +template +struct point_type +{ + typedef typename point_type + < + ring_tag, + typename ring_type::type + >::type type; +}; + + +} // namespace core_dispatch +#endif // DOXYGEN_NO_DISPATCH + + +/*! + \brief Meta-function which defines point type of any geometry + \ingroup core +*/ +template +struct point_type +{ + typedef typename boost::remove_const::type ncg; + typedef typename core_dispatch::point_type + < + typename tag::type, + ncg + >::type type; +}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_CORE_POINT_TYPE_HPP diff --git a/include/boost/geometry/core/radian_access.hpp b/include/boost/geometry/core/radian_access.hpp new file mode 100644 index 000000000..37556e226 --- /dev/null +++ b/include/boost/geometry/core/radian_access.hpp @@ -0,0 +1,152 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_CORE_RADIAN_ACCESS_HPP +#define BOOST_GEOMETRY_CORE_RADIAN_ACCESS_HPP + + +#include + +#include + +#include +#include +#include + + +#include + + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +template +struct degree_radian_converter +{ + typedef typename fp_coordinate_type::type coordinate_type; + + static inline coordinate_type get(Geometry const& geometry) + { + return boost::numeric_cast + < + coordinate_type + >(geometry::get(geometry) * geometry::math::d2r); + } + + static inline void set(Geometry& geometry, coordinate_type const& radians) + { + geometry::set(geometry, boost::numeric_cast + < + coordinate_type + >(radians * geometry::math::r2d)); + } + +}; + + +// Default, radian (or any other coordinate system) just works like "get" +template +struct radian_access +{ + typedef typename fp_coordinate_type::type coordinate_type; + + static inline coordinate_type get(Geometry const& geometry) + { + return geometry::get(geometry); + } + + static inline void set(Geometry& geometry, coordinate_type const& radians) + { + geometry::set(geometry, radians); + } +}; + +// Specialize, any "degree" coordinate system will convert to radian +// but only for dimension 0,1 (so: dimension 2 and heigher are untouched) + +template +< + typename Geometry, + template class CoordinateSystem +> +struct radian_access<0, Geometry, CoordinateSystem > + : degree_radian_converter<0, Geometry> +{}; + + +template +< + typename Geometry, + template class CoordinateSystem +> +struct radian_access<1, Geometry, CoordinateSystem > + : degree_radian_converter<1, Geometry> +{}; + + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +/*! +\brief get coordinate value of a point, result is in Radian +\details Result is in Radian, even if source coordinate system + is in Degrees +\return coordinate value +\ingroup get +\tparam Dimension dimension +\tparam Geometry geometry +\param geometry geometry to get coordinate value from +\note Only applicable to coordinate systems templatized by units, + e.g. spherical or geographic coordinate systems +*/ +template +inline typename fp_coordinate_type::type get_as_radian(Geometry const& geometry) +{ + return detail::radian_access::type>::get(geometry); +} + + +/*! +\brief set coordinate value (in radian) to a point +\details Coordinate value will be set correctly, if coordinate system of + point is in Degree, Radian value will be converted to Degree +\ingroup set +\tparam Dimension dimension +\tparam Geometry geometry +\param geometry geometry to assign coordinate to +\param radians coordinate value to assign +\note Only applicable to coordinate systems templatized by units, + e.g. spherical or geographic coordinate systems +*/ +template +inline void set_from_radian(Geometry& geometry, + typename fp_coordinate_type::type const& radians) +{ + detail::radian_access::type>::set(geometry, radians); +} + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_CORE_RADIAN_ACCESS_HPP diff --git a/include/boost/geometry/core/reverse_dispatch.hpp b/include/boost/geometry/core/reverse_dispatch.hpp new file mode 100644 index 000000000..668fb1649 --- /dev/null +++ b/include/boost/geometry/core/reverse_dispatch.hpp @@ -0,0 +1,67 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_CORE_REVERSE_DISPATCH_HPP +#define BOOST_GEOMETRY_CORE_REVERSE_DISPATCH_HPP + + +#include + +#include +#include +#include + +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +// Different geometries: reverse_dispatch if second ID < first ID +template +struct reverse_dispatch : boost::mpl::if_c + < + (GeometryId1 > GeometryId2), + boost::true_type, + boost::false_type + > +{}; + + +// Same geometry: never reverse_dispatch +template +struct reverse_dispatch : boost::false_type {}; + + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +template +struct reverse_dispatch : detail::reverse_dispatch + < + geometry_id::type::value, + geometry_id::type::value + > +{}; + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_CORE_REVERSE_DISPATCH_HPP diff --git a/include/boost/geometry/core/ring_type.hpp b/include/boost/geometry/core/ring_type.hpp new file mode 100644 index 000000000..cf79fc65e --- /dev/null +++ b/include/boost/geometry/core/ring_type.hpp @@ -0,0 +1,167 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_CORE_RING_TYPE_HPP +#define BOOST_GEOMETRY_CORE_RING_TYPE_HPP + + +#include +#include +#include + + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace traits +{ + + +/*! +\brief Traits class to indicate ring-type of a polygon's exterior ring/interior rings +\ingroup traits +\par Geometries: + - polygon +\par Specializations should provide: + - typedef XXX type ( e.g. ring

) +\tparam Geometry geometry +*/ +template +struct ring_const_type +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE + , (types) + ); +}; + +template +struct ring_mutable_type +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE + , (types) + ); +}; + + +} // namespace traits + + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + +template +struct ring_return_type +{}; + + +template +struct ring_return_type +{ + typedef LineString& type; +}; + + +template +struct ring_return_type +{ + typedef Ring& type; +}; + + +template +struct ring_return_type +{ + typedef typename boost::remove_const::type nc_polygon_type; + + typedef typename mpl::if_ + < + boost::is_const, + typename traits::ring_const_type::type, + typename traits::ring_mutable_type::type + >::type type; +}; + + +template +struct ring_type +{}; + + +template +struct ring_type +{ + typedef Ring type; +}; + + +template +struct ring_type +{ + typedef typename boost::remove_reference + < + typename ring_return_type::type + >::type type; +}; + + + + + +} // namespace core_dispatch +#endif + + +/*! +\brief Meta-function which defines ring type of (multi)polygon geometry +\details a polygon contains one exterior ring + and zero or more interior rings (holes). + This meta function retrieves the type of the rings +\note Exterior ring and interior rings must have the same ring-type. +\ingroup core +*/ +template +struct ring_type +{ + typedef typename core_dispatch::ring_type + < + typename tag::type, + Geometry + >::type type; +}; + + +template +struct ring_return_type +{ + typedef typename core_dispatch::ring_return_type + < + typename tag::type, + Geometry + >::type type; +}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_CORE_RING_TYPE_HPP diff --git a/include/boost/geometry/core/tag.hpp b/include/boost/geometry/core/tag.hpp new file mode 100644 index 000000000..702ab3ec1 --- /dev/null +++ b/include/boost/geometry/core/tag.hpp @@ -0,0 +1,68 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_CORE_TAG_HPP +#define BOOST_GEOMETRY_CORE_TAG_HPP + + +#include +#include + +#include + + +namespace boost { namespace geometry +{ + +namespace traits +{ + +/*! +\brief Traits class to attach a tag to a geometry +\details All geometries should implement a traits::tag::type metafunction to indicate their + own geometry type. +\ingroup traits +\par Geometries: + - all geometries +\par Specializations should provide: + - typedef XXX_tag type; (point_tag, box_tag, ...) +\tparam Geometry geometry +*/ +template +struct tag +{ + typedef void type; +}; + +} // namespace traits + + +/*! +\brief Meta-function to get the tag of any geometry type +\details All geometries tell their geometry type (point, linestring, polygon, etc) by implementing + a tag traits class. This meta-function uses that traits class to retrieve the tag. +\tparam Geometry geometry +\ingroup core +*/ +template +struct tag +{ + typedef typename traits::tag + < + typename boost::remove_const::type + >::type type; +}; + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_CORE_TAG_HPP diff --git a/include/boost/geometry/core/tag_cast.hpp b/include/boost/geometry/core/tag_cast.hpp new file mode 100644 index 000000000..1318f265f --- /dev/null +++ b/include/boost/geometry/core/tag_cast.hpp @@ -0,0 +1,62 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_CORE_TAG_CAST_HPP +#define BOOST_GEOMETRY_CORE_TAG_CAST_HPP + + +#include +#include + +namespace boost { namespace geometry +{ + +/// Generic tag_cast utility +template +< + typename Tag, + typename BaseTag, + typename BaseTag2 = void, + typename BaseTag3 = void, + typename BaseTag4 = void, + typename BaseTag5 = void, + typename BaseTag6 = void, + typename BaseTag7 = void +> +struct tag_cast +{ + typedef typename boost::mpl::if_ + < + typename boost::is_base_of::type, + BaseTag, + // Try next one in line: + typename tag_cast + < + Tag, BaseTag2, BaseTag3, BaseTag4, + BaseTag5, BaseTag6, BaseTag7, void + >::type + >::type type; +}; + +// Specialization for last one +template +struct tag_cast +{ + // If not found, take specified tag, so do not cast + typedef Tag type; +}; + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_CORE_TAG_CAST_HPP diff --git a/include/boost/geometry/core/tags.hpp b/include/boost/geometry/core/tags.hpp new file mode 100644 index 000000000..6469b6c11 --- /dev/null +++ b/include/boost/geometry/core/tags.hpp @@ -0,0 +1,84 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_CORE_TAGS_HPP +#define BOOST_GEOMETRY_CORE_TAGS_HPP + + +namespace boost { namespace geometry +{ + +// Tags defining strategies linked to coordinate systems + + +/// Tag indicating Cartesian coordinate system family (cartesian,epsg) +struct cartesian_tag {}; + +/// Tag indicating Geographic coordinate system family (geographic) +struct geographic_tag {}; + +/// Tag indicating Spherical coordinate system family (spherical,celestial,...) +struct spherical_tag {}; + + +// Tags defining tag hierarchy + +/// For single-geometries (point, linestring, polygon, box, ring, segment) +struct single_tag {}; + + +/// For multiple-geometries (multi_point, multi_linestring, multi_polygon) +struct multi_tag {}; + +/// For point-like types (point, multi_point) +struct pointlike_tag {}; + +/// For linear types (linestring, multi-linestring, segment) +struct linear_tag {}; + +/// For areal types (polygon, multi_polygon, box, ring) +struct areal_tag {}; + +/// For volume types (also box (?), polyhedron) +struct volumetric_tag {}; + + +// Tags defining geometry types + + +/// "default" tag +struct geometry_not_recognized_tag {}; + +/// OGC Point identifying tag +struct point_tag : single_tag, pointlike_tag {}; + +/// OGC Linestring identifying tag +struct linestring_tag : single_tag, linear_tag {}; + +/// OGC Polygon identifying tag +struct polygon_tag : single_tag, areal_tag {}; + +/// Convenience (linear) ring identifying tag +struct ring_tag : single_tag, areal_tag {}; + +/// Convenience 2D or 3D box (mbr / aabb) identifying tag +struct box_tag : single_tag, areal_tag {}; + +/// Convenience segment (2-points) identifying tag +struct segment_tag : single_tag, linear_tag {}; + + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_CORE_TAGS_HPP diff --git a/include/boost/geometry/core/topological_dimension.hpp b/include/boost/geometry/core/topological_dimension.hpp new file mode 100644 index 000000000..05ad405a8 --- /dev/null +++ b/include/boost/geometry/core/topological_dimension.hpp @@ -0,0 +1,88 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_CORE_TOPOLOGICAL_DIMENSION_HPP +#define BOOST_GEOMETRY_CORE_TOPOLOGICAL_DIMENSION_HPP + + +#include + + +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DISPATCH +namespace core_dispatch +{ + + +template +struct top_dim {}; + + +template <> +struct top_dim : boost::mpl::int_<0> {}; + + +template <> +struct top_dim : boost::mpl::int_<1> {}; + + +template <> +struct top_dim : boost::mpl::int_<1> {}; + + +// ring: topological dimension of two, but some people say: 1 !! +template <> +struct top_dim : boost::mpl::int_<2> {}; + + +template <> +struct top_dim : boost::mpl::int_<2> {}; + + +template <> +struct top_dim : boost::mpl::int_<2> {}; + + + +} // namespace core_dispatch +#endif + + + + + +/*! + \brief Meta-function returning the topological dimension of a geometry + \details The topological dimension defines a point as 0-dimensional, + a linestring as 1-dimensional, + and a ring or polygon as 2-dimensional. + \see http://www.math.okstate.edu/mathdept/dynamics/lecnotes/node36.html + \ingroup core +*/ +template +struct topological_dimension + : core_dispatch::top_dim::type> {}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_CORE_TOPOLOGICAL_DIMENSION_HPP