1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
4 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
14 #ifndef BOOST_GEOMETRY_CORE_COORDINATE_DIMENSION_HPP
15 #define BOOST_GEOMETRY_CORE_COORDINATE_DIMENSION_HPP
20 #include <boost/mpl/assert.hpp>
21 #include <boost/static_assert.hpp>
23 #include <boost/geometry/core/point_type.hpp>
24 #include <boost/geometry/util/bare_type.hpp>
26 namespace boost { namespace geometry
33 \brief Traits class indicating the number of dimensions of a point
36 \par Specializations should provide:
37 - value (should be derived from boost::mpl::int_<D>
40 template <typename Point, typename Enable = void>
45 false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE, (types<Point>)
51 #ifndef DOXYGEN_NO_DISPATCH
52 namespace core_dispatch
55 // Base class derive from its own specialization of point-tag
56 template <typename T, typename G>
57 struct dimension : dimension<point_tag, typename point_type<T, G>::type> {};
60 struct dimension<point_tag, P>
61 : traits::dimension<typename geometry::util::bare_type<P>::type>
64 (traits::dimension<typename geometry::util::bare_type<P>::type>::value > 0),
65 INVALID_DIMENSION_VALUE,
66 (traits::dimension<typename geometry::util::bare_type<P>::type>)
70 } // namespace core_dispatch
74 \brief \brief_meta{value, number of coordinates (the number of axes of any geometry), \meta_point_type}
75 \tparam Geometry \tparam_geometry
78 \qbk{[include reference/core/coordinate_dimension.qbk]}
80 template <typename Geometry>
82 : core_dispatch::dimension
84 typename tag<Geometry>::type,
85 typename geometry::util::bare_type<Geometry>::type
90 \brief assert_dimension, enables compile-time checking if coordinate dimensions are as expected
93 template <typename Geometry, int Dimensions>
94 inline void assert_dimension()
96 BOOST_STATIC_ASSERT(( static_cast<int>(dimension<Geometry>::value) == Dimensions ));
100 \brief assert_dimension, enables compile-time checking if coordinate dimensions are as expected
103 template <typename Geometry, int Dimensions>
104 inline void assert_dimension_less_equal()
106 BOOST_STATIC_ASSERT(( static_cast<int>(dimension<Geometry>::type::value) <= Dimensions ));
109 template <typename Geometry, int Dimensions>
110 inline void assert_dimension_greater_equal()
112 BOOST_STATIC_ASSERT(( static_cast<int>(dimension<Geometry>::type::value) >= Dimensions ));
116 \brief assert_dimension_equal, enables compile-time checking if coordinate dimensions of two geometries are equal
119 template <typename G1, typename G2>
120 inline void assert_dimension_equal()
122 BOOST_STATIC_ASSERT(( static_cast<size_t>(dimension<G1>::type::value) == static_cast<size_t>(dimension<G2>::type::value) ));
125 }} // namespace boost::geometry
127 #endif // BOOST_GEOMETRY_CORE_COORDINATE_DIMENSION_HPP