envelope.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
  5. // This file was modified by Oracle on 2015, 2016, 2018, 2019.
  6. // Modifications copyright (c) 2015-2019, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  8. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  9. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  10. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  11. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  12. // Distributed under the Boost Software License, Version 1.0.
  13. // (See accompanying file LICENSE_1_0.txt or copy at
  14. // http://www.boost.org/LICENSE_1_0.txt)
  15. #ifndef BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_HPP
  16. #define BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_HPP
  17. #include <boost/geometry/algorithms/detail/envelope/initialize.hpp>
  18. #include <boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp>
  19. #include <boost/geometry/iterators/segment_iterator.hpp>
  20. #include <boost/geometry/strategy/spherical/envelope_box.hpp>
  21. #include <boost/geometry/strategy/spherical/envelope_segment.hpp>
  22. #include <boost/geometry/strategy/spherical/expand_box.hpp>
  23. #include <boost/geometry/strategy/spherical/expand_segment.hpp>
  24. namespace boost { namespace geometry
  25. {
  26. namespace strategy { namespace envelope
  27. {
  28. template <typename CalculationType = void>
  29. class spherical
  30. {
  31. public:
  32. typedef spherical_tag cs_tag;
  33. // Linestring, Ring, Polygon
  34. template <typename Range>
  35. static inline geometry::segment_iterator<Range const> begin(Range const& range)
  36. {
  37. return geometry::segments_begin(range);
  38. }
  39. template <typename Range>
  40. static inline geometry::segment_iterator<Range const> end(Range const& range)
  41. {
  42. return geometry::segments_end(range);
  43. }
  44. // MultiLinestring, MultiPolygon
  45. template <typename Box>
  46. struct multi_state
  47. {
  48. void apply(Box const& single_box)
  49. {
  50. m_boxes.push_back(single_box);
  51. }
  52. void result(Box & box)
  53. {
  54. if (!m_boxes.empty())
  55. {
  56. geometry::detail::envelope::envelope_range_of_boxes::apply(m_boxes, box);
  57. }
  58. else
  59. {
  60. geometry::detail::envelope::initialize<Box, 0, dimension<Box>::value>::apply(box);
  61. }
  62. }
  63. private:
  64. std::vector<Box> m_boxes;
  65. };
  66. };
  67. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  68. namespace services
  69. {
  70. template <typename Tag, typename CalculationType>
  71. struct default_strategy<Tag, spherical_equatorial_tag, CalculationType>
  72. {
  73. typedef strategy::envelope::spherical<CalculationType> type;
  74. };
  75. template <typename Tag, typename CalculationType>
  76. struct default_strategy<Tag, spherical_polar_tag, CalculationType>
  77. {
  78. typedef strategy::envelope::spherical<CalculationType> type;
  79. };
  80. }
  81. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  82. }} // namespace strategy::envelope
  83. }} //namepsace boost::geometry
  84. #endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_HPP