envelope.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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_MULTI_ALGORITHMS_ENVELOPE_HPP
  11. #define BOOST_GEOMETRY_MULTI_ALGORITHMS_ENVELOPE_HPP
  12. #include <vector>
  13. #include <boost/range/metafunctions.hpp>
  14. #include <boost/geometry/core/exterior_ring.hpp>
  15. #include <boost/geometry/algorithms/envelope.hpp>
  16. #include <boost/geometry/multi/core/tags.hpp>
  17. #include <boost/geometry/multi/core/point_type.hpp>
  18. #include <boost/geometry/multi/geometries/concepts/check.hpp>
  19. namespace boost { namespace geometry
  20. {
  21. #ifndef DOXYGEN_NO_DETAIL
  22. namespace detail { namespace envelope
  23. {
  24. struct envelope_multi_linestring
  25. {
  26. template<typename MultiLinestring, typename Box>
  27. static inline void apply(MultiLinestring const& mp, Box& mbr)
  28. {
  29. assign_inverse(mbr);
  30. for (typename boost::range_iterator<MultiLinestring const>::type
  31. it = mp.begin();
  32. it != mp.end();
  33. ++it)
  34. {
  35. envelope_range_additional(*it, mbr);
  36. }
  37. }
  38. };
  39. // version for multi_polygon: outer ring's of all polygons
  40. struct envelope_multi_polygon
  41. {
  42. template<typename MultiPolygon, typename Box>
  43. static inline void apply(MultiPolygon const& mp, Box& mbr)
  44. {
  45. assign_inverse(mbr);
  46. for (typename boost::range_const_iterator<MultiPolygon>::type
  47. it = mp.begin();
  48. it != mp.end();
  49. ++it)
  50. {
  51. envelope_range_additional(exterior_ring(*it), mbr);
  52. }
  53. }
  54. };
  55. }} // namespace detail::envelope
  56. #endif
  57. #ifndef DOXYGEN_NO_DISPATCH
  58. namespace dispatch
  59. {
  60. template <typename Multi>
  61. struct envelope<Multi, multi_point_tag>
  62. : detail::envelope::envelope_range
  63. {};
  64. template <typename Multi>
  65. struct envelope<Multi, multi_linestring_tag>
  66. : detail::envelope::envelope_multi_linestring
  67. {};
  68. template <typename Multi>
  69. struct envelope<Multi, multi_polygon_tag>
  70. : detail::envelope::envelope_multi_polygon
  71. {};
  72. } // namespace dispatch
  73. #endif
  74. }} // namespace boost::geometry
  75. #endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_ENVELOPE_HPP