annotate DEPENDENCIES/generic/include/boost/geometry/strategies/geographic/distance_vincenty.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents f46d142149f5
children
rev   line source
Chris@102 1 // Boost.Geometry
Chris@102 2
Chris@102 3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
Chris@102 4
Chris@102 5 // This file was modified by Oracle on 2014.
Chris@102 6 // Modifications copyright (c) 2014 Oracle and/or its affiliates.
Chris@102 7
Chris@102 8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
Chris@102 9
Chris@102 10 // Use, modification and distribution is subject to the Boost Software License,
Chris@102 11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@102 12 // http://www.boost.org/LICENSE_1_0.txt)
Chris@102 13
Chris@102 14 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_VINCENTY_HPP
Chris@102 15 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_VINCENTY_HPP
Chris@102 16
Chris@102 17
Chris@102 18 #include <boost/geometry/core/coordinate_type.hpp>
Chris@102 19 #include <boost/geometry/core/radian_access.hpp>
Chris@102 20
Chris@102 21 #include <boost/geometry/strategies/distance.hpp>
Chris@102 22
Chris@102 23 #include <boost/geometry/util/promote_floating_point.hpp>
Chris@102 24 #include <boost/geometry/util/select_calculation_type.hpp>
Chris@102 25
Chris@102 26 #include <boost/geometry/algorithms/detail/vincenty_inverse.hpp>
Chris@102 27
Chris@102 28 namespace boost { namespace geometry
Chris@102 29 {
Chris@102 30
Chris@102 31 namespace strategy { namespace distance
Chris@102 32 {
Chris@102 33
Chris@102 34 /*!
Chris@102 35 \brief Distance calculation formulae on latlong coordinates, after Vincenty, 1975
Chris@102 36 \ingroup distance
Chris@102 37 \tparam Spheroid The reference spheroid model
Chris@102 38 \tparam CalculationType \tparam_calculation
Chris@102 39 \author See
Chris@102 40 - http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf
Chris@102 41 - http://www.icsm.gov.au/gda/gdav2.3.pdf
Chris@102 42 \author Adapted from various implementations to get it close to the original document
Chris@102 43 - http://www.movable-type.co.uk/scripts/LatLongVincenty.html
Chris@102 44 - http://exogen.case.edu/projects/geopy/source/geopy.distance.html
Chris@102 45 - http://futureboy.homeip.net/fsp/colorize.fsp?fileName=navigation.frink
Chris@102 46
Chris@102 47 */
Chris@102 48 template
Chris@102 49 <
Chris@102 50 typename Spheroid,
Chris@102 51 typename CalculationType = void
Chris@102 52 >
Chris@102 53 class vincenty
Chris@102 54 {
Chris@102 55 public :
Chris@102 56 template <typename Point1, typename Point2>
Chris@102 57 struct calculation_type
Chris@102 58 : promote_floating_point
Chris@102 59 <
Chris@102 60 typename select_calculation_type
Chris@102 61 <
Chris@102 62 Point1,
Chris@102 63 Point2,
Chris@102 64 CalculationType
Chris@102 65 >::type
Chris@102 66 >
Chris@102 67 {};
Chris@102 68
Chris@102 69 typedef Spheroid model_type;
Chris@102 70
Chris@102 71 inline vincenty()
Chris@102 72 : m_spheroid()
Chris@102 73 {}
Chris@102 74
Chris@102 75 explicit inline vincenty(Spheroid const& spheroid)
Chris@102 76 : m_spheroid(spheroid)
Chris@102 77 {}
Chris@102 78
Chris@102 79 template <typename Point1, typename Point2>
Chris@102 80 inline typename calculation_type<Point1, Point2>::type
Chris@102 81 apply(Point1 const& point1, Point2 const& point2) const
Chris@102 82 {
Chris@102 83 return geometry::detail::vincenty_inverse
Chris@102 84 <
Chris@102 85 typename calculation_type<Point1, Point2>::type
Chris@102 86 >(get_as_radian<0>(point1),
Chris@102 87 get_as_radian<1>(point1),
Chris@102 88 get_as_radian<0>(point2),
Chris@102 89 get_as_radian<1>(point2),
Chris@102 90 m_spheroid).distance();
Chris@102 91 }
Chris@102 92
Chris@102 93 inline Spheroid const& model() const
Chris@102 94 {
Chris@102 95 return m_spheroid;
Chris@102 96 }
Chris@102 97
Chris@102 98 private :
Chris@102 99 Spheroid m_spheroid;
Chris@102 100 };
Chris@102 101
Chris@102 102 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
Chris@102 103 namespace services
Chris@102 104 {
Chris@102 105
Chris@102 106 template <typename Spheroid, typename CalculationType>
Chris@102 107 struct tag<vincenty<Spheroid, CalculationType> >
Chris@102 108 {
Chris@102 109 typedef strategy_tag_distance_point_point type;
Chris@102 110 };
Chris@102 111
Chris@102 112
Chris@102 113 template <typename Spheroid, typename CalculationType, typename P1, typename P2>
Chris@102 114 struct return_type<vincenty<Spheroid, CalculationType>, P1, P2>
Chris@102 115 : vincenty<Spheroid, CalculationType>::template calculation_type<P1, P2>
Chris@102 116 {};
Chris@102 117
Chris@102 118
Chris@102 119 template <typename Spheroid, typename CalculationType>
Chris@102 120 struct comparable_type<vincenty<Spheroid, CalculationType> >
Chris@102 121 {
Chris@102 122 typedef vincenty<Spheroid, CalculationType> type;
Chris@102 123 };
Chris@102 124
Chris@102 125
Chris@102 126 template <typename Spheroid, typename CalculationType>
Chris@102 127 struct get_comparable<vincenty<Spheroid, CalculationType> >
Chris@102 128 {
Chris@102 129 static inline vincenty<Spheroid, CalculationType> apply(vincenty<Spheroid, CalculationType> const& input)
Chris@102 130 {
Chris@102 131 return input;
Chris@102 132 }
Chris@102 133 };
Chris@102 134
Chris@102 135 template <typename Spheroid, typename CalculationType, typename P1, typename P2>
Chris@102 136 struct result_from_distance<vincenty<Spheroid, CalculationType>, P1, P2 >
Chris@102 137 {
Chris@102 138 template <typename T>
Chris@102 139 static inline typename return_type<vincenty<Spheroid, CalculationType>, P1, P2>::type
Chris@102 140 apply(vincenty<Spheroid, CalculationType> const& , T const& value)
Chris@102 141 {
Chris@102 142 return value;
Chris@102 143 }
Chris@102 144 };
Chris@102 145
Chris@102 146
Chris@102 147 } // namespace services
Chris@102 148 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
Chris@102 149
Chris@102 150
Chris@102 151 // We might add a vincenty-like strategy also for point-segment distance, but to calculate the projected point is not trivial
Chris@102 152
Chris@102 153
Chris@102 154
Chris@102 155 }} // namespace strategy::distance
Chris@102 156
Chris@102 157
Chris@102 158 }} // namespace boost::geometry
Chris@102 159
Chris@102 160
Chris@102 161 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_VINCENTY_HPP