envelope_segment.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2017 Oracle and/or its affiliates.
  3. // Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
  4. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  5. // Use, modification and distribution is subject to the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_SEGMENT_HPP
  9. #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_SEGMENT_HPP
  10. #include <boost/geometry/algorithms/detail/envelope/segment.hpp>
  11. #include <boost/geometry/algorithms/detail/normalize.hpp>
  12. #include <boost/geometry/strategies/envelope.hpp>
  13. #include <boost/geometry/strategies/spherical/azimuth.hpp>
  14. namespace boost { namespace geometry
  15. {
  16. namespace strategy { namespace envelope
  17. {
  18. template
  19. <
  20. typename CalculationType = void
  21. >
  22. class spherical_segment
  23. {
  24. public :
  25. inline spherical_segment()
  26. {}
  27. template <typename Point1, typename Point2, typename Box>
  28. inline void
  29. apply(Point1 const& point1, Point2 const& point2, Box& box) const
  30. {
  31. Point1 p1_normalized = detail::return_normalized<Point1>(point1);
  32. Point2 p2_normalized = detail::return_normalized<Point2>(point2);
  33. geometry::strategy::azimuth::spherical<CalculationType> azimuth_spherical;
  34. typedef typename coordinate_system<Point1>::type::units units_type;
  35. geometry::detail::envelope::envelope_segment_impl<spherical_equatorial_tag>
  36. ::template apply<units_type>(geometry::get<0>(p1_normalized),
  37. geometry::get<1>(p1_normalized),
  38. geometry::get<0>(p2_normalized),
  39. geometry::get<1>(p2_normalized),
  40. box,
  41. azimuth_spherical);
  42. }
  43. };
  44. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  45. namespace services
  46. {
  47. template <typename CalculationType>
  48. struct default_strategy<spherical_equatorial_tag, CalculationType>
  49. {
  50. typedef strategy::envelope::spherical_segment<CalculationType> type;
  51. };
  52. template <typename CalculationType>
  53. struct default_strategy<spherical_polar_tag, CalculationType>
  54. {
  55. typedef strategy::envelope::spherical_segment<CalculationType> type;
  56. };
  57. }
  58. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  59. }} // namespace strategy::envelope
  60. }} //namepsace boost::geometry
  61. #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_SEGMENT_HPP