interior_rings.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. // This file was modified by Oracle on 2020-2023.
  6. // Modifications copyright (c) 2020-2023, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  8. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  9. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  10. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  11. // Use, modification and distribution is subject to the Boost Software License,
  12. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #ifndef BOOST_GEOMETRY_CORE_INTERIOR_RINGS_HPP
  15. #define BOOST_GEOMETRY_CORE_INTERIOR_RINGS_HPP
  16. #include <type_traits>
  17. #include <boost/range/value_type.hpp>
  18. #include <boost/geometry/core/interior_type.hpp>
  19. #include <boost/geometry/core/static_assert.hpp>
  20. #include <boost/geometry/core/tag.hpp>
  21. #include <boost/geometry/core/tags.hpp>
  22. namespace boost { namespace geometry
  23. {
  24. namespace traits
  25. {
  26. /*!
  27. \brief Traits class defining access to interior_rings of a polygon
  28. \details defines access (const and non const) to interior ring
  29. \ingroup traits
  30. \par Geometries:
  31. - polygon
  32. \par Specializations should provide:
  33. - static inline INTERIOR& get(POLY&)
  34. - static inline const INTERIOR& get(POLY const&)
  35. \tparam Geometry geometry
  36. */
  37. template <typename Geometry>
  38. struct interior_rings
  39. {
  40. BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
  41. "Not implemented for this Geometry type.",
  42. Geometry);
  43. };
  44. } // namespace traits
  45. #ifndef DOXYGEN_NO_DISPATCH
  46. namespace core_dispatch
  47. {
  48. template
  49. <
  50. typename GeometryTag,
  51. typename Geometry
  52. >
  53. struct interior_rings {};
  54. template <typename Polygon>
  55. struct interior_rings<polygon_tag, Polygon>
  56. {
  57. static inline
  58. typename geometry::interior_return_type<Polygon>::type
  59. apply(Polygon& polygon)
  60. {
  61. return traits::interior_rings
  62. <
  63. typename std::remove_const<Polygon>::type
  64. >::get(polygon);
  65. }
  66. };
  67. template <typename MultiPolygon>
  68. struct interior_type<multi_polygon_tag, MultiPolygon>
  69. {
  70. typedef typename core_dispatch::interior_type
  71. <
  72. polygon_tag,
  73. typename boost::range_value<MultiPolygon>::type
  74. >::type type;
  75. };
  76. } // namespace core_dispatch
  77. #endif
  78. /*!
  79. \brief Function to get the interior rings of a polygon (non const version)
  80. \ingroup interior_rings
  81. \note OGC compliance: instead of InteriorRingN
  82. \tparam Polygon polygon type
  83. \param polygon the polygon to get the interior rings from
  84. \return the interior rings (possibly a reference)
  85. */
  86. template <typename Polygon>
  87. inline typename interior_return_type<Polygon>::type interior_rings(Polygon& polygon)
  88. {
  89. return core_dispatch::interior_rings
  90. <
  91. typename tag<Polygon>::type,
  92. Polygon
  93. >::apply(polygon);
  94. }
  95. /*!
  96. \brief Function to get the interior rings of a polygon (const version)
  97. \ingroup interior_rings
  98. \note OGC compliance: instead of InteriorRingN
  99. \tparam Polygon polygon type
  100. \param polygon the polygon to get the interior rings from
  101. \return the interior rings (possibly a const reference)
  102. \qbk{distinguish,const version}
  103. */
  104. template <typename Polygon>
  105. inline typename interior_return_type<Polygon const>::type interior_rings(
  106. Polygon const& polygon)
  107. {
  108. return core_dispatch::interior_rings
  109. <
  110. typename tag<Polygon>::type,
  111. Polygon const
  112. >::apply(polygon);
  113. }
  114. }} // namespace boost::geometry
  115. #endif // BOOST_GEOMETRY_CORE_INTERIOR_RINGS_HPP