// 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_GEOGRAPHIC_HPP #define BOOST_GEOMETRY_STRATEGIES_DISTANCE_GEOGRAPHIC_HPP #include #include #include #include #include #include #include #include #include #include // TODO - for backwards compatibility, remove? #include #include #include #include #include namespace boost { namespace geometry { namespace strategies { namespace distance { // TODO: azimuth and normalize getters would not be needed if distance_segment_box was implemented differently // right now it calls disjoint algorithm details. template < typename FormulaPolicy = strategy::andoyer, typename Spheroid = srs::spheroid, typename CalculationType = void > class geographic : public strategies::relate::geographic { using base_t = strategies::relate::geographic; public: geographic() = default; explicit geographic(Spheroid const& spheroid) : base_t(spheroid) {} // azimuth auto azimuth() const { return strategy::azimuth::geographic < FormulaPolicy, Spheroid, CalculationType >(base_t::m_spheroid); } // distance template auto distance(Geometry1 const&, Geometry2 const&, detail::enable_if_pp_t * = nullptr) const { return strategy::distance::geographic < FormulaPolicy, Spheroid, CalculationType >(base_t::m_spheroid); } template auto distance(Geometry1 const&, Geometry2 const&, detail::enable_if_ps_t * = nullptr) const { return strategy::distance::geographic_cross_track < FormulaPolicy, Spheroid, CalculationType >(base_t::m_spheroid); } template auto distance(Geometry1 const&, Geometry2 const&, detail::enable_if_pb_t * = nullptr) const { return strategy::distance::geographic_cross_track_point_box < FormulaPolicy, Spheroid, CalculationType >(base_t::m_spheroid); } template auto distance(Geometry1 const&, Geometry2 const&, detail::enable_if_sb_t * = nullptr) const { return strategy::distance::geographic_segment_box < FormulaPolicy, Spheroid, CalculationType >(base_t::m_spheroid); } template auto distance(Geometry1 const&, Geometry2 const&, detail::enable_if_bb_t * = nullptr) const { return strategy::distance::geographic_cross_track_box_box < FormulaPolicy, Spheroid, CalculationType >(base_t::m_spheroid); } // normalize template static auto normalize(Geometry const&, std::enable_if_t < util::is_point::value > * = nullptr) { return strategy::normalize::spherical_point(); } }; namespace services { template struct default_strategy { using type = strategies::distance::geographic<>; }; template struct strategy_converter > { static auto get(strategy::distance::geographic const& s) { return strategies::distance::geographic(s.model()); } }; // TODO - for backwards compatibility, remove? template struct strategy_converter > { static auto get(strategy::distance::andoyer const& s) { return strategies::distance::geographic(s.model()); } }; // TODO - for backwards compatibility, remove? template struct strategy_converter > { static auto get(strategy::distance::thomas const& s) { return strategies::distance::geographic(s.model()); } }; // TODO - for backwards compatibility, remove? template struct strategy_converter > { static auto get(strategy::distance::vincenty const& s) { return strategies::distance::geographic(s.model()); } }; template struct strategy_converter > { static auto get(strategy::distance::geographic_cross_track const& s) { return strategies::distance::geographic(s.model()); } }; template struct strategy_converter > { static auto get(strategy::distance::geographic_cross_track_point_box const& s) { return strategies::distance::geographic(s.model()); } }; template struct strategy_converter > { static auto get(strategy::distance::geographic_segment_box const& s) { return strategies::distance::geographic(s.model()); } }; template struct strategy_converter > { static auto get(strategy::distance::geographic_cross_track_box_box const& s) { return strategies::distance::geographic(s.model()); } }; // details // TODO: This specialization wouldn't be needed if strategy::distance::geographic_cross_track was implemented as an alias template struct strategy_converter > { struct altered_strategy : strategies::distance::geographic { typedef strategies::distance::geographic base_t; explicit altered_strategy(S const& s) : base_t(s) {} using base_t::distance; template auto distance(Geometry1 const&, Geometry2 const&, detail::enable_if_ps_t * = nullptr) const { return strategy::distance::detail::geographic_cross_track < FP, S, CT, B, ECP >(base_t::m_spheroid); } }; static auto get(strategy::distance::detail::geographic_cross_track const& s) { return altered_strategy(s.model()); } }; } // namespace services }} // namespace strategies::distance }} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_DISTANCE_GEOGRAPHIC_HPP