1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. 4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. 5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. 6 7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library 8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. 9 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) 13 14 #ifndef BOOST_GEOMETRY_VIEWS_DETAIL_RANGE_TYPE_HPP 15 #define BOOST_GEOMETRY_VIEWS_DETAIL_RANGE_TYPE_HPP 16 17 18 #include <boost/mpl/assert.hpp> 19 #include <boost/range/value_type.hpp> 20 21 #include <boost/geometry/core/ring_type.hpp> 22 #include <boost/geometry/core/tag.hpp> 23 #include <boost/geometry/core/tags.hpp> 24 25 #include <boost/geometry/views/box_view.hpp> 26 27 namespace boost { namespace geometry 28 { 29 30 31 #ifndef DOXYGEN_NO_DISPATCH 32 namespace dispatch 33 { 34 35 36 template <typename Geometry, 37 typename Tag = typename tag<Geometry>::type> 38 struct range_type 39 { 40 BOOST_MPL_ASSERT_MSG 41 ( 42 false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE 43 , (types<Geometry>) 44 ); 45 }; 46 47 48 template <typename Geometry> 49 struct range_type<Geometry, ring_tag> 50 { 51 typedef Geometry type; 52 }; 53 54 55 template <typename Geometry> 56 struct range_type<Geometry, linestring_tag> 57 { 58 typedef Geometry type; 59 }; 60 61 62 template <typename Geometry> 63 struct range_type<Geometry, polygon_tag> 64 { 65 typedef typename ring_type<Geometry>::type type; 66 }; 67 68 69 template <typename Geometry> 70 struct range_type<Geometry, box_tag> 71 { 72 typedef box_view<Geometry> type; 73 }; 74 75 76 // multi-point acts itself as a range 77 template <typename Geometry> 78 struct range_type<Geometry, multi_point_tag> 79 { 80 typedef Geometry type; 81 }; 82 83 84 template <typename Geometry> 85 struct range_type<Geometry, multi_linestring_tag> 86 { 87 typedef typename boost::range_value<Geometry>::type type; 88 }; 89 90 91 template <typename Geometry> 92 struct range_type<Geometry, multi_polygon_tag> 93 { 94 // Call its single-version 95 typedef typename dispatch::range_type 96 < 97 typename boost::range_value<Geometry>::type 98 >::type type; 99 }; 100 101 102 } // namespace dispatch 103 #endif // DOXYGEN_NO_DISPATCH 104 105 // Will probably be replaced by the more generic "view_as", therefore in detail 106 namespace detail 107 { 108 109 110 /*! 111 \brief Meta-function defining a type which is a boost-range. 112 \details 113 - For linestrings and rings, it defines the type itself. 114 - For polygons it defines the ring type. 115 - For multi-points, it defines the type itself 116 - For multi-polygons and multi-linestrings, it defines the single-version 117 (so in the end the linestring and ring-type-of-multi-polygon) 118 \ingroup iterators 119 */ 120 template <typename Geometry> 121 struct range_type 122 { 123 typedef typename dispatch::range_type 124 < 125 Geometry 126 >::type type; 127 }; 128 129 } 130 131 }} // namespace boost::geometry 132 133 134 #endif // BOOST_GEOMETRY_VIEWS_DETAIL_RANGE_TYPE_HPP 135