point_order.hpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. // Boost.Geometry
  2. // Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
  3. // Copyright (c) 2019-2020, Oracle and/or its affiliates.
  4. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  5. // Licensed under the Boost Software License version 1.0.
  6. // http://www.boost.org/users/license.html
  7. #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_POINT_ORDER_HPP
  8. #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_POINT_ORDER_HPP
  9. //#include <type_traits>
  10. #include <boost/geometry/core/tags.hpp>
  11. #include <boost/geometry/formulas/spherical.hpp>
  12. #include <boost/geometry/strategy/spherical/area.hpp>
  13. #include <boost/geometry/strategies/spherical/point_in_point.hpp>
  14. #include <boost/geometry/strategies/point_order.hpp>
  15. #include <boost/geometry/util/math.hpp>
  16. #include <boost/geometry/util/select_calculation_type.hpp>
  17. namespace boost { namespace geometry
  18. {
  19. namespace strategy { namespace point_order
  20. {
  21. //template <typename CalculationType = void>
  22. //struct spherical
  23. //{
  24. // typedef azimuth_tag version_tag;
  25. //
  26. // template <typename Geometry>
  27. // struct result_type
  28. // {
  29. // typedef typename geometry::select_calculation_type_alt
  30. // <
  31. // CalculationType, Geometry
  32. // >::type type;
  33. // };
  34. //
  35. // template <typename Point>
  36. // inline bool apply(Point const& p1, Point const& p2,
  37. // typename result_type<Point>::type & azi,
  38. // typename result_type<Point>::type & razi) const
  39. // {
  40. // typedef typename result_type<Point>::type calc_t;
  41. //
  42. // if (equals_point_point(p1, p2))
  43. // {
  44. // return false;
  45. // }
  46. //
  47. // calc_t lon1 = geometry::get_as_radian<0>(p1);
  48. // calc_t lat1 = geometry::get_as_radian<1>(p1);
  49. // calc_t lon2 = geometry::get_as_radian<0>(p2);
  50. // calc_t lat2 = geometry::get_as_radian<1>(p2);
  51. //
  52. // convert_latitudes<Point>(lat1, lat2);
  53. //
  54. // formula::result_spherical<calc_t>
  55. // res = formula::spherical_azimuth<calc_t, true>(lon1, lat1, lon2, lat2);
  56. //
  57. // azi = res.azimuth;
  58. // razi = res.reverse_azimuth;
  59. //
  60. // return true;
  61. // }
  62. //
  63. // template <typename Point>
  64. // inline typename result_type<Point>::type
  65. // apply(Point const& /*p0*/, Point const& /*p1*/, Point const& /*p2*/,
  66. // typename result_type<Point>::type const& azi1,
  67. // typename result_type<Point>::type const& azi2) const
  68. // {
  69. // // TODO: support poles
  70. // return math::longitude_distance_signed<radian>(azi1, azi2);
  71. // }
  72. //
  73. //private:
  74. // template <typename Point>
  75. // static bool equals_point_point(Point const& p0, Point const& p1)
  76. // {
  77. // return strategy::within::spherical_point_point::apply(p0, p1);
  78. // }
  79. //
  80. // template <typename Point, typename CalcT>
  81. // static void convert_latitudes(CalcT & lat1, CalcT & lat2)
  82. // {
  83. // static const bool is_polar = std::is_same
  84. // <
  85. // typename geometry::cs_tag<Point>::type,
  86. // spherical_polar_tag
  87. // >::value;
  88. //
  89. // if BOOST_GEOMETRY_CONSTEXPR (is_polar)
  90. // {
  91. // CalcT pi_half = math::half_pi<CalcT>();
  92. // lat1 = pi_half - lat1;
  93. // lat2 = pi_half - lat2;
  94. // }
  95. // }
  96. //};
  97. template <typename CalculationType = void>
  98. struct spherical
  99. : strategy::area::spherical<double, CalculationType>
  100. {
  101. typedef area_tag version_tag;
  102. // TEMP
  103. static strategy::area::spherical<double, CalculationType> get_area_strategy()
  104. {
  105. return strategy::area::spherical<double, CalculationType>();
  106. }
  107. };
  108. namespace services
  109. {
  110. template <>
  111. struct default_strategy<spherical_equatorial_tag>
  112. {
  113. typedef spherical<> type;
  114. };
  115. /*template <>
  116. struct default_strategy<spherical_polar_tag>
  117. {
  118. typedef spherical<> type;
  119. };*/
  120. } // namespace services
  121. }} // namespace strategy::point_order
  122. }} // namespace boost::geometry
  123. #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_POINT_ORDER_HPP