// Boost.Geometry // Copyright (c) 2021, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_DISTANCE_SPHERICAL_HPP #define BOOST_GEOMETRY_STRATEGIES_DISTANCE_SPHERICAL_HPP #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace geometry { namespace strategies { namespace distance { #ifndef DOXYGEN_NO_DETAIL namespace detail { // TODO: azimuth and normalize getters would not be needed if distance_segment_box was implemented differently // right now it calls disjoint algorithm details. template class spherical : public strategies::relate::detail::spherical { using base_t = strategies::relate::detail::spherical; public: spherical() = default; template explicit spherical(RadiusOrSphere const& radius_or_sphere) : base_t(radius_or_sphere) {} // azimuth static auto azimuth() { return strategy::azimuth::spherical(); } // distance template auto distance(Geometry1 const&, Geometry2 const&, detail::enable_if_pp_t * = nullptr) const { return strategy::distance::haversine < typename base_t::radius_type, CalculationType >(base_t::radius()); } template auto distance(Geometry1 const&, Geometry2 const&, detail::enable_if_ps_t * = nullptr) const { return strategy::distance::cross_track < CalculationType, strategy::distance::haversine >(base_t::radius()); } template auto distance(Geometry1 const&, Geometry2 const&, detail::enable_if_pb_t * = nullptr) const { return strategy::distance::cross_track_point_box < CalculationType, strategy::distance::haversine >(base_t::radius()); } template auto distance(Geometry1 const&, Geometry2 const&, detail::enable_if_sb_t * = nullptr) const { return strategy::distance::spherical_segment_box < CalculationType, strategy::distance::haversine >(base_t::radius()); } template auto distance(Geometry1 const&, Geometry2 const&, detail::enable_if_bb_t * = nullptr) const { return strategy::distance::cross_track_box_box < CalculationType, strategy::distance::haversine >(base_t::radius()); } // normalize template static auto normalize(Geometry const&, std::enable_if_t < util::is_point::value > * = nullptr) { return strategy::normalize::spherical_point(); } }; } // namespace detail #endif // DOXYGEN_NO_DETAIL template < typename RadiusTypeOrSphere = double, typename CalculationType = void > class spherical : public strategies::distance::detail::spherical { using base_t = strategies::distance::detail::spherical; public: spherical() = default; template explicit spherical(RadiusOrSphere const& radius_or_sphere) : base_t(radius_or_sphere) {} }; namespace services { template struct default_strategy < Geometry1, Geometry2, spherical_equatorial_tag, spherical_equatorial_tag > { using type = strategies::distance::spherical<>; }; template struct strategy_converter > { template static auto get(S const& s) { return strategies::distance::spherical(s.radius()); } }; template struct strategy_converter > : strategy_converter {}; template struct strategy_converter > : strategy_converter {}; template struct strategy_converter > : strategy_converter {}; template struct strategy_converter > : strategy_converter {}; template struct strategy_converter > { template static auto get(S const& s) { return strategies::distance::detail::make_comparable( strategies::distance::spherical(s.radius())); } }; template struct strategy_converter > : strategy_converter {}; } // namespace services }} // namespace strategies::distance }} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_DISTANCE_SPHERICAL_HPP