distance_karney.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // Boost.Geometry
  2. // Copyright (c) 2018 Adeel Ahmad, Islamabad, Pakistan.
  3. // Contributed and/or modified by Adeel Ahmad, as part of Google Summer of Code 2018 program.
  4. // Use, modification and distribution is subject to the Boost Software License,
  5. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_KARNEY_HPP
  8. #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_KARNEY_HPP
  9. #include <boost/geometry/strategies/geographic/distance.hpp>
  10. #include <boost/geometry/strategies/geographic/parameters.hpp>
  11. namespace boost { namespace geometry
  12. {
  13. namespace strategy { namespace distance
  14. {
  15. /*!
  16. \brief The solution of the inverse problem of geodesics on latlong coordinates,
  17. after Karney (2011).
  18. \ingroup distance
  19. \tparam Spheroid The reference spheroid model
  20. \tparam CalculationType \tparam_calculation
  21. \author See
  22. - Charles F.F Karney, Algorithms for geodesics, 2011
  23. https://arxiv.org/pdf/1109.4448.pdf
  24. */
  25. template
  26. <
  27. typename Spheroid = srs::spheroid<double>,
  28. typename CalculationType = void
  29. >
  30. class karney
  31. : public strategy::distance::geographic
  32. <
  33. strategy::karney, Spheroid, CalculationType
  34. >
  35. {
  36. typedef strategy::distance::geographic
  37. <
  38. strategy::karney, Spheroid, CalculationType
  39. > base_type;
  40. public:
  41. inline karney()
  42. : base_type()
  43. {}
  44. explicit inline karney(Spheroid const& spheroid)
  45. : base_type(spheroid)
  46. {}
  47. };
  48. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  49. namespace services
  50. {
  51. template <typename Spheroid, typename CalculationType>
  52. struct tag<karney<Spheroid, CalculationType> >
  53. {
  54. typedef strategy_tag_distance_point_point type;
  55. };
  56. template <typename Spheroid, typename CalculationType, typename P1, typename P2>
  57. struct return_type<karney<Spheroid, CalculationType>, P1, P2>
  58. : karney<Spheroid, CalculationType>::template calculation_type<P1, P2>
  59. {};
  60. template <typename Spheroid, typename CalculationType>
  61. struct comparable_type<karney<Spheroid, CalculationType> >
  62. {
  63. typedef karney<Spheroid, CalculationType> type;
  64. };
  65. template <typename Spheroid, typename CalculationType>
  66. struct get_comparable<karney<Spheroid, CalculationType> >
  67. {
  68. static inline karney<Spheroid, CalculationType> apply(karney<Spheroid, CalculationType> const& input)
  69. {
  70. return input;
  71. }
  72. };
  73. template <typename Spheroid, typename CalculationType, typename P1, typename P2>
  74. struct result_from_distance<karney<Spheroid, CalculationType>, P1, P2 >
  75. {
  76. template <typename T>
  77. static inline typename return_type<karney<Spheroid, CalculationType>, P1, P2>::type
  78. apply(karney<Spheroid, CalculationType> const& , T const& value)
  79. {
  80. return value;
  81. }
  82. };
  83. } // namespace services
  84. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  85. }} // namespace strategy::distance
  86. }} // namespace boost::geometry
  87. #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_KARNEY_HPP