envelope.hpp 4.2 KB

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