// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2016 Barend Gehrels, Amsterdam, the Netherlands. // This file was modified by Oracle on 2014-2017. // Modifications copyright (c) 2014-2017 Oracle and/or its affiliates. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_HPP #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace geometry { namespace strategy { namespace distance { template < typename FormulaPolicy = strategy::andoyer, typename Spheroid = srs::spheroid, typename CalculationType = void > class geographic { public : template struct calculation_type : promote_floating_point < typename select_calculation_type < Point1, Point2, CalculationType >::type > {}; typedef Spheroid model_type; inline geographic() : m_spheroid() {} explicit inline geographic(Spheroid const& spheroid) : m_spheroid(spheroid) {} template static inline CT apply(CT lon1, CT lat1, CT lon2, CT lat2, Spheroid const& spheroid) { typedef typename formula::elliptic_arc_length < CT, strategy::default_order::value > elliptic_arc_length; typename elliptic_arc_length::result res = elliptic_arc_length::apply(lon1, lat1, lon2, lat2, spheroid); if (res.meridian) { return res.distance; } return FormulaPolicy::template inverse < CT, true, false, false, false, false >::apply(lon1, lat1, lon2, lat2, spheroid).distance; } template inline typename calculation_type::type apply(Point1 const& point1, Point2 const& point2) const { typedef typename calculation_type::type CT; CT lon1 = get_as_radian<0>(point1); CT lat1 = get_as_radian<1>(point1); CT lon2 = get_as_radian<0>(point2); CT lat2 = get_as_radian<1>(point2); return apply(lon1, lat1, lon2, lat2, m_spheroid); } inline Spheroid const& model() const { return m_spheroid; } private : Spheroid m_spheroid; }; #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS namespace services { template < typename FormulaPolicy, typename Spheroid, typename CalculationType > struct tag > { typedef strategy_tag_distance_point_point type; }; template < typename FormulaPolicy, typename Spheroid, typename CalculationType, typename P1, typename P2 > struct return_type, P1, P2> : geographic::template calculation_type {}; template < typename FormulaPolicy, typename Spheroid, typename CalculationType > struct comparable_type > { typedef geographic type; }; template < typename FormulaPolicy, typename Spheroid, typename CalculationType > struct get_comparable > { static inline geographic apply(geographic const& input) { return input; } }; template < typename FormulaPolicy, typename Spheroid, typename CalculationType, typename P1, typename P2 > struct result_from_distance, P1, P2> { template static inline typename return_type, P1, P2>::type apply(geographic const& , T const& value) { return value; } }; template struct default_strategy { typedef strategy::distance::geographic < strategy::andoyer, srs::spheroid < typename select_coordinate_type::type > > type; }; } // namespace services #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS }} // namespace strategy::distance }} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_HPP