expand_segment.hpp 3.1 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. // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
  6. // This file was modified by Oracle on 2015-2020.
  7. // Modifications copyright (c) 2015-2020, Oracle and/or its affiliates.
  8. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  9. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  10. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  11. // Distributed under the Boost Software License, Version 1.0.
  12. // (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #ifndef BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_SEGMENT_HPP
  15. #define BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_SEGMENT_HPP
  16. #include <cstddef>
  17. #include <functional>
  18. #include <boost/geometry/core/access.hpp>
  19. #include <boost/geometry/core/tags.hpp>
  20. #include <boost/geometry/util/select_coordinate_type.hpp>
  21. #include <boost/geometry/algorithms/detail/envelope/box.hpp>
  22. #include <boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp>
  23. #include <boost/geometry/algorithms/detail/envelope/segment.hpp>
  24. #include <boost/geometry/strategy/expand.hpp>
  25. #include <boost/geometry/strategy/spherical/envelope_box.hpp>
  26. #include <boost/geometry/strategy/spherical/envelope_segment.hpp>
  27. namespace boost { namespace geometry
  28. {
  29. namespace strategy { namespace expand
  30. {
  31. #ifndef DOXYGEN_NO_DETAIL
  32. namespace detail
  33. {
  34. struct segment_on_spheroid
  35. {
  36. template <typename Box, typename Segment, typename Strategy>
  37. static inline void apply(Box& box, Segment const& segment, Strategy const& strategy)
  38. {
  39. Box mbrs[2];
  40. // compute the envelope of the segment
  41. geometry::detail::envelope::envelope_segment::apply(segment, mbrs[0], strategy);
  42. // normalize the box
  43. strategy::envelope::spherical_box::apply(box, mbrs[1]);
  44. // compute the envelope of the two boxes
  45. geometry::detail::envelope::envelope_range_of_boxes::apply(mbrs, box);
  46. }
  47. };
  48. } // namespace detail
  49. #endif // DOXYGEN_NO_DETAIL
  50. template
  51. <
  52. typename CalculationType = void
  53. >
  54. class spherical_segment
  55. {
  56. public:
  57. template <typename Box, typename Segment>
  58. static inline void apply(Box& box, Segment const& segment)
  59. {
  60. detail::segment_on_spheroid::apply(box, segment,
  61. strategy::envelope::spherical_segment<CalculationType>());
  62. }
  63. };
  64. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  65. namespace services
  66. {
  67. template <typename CalculationType>
  68. struct default_strategy<segment_tag, spherical_equatorial_tag, CalculationType>
  69. {
  70. typedef spherical_segment<CalculationType> type;
  71. };
  72. template <typename CalculationType>
  73. struct default_strategy<segment_tag, spherical_polar_tag, CalculationType>
  74. {
  75. typedef spherical_segment<CalculationType> type;
  76. };
  77. } // namespace services
  78. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  79. }} // namespace strategy::expand
  80. }} // namespace boost::geometry
  81. #endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_SEGMENT_HPP