3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // This file was modified by Oracle on 2014.
6 // Modifications copyright (c) 2014 Oracle and/or its affiliates.
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
14 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_VINCENTY_HPP
15 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_VINCENTY_HPP
18 #include <boost/geometry/core/coordinate_type.hpp>
19 #include <boost/geometry/core/radian_access.hpp>
21 #include <boost/geometry/strategies/distance.hpp>
23 #include <boost/geometry/util/promote_floating_point.hpp>
24 #include <boost/geometry/util/select_calculation_type.hpp>
26 #include <boost/geometry/algorithms/detail/vincenty_inverse.hpp>
28 namespace boost { namespace geometry
31 namespace strategy { namespace distance
35 \brief Distance calculation formulae on latlong coordinates, after Vincenty, 1975
37 \tparam Spheroid The reference spheroid model
38 \tparam CalculationType \tparam_calculation
40 - http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf
41 - http://www.icsm.gov.au/gda/gdav2.3.pdf
42 \author Adapted from various implementations to get it close to the original document
43 - http://www.movable-type.co.uk/scripts/LatLongVincenty.html
44 - http://exogen.case.edu/projects/geopy/source/geopy.distance.html
45 - http://futureboy.homeip.net/fsp/colorize.fsp?fileName=navigation.frink
51 typename CalculationType = void
56 template <typename Point1, typename Point2>
57 struct calculation_type
58 : promote_floating_point
60 typename select_calculation_type
69 typedef Spheroid model_type;
75 explicit inline vincenty(Spheroid const& spheroid)
76 : m_spheroid(spheroid)
79 template <typename Point1, typename Point2>
80 inline typename calculation_type<Point1, Point2>::type
81 apply(Point1 const& point1, Point2 const& point2) const
83 return geometry::detail::vincenty_inverse
85 typename calculation_type<Point1, Point2>::type,
87 >::apply(get_as_radian<0>(point1),
88 get_as_radian<1>(point1),
89 get_as_radian<0>(point2),
90 get_as_radian<1>(point2),
94 inline Spheroid const& model() const
103 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
107 template <typename Spheroid, typename CalculationType>
108 struct tag<vincenty<Spheroid, CalculationType> >
110 typedef strategy_tag_distance_point_point type;
114 template <typename Spheroid, typename CalculationType, typename P1, typename P2>
115 struct return_type<vincenty<Spheroid, CalculationType>, P1, P2>
116 : vincenty<Spheroid, CalculationType>::template calculation_type<P1, P2>
120 template <typename Spheroid, typename CalculationType>
121 struct comparable_type<vincenty<Spheroid, CalculationType> >
123 typedef vincenty<Spheroid, CalculationType> type;
127 template <typename Spheroid, typename CalculationType>
128 struct get_comparable<vincenty<Spheroid, CalculationType> >
130 static inline vincenty<Spheroid, CalculationType> apply(vincenty<Spheroid, CalculationType> const& input)
136 template <typename Spheroid, typename CalculationType, typename P1, typename P2>
137 struct result_from_distance<vincenty<Spheroid, CalculationType>, P1, P2 >
139 template <typename T>
140 static inline typename return_type<vincenty<Spheroid, CalculationType>, P1, P2>::type
141 apply(vincenty<Spheroid, CalculationType> const& , T const& value)
148 } // namespace services
149 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
152 // We might add a vincenty-like strategy also for point-segment distance, but to calculate the projected point is not trivial
156 }} // namespace strategy::distance
159 }} // namespace boost::geometry
162 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_VINCENTY_HPP