expand_segment.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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, 2016, 2017, 2018.
  7. // Modifications copyright (c) 2015-2018, 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_STRATEGIES_SPHERICAL_EXPAND_SEGMENT_HPP
  15. #define BOOST_GEOMETRY_STRATEGIES_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/strategies/expand.hpp>
  25. #include <boost/geometry/strategies/spherical/envelope_segment.hpp>
  26. namespace boost { namespace geometry
  27. {
  28. namespace strategy { namespace expand
  29. {
  30. #ifndef DOXYGEN_NO_DETAIL
  31. namespace detail
  32. {
  33. struct segment_on_spheroid
  34. {
  35. template <typename Box, typename Segment, typename EnvelopeStrategy>
  36. static inline void apply(Box& box, Segment const& segment, EnvelopeStrategy const& strategy)
  37. {
  38. Box mbrs[2];
  39. // compute the envelope of the segment
  40. typename point_type<Segment>::type p[2];
  41. geometry::detail::assign_point_from_index<0>(segment, p[0]);
  42. geometry::detail::assign_point_from_index<1>(segment, p[1]);
  43. geometry::detail::envelope::envelope_segment
  44. <
  45. dimension<Segment>::value
  46. >::apply(p[0], p[1], mbrs[0], strategy);
  47. // normalize the box
  48. strategy::envelope::spherical_box::apply(box, mbrs[1]);
  49. // compute the envelope of the two boxes
  50. geometry::detail::envelope::envelope_range_of_boxes::apply(mbrs, box);
  51. }
  52. };
  53. } // namespace detail
  54. #endif // DOXYGEN_NO_DETAIL
  55. template
  56. <
  57. typename CalculationType = void
  58. >
  59. class spherical_segment
  60. {
  61. public:
  62. template <typename Box, typename Segment>
  63. static inline void apply(Box& box, Segment const& segment)
  64. {
  65. detail::segment_on_spheroid::apply(box, segment,
  66. strategy::envelope::spherical_segment<CalculationType>());
  67. }
  68. };
  69. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  70. namespace services
  71. {
  72. template <typename CalculationType>
  73. struct default_strategy<segment_tag, spherical_equatorial_tag, CalculationType>
  74. {
  75. typedef spherical_segment<CalculationType> type;
  76. };
  77. template <typename CalculationType>
  78. struct default_strategy<segment_tag, spherical_polar_tag, CalculationType>
  79. {
  80. typedef spherical_segment<CalculationType> type;
  81. };
  82. } // namespace services
  83. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  84. }} // namespace strategy::expand
  85. }} // namespace boost::geometry
  86. #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_SEGMENT_HPP