envelope_segment.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP
  9. #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP
  10. #include <boost/geometry/algorithms/detail/envelope/segment.hpp>
  11. #include <boost/geometry/algorithms/detail/normalize.hpp>
  12. #include <boost/geometry/srs/spheroid.hpp>
  13. #include <boost/geometry/strategies/envelope.hpp>
  14. #include <boost/geometry/strategies/geographic/azimuth.hpp>
  15. #include <boost/geometry/strategies/geographic/parameters.hpp>
  16. namespace boost { namespace geometry
  17. {
  18. namespace strategy { namespace envelope
  19. {
  20. template
  21. <
  22. typename FormulaPolicy = strategy::andoyer,
  23. typename Spheroid = geometry::srs::spheroid<double>,
  24. typename CalculationType = void
  25. >
  26. class geographic_segment
  27. {
  28. public:
  29. typedef Spheroid model_type;
  30. inline geographic_segment()
  31. : m_spheroid()
  32. {}
  33. explicit inline geographic_segment(Spheroid const& spheroid)
  34. : m_spheroid(spheroid)
  35. {}
  36. template <typename Point1, typename Point2, typename Box>
  37. inline void apply(Point1 const& point1, Point2 const& point2, Box& box) const
  38. {
  39. Point1 p1_normalized = detail::return_normalized<Point1>(point1);
  40. Point2 p2_normalized = detail::return_normalized<Point2>(point2);
  41. geometry::strategy::azimuth::geographic
  42. <
  43. FormulaPolicy,
  44. Spheroid,
  45. CalculationType
  46. > azimuth_geographic(m_spheroid);
  47. typedef typename coordinate_system<Point1>::type::units units_type;
  48. detail::envelope::envelope_segment_impl
  49. <
  50. geographic_tag
  51. >::template apply<units_type>(geometry::get<0>(p1_normalized),
  52. geometry::get<1>(p1_normalized),
  53. geometry::get<0>(p2_normalized),
  54. geometry::get<1>(p2_normalized),
  55. box,
  56. azimuth_geographic);
  57. }
  58. private:
  59. Spheroid m_spheroid;
  60. };
  61. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  62. namespace services
  63. {
  64. template <typename CalculationType>
  65. struct default_strategy<geographic_tag, CalculationType>
  66. {
  67. typedef strategy::envelope::geographic_segment
  68. <
  69. strategy::andoyer,
  70. srs::spheroid<double>,
  71. CalculationType
  72. > type;
  73. };
  74. }
  75. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  76. }} // namespace strategy::envelope
  77. }} //namepsace boost::geometry
  78. #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP