1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2010 Alfredo Correa
4 // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_HPP
11 #define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_HPP
14 #ifdef BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_TAG_DEFINED
15 #error Include either "boost_array_as_point" or \
16 "boost_array_as_linestring" or "boost_array_as_ring" \
17 or "boost_array_as_multi_point" to adapt a boost_array
20 #define BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_TAG_DEFINED
25 #include <boost/type_traits/is_arithmetic.hpp>
27 #include <boost/geometry/core/access.hpp>
28 #include <boost/geometry/core/cs.hpp>
29 #include <boost/geometry/core/coordinate_dimension.hpp>
30 #include <boost/geometry/core/coordinate_type.hpp>
31 #include <boost/geometry/core/tags.hpp>
33 #include <boost/array.hpp>
35 namespace boost { namespace geometry
39 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
44 #ifndef DOXYGEN_NO_DETAIL
49 // Create class and specialization to indicate the tag
50 // for normal cases and the case that the type of the c-array is arithmetic
52 struct boost_array_tag
54 typedef geometry_not_recognized_tag type;
59 struct boost_array_tag<true>
61 typedef point_tag type;
66 #endif // DOXYGEN_NO_DETAIL
69 // Assign the point-tag, preventing arrays of points getting a point-tag
70 template <typename CoordinateType, std::size_t DimensionCount>
71 struct tag<boost::array<CoordinateType, DimensionCount> >
72 : detail::boost_array_tag<boost::is_arithmetic<CoordinateType>::value> {};
75 template <typename CoordinateType, std::size_t DimensionCount>
76 struct coordinate_type<boost::array<CoordinateType, DimensionCount> >
78 typedef CoordinateType type;
82 template <typename CoordinateType, std::size_t DimensionCount>
83 struct dimension<boost::array<CoordinateType, DimensionCount> >: boost::mpl::int_<DimensionCount> {};
86 template <typename CoordinateType, std::size_t DimensionCount, std::size_t Dimension>
87 struct access<boost::array<CoordinateType, DimensionCount>, Dimension>
89 static inline CoordinateType get(boost::array<CoordinateType, DimensionCount> const& a)
94 static inline void set(boost::array<CoordinateType, DimensionCount>& a,
95 CoordinateType const& value)
102 } // namespace traits
103 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
106 }} // namespace boost::geometry
109 #define BOOST_GEOMETRY_REGISTER_BOOST_ARRAY_CS(CoordinateSystem) \
110 namespace boost { namespace geometry { namespace traits { \
111 template <class T, std::size_t N> \
112 struct coordinate_system<boost::array<T, N> > \
114 typedef CoordinateSystem type; \
119 #endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_HPP