range_type.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  6. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_GEOMETRY_VIEWS_DETAIL_RANGE_TYPE_HPP
  11. #define BOOST_GEOMETRY_VIEWS_DETAIL_RANGE_TYPE_HPP
  12. #include <boost/mpl/assert.hpp>
  13. #include <boost/range/value_type.hpp>
  14. #include <boost/geometry/core/ring_type.hpp>
  15. #include <boost/geometry/core/tag.hpp>
  16. #include <boost/geometry/core/tags.hpp>
  17. #include <boost/geometry/views/box_view.hpp>
  18. namespace boost { namespace geometry
  19. {
  20. #ifndef DOXYGEN_NO_DISPATCH
  21. namespace dispatch
  22. {
  23. template <typename Geometry,
  24. typename Tag = typename tag<Geometry>::type>
  25. struct range_type
  26. {
  27. BOOST_MPL_ASSERT_MSG
  28. (
  29. false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
  30. , (types<Geometry>)
  31. );
  32. };
  33. template <typename Geometry>
  34. struct range_type<Geometry, ring_tag>
  35. {
  36. typedef Geometry type;
  37. };
  38. template <typename Geometry>
  39. struct range_type<Geometry, linestring_tag>
  40. {
  41. typedef Geometry type;
  42. };
  43. template <typename Geometry>
  44. struct range_type<Geometry, polygon_tag>
  45. {
  46. typedef typename ring_type<Geometry>::type type;
  47. };
  48. template <typename Geometry>
  49. struct range_type<Geometry, box_tag>
  50. {
  51. typedef box_view<Geometry> type;
  52. };
  53. // multi-point acts itself as a range
  54. template <typename Geometry>
  55. struct range_type<Geometry, multi_point_tag>
  56. {
  57. typedef Geometry type;
  58. };
  59. template <typename Geometry>
  60. struct range_type<Geometry, multi_linestring_tag>
  61. {
  62. typedef typename boost::range_value<Geometry>::type type;
  63. };
  64. template <typename Geometry>
  65. struct range_type<Geometry, multi_polygon_tag>
  66. {
  67. // Call its single-version
  68. typedef typename dispatch::range_type
  69. <
  70. typename boost::range_value<Geometry>::type
  71. >::type type;
  72. };
  73. } // namespace dispatch
  74. #endif // DOXYGEN_NO_DISPATCH
  75. // Will probably be replaced by the more generic "view_as", therefore in detail
  76. namespace detail
  77. {
  78. /*!
  79. \brief Meta-function defining a type which is a boost-range.
  80. \details
  81. - For linestrings and rings, it defines the type itself.
  82. - For polygons it defines the ring type.
  83. - For multi-points, it defines the type itself
  84. - For multi-polygons and multi-linestrings, it defines the single-version
  85. (so in the end the linestring and ring-type-of-multi-polygon)
  86. \ingroup iterators
  87. */
  88. template <typename Geometry>
  89. struct range_type
  90. {
  91. typedef typename dispatch::range_type
  92. <
  93. Geometry
  94. >::type type;
  95. };
  96. }
  97. }} // namespace boost::geometry
  98. #endif // BOOST_GEOMETRY_VIEWS_DETAIL_RANGE_TYPE_HPP