Chris@102: // Boost.Geometry Chris@102: Chris@102: // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. Chris@102: Chris@102: // This file was modified by Oracle on 2014. Chris@102: // Modifications copyright (c) 2014 Oracle and/or its affiliates. Chris@102: Chris@102: // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle Chris@102: Chris@102: // Use, modification and distribution is subject to the Boost Software License, Chris@102: // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@102: // http://www.boost.org/LICENSE_1_0.txt) Chris@102: Chris@102: #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_VINCENTY_HPP Chris@102: #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_VINCENTY_HPP Chris@102: Chris@102: Chris@102: #include Chris@102: #include Chris@102: Chris@102: #include Chris@102: Chris@102: #include Chris@102: #include Chris@102: Chris@102: #include Chris@102: Chris@102: namespace boost { namespace geometry Chris@102: { Chris@102: Chris@102: namespace strategy { namespace distance Chris@102: { Chris@102: Chris@102: /*! Chris@102: \brief Distance calculation formulae on latlong coordinates, after Vincenty, 1975 Chris@102: \ingroup distance Chris@102: \tparam Spheroid The reference spheroid model Chris@102: \tparam CalculationType \tparam_calculation Chris@102: \author See Chris@102: - http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf Chris@102: - http://www.icsm.gov.au/gda/gdav2.3.pdf Chris@102: \author Adapted from various implementations to get it close to the original document Chris@102: - http://www.movable-type.co.uk/scripts/LatLongVincenty.html Chris@102: - http://exogen.case.edu/projects/geopy/source/geopy.distance.html Chris@102: - http://futureboy.homeip.net/fsp/colorize.fsp?fileName=navigation.frink Chris@102: Chris@102: */ Chris@102: template Chris@102: < Chris@102: typename Spheroid, Chris@102: typename CalculationType = void Chris@102: > Chris@102: class vincenty Chris@102: { Chris@102: public : Chris@102: template Chris@102: struct calculation_type Chris@102: : promote_floating_point Chris@102: < Chris@102: typename select_calculation_type Chris@102: < Chris@102: Point1, Chris@102: Point2, Chris@102: CalculationType Chris@102: >::type Chris@102: > Chris@102: {}; Chris@102: Chris@102: typedef Spheroid model_type; Chris@102: Chris@102: inline vincenty() Chris@102: : m_spheroid() Chris@102: {} Chris@102: Chris@102: explicit inline vincenty(Spheroid const& spheroid) Chris@102: : m_spheroid(spheroid) Chris@102: {} Chris@102: Chris@102: template Chris@102: inline typename calculation_type::type Chris@102: apply(Point1 const& point1, Point2 const& point2) const Chris@102: { Chris@102: return geometry::detail::vincenty_inverse Chris@102: < Chris@102: typename calculation_type::type Chris@102: >(get_as_radian<0>(point1), Chris@102: get_as_radian<1>(point1), Chris@102: get_as_radian<0>(point2), Chris@102: get_as_radian<1>(point2), Chris@102: m_spheroid).distance(); Chris@102: } Chris@102: Chris@102: inline Spheroid const& model() const Chris@102: { Chris@102: return m_spheroid; Chris@102: } Chris@102: Chris@102: private : Chris@102: Spheroid m_spheroid; Chris@102: }; Chris@102: Chris@102: #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS Chris@102: namespace services Chris@102: { Chris@102: Chris@102: template Chris@102: struct tag > Chris@102: { Chris@102: typedef strategy_tag_distance_point_point type; Chris@102: }; Chris@102: Chris@102: Chris@102: template Chris@102: struct return_type, P1, P2> Chris@102: : vincenty::template calculation_type Chris@102: {}; Chris@102: Chris@102: Chris@102: template Chris@102: struct comparable_type > Chris@102: { Chris@102: typedef vincenty type; Chris@102: }; Chris@102: Chris@102: Chris@102: template Chris@102: struct get_comparable > Chris@102: { Chris@102: static inline vincenty apply(vincenty const& input) Chris@102: { Chris@102: return input; Chris@102: } Chris@102: }; Chris@102: Chris@102: template Chris@102: struct result_from_distance, P1, P2 > Chris@102: { Chris@102: template Chris@102: static inline typename return_type, P1, P2>::type Chris@102: apply(vincenty const& , T const& value) Chris@102: { Chris@102: return value; Chris@102: } Chris@102: }; Chris@102: Chris@102: Chris@102: } // namespace services Chris@102: #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS Chris@102: Chris@102: Chris@102: // We might add a vincenty-like strategy also for point-segment distance, but to calculate the projected point is not trivial Chris@102: Chris@102: Chris@102: Chris@102: }} // namespace strategy::distance Chris@102: Chris@102: Chris@102: }} // namespace boost::geometry Chris@102: Chris@102: Chris@102: #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_VINCENTY_HPP