areal.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Boost.Geometry
  2. // Copyright (c) 2018 Oracle and/or its affiliates.
  3. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  4. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  5. // Use, modification and distribution is subject to the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_AREAL_HPP
  9. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_AREAL_HPP
  10. #include <boost/geometry/core/cs.hpp>
  11. #include <boost/geometry/core/tags.hpp>
  12. #include <boost/geometry/iterators/segment_iterator.hpp>
  13. #include <boost/geometry/algorithms/detail/envelope/range.hpp>
  14. #include <boost/geometry/algorithms/detail/envelope/linear.hpp>
  15. #include <boost/geometry/algorithms/dispatch/envelope.hpp>
  16. namespace boost { namespace geometry
  17. {
  18. #ifndef DOXYGEN_NO_DETAIL
  19. namespace detail { namespace envelope
  20. {
  21. struct envelope_polygon
  22. {
  23. template <typename Polygon, typename Box, typename Strategy>
  24. static inline void apply(Polygon const& polygon, Box& mbr, Strategy const& strategy)
  25. {
  26. typename ring_return_type<Polygon const>::type ext_ring
  27. = exterior_ring(polygon);
  28. if (geometry::is_empty(ext_ring))
  29. {
  30. // if the exterior ring is empty, consider the interior rings
  31. envelope_multi_range
  32. <
  33. envelope_range
  34. >::apply(interior_rings(polygon), mbr, strategy);
  35. }
  36. else
  37. {
  38. // otherwise, consider only the exterior ring
  39. envelope_range::apply(ext_ring, mbr, strategy);
  40. }
  41. }
  42. };
  43. }} // namespace detail::envelope
  44. #endif // DOXYGEN_NO_DETAIL
  45. #ifndef DOXYGEN_NO_DISPATCH
  46. namespace dispatch
  47. {
  48. template <typename Ring>
  49. struct envelope<Ring, ring_tag>
  50. : detail::envelope::envelope_range
  51. {};
  52. template <typename Polygon>
  53. struct envelope<Polygon, polygon_tag>
  54. : detail::envelope::envelope_polygon
  55. {};
  56. template <typename MultiPolygon>
  57. struct envelope<MultiPolygon, multi_polygon_tag>
  58. : detail::envelope::envelope_multi_range
  59. <
  60. detail::envelope::envelope_polygon
  61. >
  62. {};
  63. } // namespace dispatch
  64. #endif // DOXYGEN_NO_DISPATCH
  65. }} // namespace boost::geometry
  66. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_AREAL_HPP