envelope.hpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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_STRATEGIES_SPHERICAL_ENVELOPE_HPP
  16. #define BOOST_GEOMETRY_STRATEGIES_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/strategies/spherical/envelope_box.hpp>
  21. #include <boost/geometry/strategies/spherical/envelope_segment.hpp>
  22. #include <boost/geometry/strategies/spherical/expand_box.hpp>
  23. #include <boost/geometry/strategies/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. typedef spherical_segment<CalculationType> element_envelope_strategy_type;
  34. static inline element_envelope_strategy_type get_element_envelope_strategy()
  35. {
  36. return element_envelope_strategy_type();
  37. }
  38. typedef expand::spherical_segment<CalculationType> element_expand_strategy_type;
  39. static inline element_expand_strategy_type get_element_expand_strategy()
  40. {
  41. return element_expand_strategy_type();
  42. }
  43. typedef strategy::expand::spherical_box box_expand_strategy_type;
  44. static inline box_expand_strategy_type get_box_expand_strategy()
  45. {
  46. return box_expand_strategy_type();
  47. }
  48. // Linestring, Ring, Polygon
  49. template <typename Range>
  50. static inline geometry::segment_iterator<Range const> begin(Range const& range)
  51. {
  52. return geometry::segments_begin(range);
  53. }
  54. template <typename Range>
  55. static inline geometry::segment_iterator<Range const> end(Range const& range)
  56. {
  57. return geometry::segments_end(range);
  58. }
  59. // MultiLinestring, MultiPolygon
  60. template <typename Box>
  61. struct multi_state
  62. {
  63. void apply(Box const& single_box)
  64. {
  65. m_boxes.push_back(single_box);
  66. }
  67. void result(Box & box)
  68. {
  69. if (!m_boxes.empty())
  70. {
  71. geometry::detail::envelope::envelope_range_of_boxes::apply(m_boxes, box);
  72. }
  73. else
  74. {
  75. geometry::detail::envelope::initialize<Box, 0, dimension<Box>::value>::apply(box);
  76. }
  77. }
  78. private:
  79. std::vector<Box> m_boxes;
  80. };
  81. // Segment
  82. template <typename Point1, typename Point2, typename Box>
  83. static inline void apply(Point1 const& point1, Point2 const& point2,
  84. Box& box)
  85. {
  86. spherical_segment<CalculationType>::apply(point1, point2, box);
  87. }
  88. // Box
  89. template <typename BoxIn, typename Box>
  90. static inline void apply(BoxIn const& box_in, Box& box)
  91. {
  92. spherical_box::apply(box_in, box);
  93. }
  94. };
  95. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  96. namespace services
  97. {
  98. template <typename Tag, typename CalculationType>
  99. struct default_strategy<Tag, spherical_equatorial_tag, CalculationType>
  100. {
  101. typedef strategy::envelope::spherical<CalculationType> type;
  102. };
  103. template <typename Tag, typename CalculationType>
  104. struct default_strategy<Tag, spherical_polar_tag, CalculationType>
  105. {
  106. typedef strategy::envelope::spherical<CalculationType> type;
  107. };
  108. }
  109. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  110. }} // namespace strategy::envelope
  111. }} //namepsace boost::geometry
  112. #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_HPP