distance_andoyer.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2016 Barend Gehrels, Amsterdam, the Netherlands.
  3. // This file was modified by Oracle on 2014, 2017.
  4. // Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
  5. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  6. // Use, modification and distribution is subject to the Boost Software License,
  7. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_DETAIL_HPP
  10. #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_DETAIL_HPP
  11. #include <boost/geometry/strategies/geographic/distance.hpp>
  12. #include <boost/geometry/strategies/geographic/parameters.hpp>
  13. namespace boost { namespace geometry
  14. {
  15. namespace strategy { namespace distance
  16. {
  17. /*!
  18. \brief Point-point distance approximation taking flattening into account
  19. \ingroup distance
  20. \tparam Spheroid The reference spheroid model
  21. \tparam CalculationType \tparam_calculation
  22. \author After Andoyer, 19xx, republished 1950, republished by Meeus, 1999
  23. \note Although not so well-known, the approximation is very good: in all cases the results
  24. are about the same as Vincenty. In my (Barend's) testcases the results didn't differ more than 6 m
  25. \see http://nacc.upc.es/tierra/node16.html
  26. \see http://sci.tech-archive.net/Archive/sci.geo.satellite-nav/2004-12/2724.html
  27. \see http://home.att.net/~srschmitt/great_circle_route.html (implementation)
  28. \see http://www.codeguru.com/Cpp/Cpp/algorithms/article.php/c5115 (implementation)
  29. \see http://futureboy.homeip.net/frinksamp/navigation.frink (implementation)
  30. \see http://www.voidware.com/earthdist.htm (implementation)
  31. \see http://www.dtic.mil/docs/citations/AD0627893
  32. \see http://www.dtic.mil/docs/citations/AD703541
  33. */
  34. template
  35. <
  36. typename Spheroid = srs::spheroid<double>,
  37. typename CalculationType = void
  38. >
  39. class andoyer
  40. : public strategy::distance::geographic
  41. <
  42. strategy::andoyer, Spheroid, CalculationType
  43. >
  44. {
  45. typedef strategy::distance::geographic
  46. <
  47. strategy::andoyer, Spheroid, CalculationType
  48. > base_type;
  49. public :
  50. inline andoyer()
  51. : base_type()
  52. {}
  53. explicit inline andoyer(Spheroid const& spheroid)
  54. : base_type(spheroid)
  55. {}
  56. };
  57. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  58. namespace services
  59. {
  60. template <typename Spheroid, typename CalculationType>
  61. struct tag<andoyer<Spheroid, CalculationType> >
  62. {
  63. typedef strategy_tag_distance_point_point type;
  64. };
  65. template <typename Spheroid, typename CalculationType, typename P1, typename P2>
  66. struct return_type<andoyer<Spheroid, CalculationType>, P1, P2>
  67. : andoyer<Spheroid, CalculationType>::template calculation_type<P1, P2>
  68. {};
  69. template <typename Spheroid, typename CalculationType>
  70. struct comparable_type<andoyer<Spheroid, CalculationType> >
  71. {
  72. typedef andoyer<Spheroid, CalculationType> type;
  73. };
  74. template <typename Spheroid, typename CalculationType>
  75. struct get_comparable<andoyer<Spheroid, CalculationType> >
  76. {
  77. static inline andoyer<Spheroid, CalculationType> apply(andoyer<Spheroid, CalculationType> const& input)
  78. {
  79. return input;
  80. }
  81. };
  82. template <typename Spheroid, typename CalculationType, typename P1, typename P2>
  83. struct result_from_distance<andoyer<Spheroid, CalculationType>, P1, P2>
  84. {
  85. template <typename T>
  86. static inline typename return_type<andoyer<Spheroid, CalculationType>, P1, P2>::type
  87. apply(andoyer<Spheroid, CalculationType> const& , T const& value)
  88. {
  89. return value;
  90. }
  91. };
  92. } // namespace services
  93. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  94. }} // namespace strategy::distance
  95. }} // namespace boost::geometry
  96. #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_DETAIL_HPP