// Boost.Geometry // Copyright (c) 2020, 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_INDEX_GEOGRAPHIC_HPP #define BOOST_GEOMETRY_STRATEGIES_INDEX_GEOGRAPHIC_HPP #include #include // TEMP - move to strategy #include #include #include #include #include #include #include #include namespace boost { namespace geometry { namespace strategies { namespace index { template < typename FormulaPolicy = strategy::andoyer, // TODO: Is SeriesOrder argument needed here? std::size_t SeriesOrder = strategy::default_order::value, typename Spheroid = srs::spheroid, typename CalculationType = void > class geographic : public relate::geographic { typedef relate::geographic base_t; public: geographic() : base_t() {} explicit geographic(Spheroid const& spheroid) : base_t(spheroid) {} template auto comparable_distance(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_pointlike::value && util::is_pointlike::value > * = nullptr) const { return geometry::strategy::distance::geographic < FormulaPolicy, Spheroid, CalculationType >(base_t::m_spheroid); } template auto comparable_distance(Geometry1 const&, Geometry2 const&, std::enable_if_t < (util::is_pointlike::value && util::is_segment::value) || (util::is_segment::value && util::is_pointlike::value) > * = nullptr) const { return geometry::strategy::distance::geographic_cross_track < FormulaPolicy, Spheroid, CalculationType >(base_t::m_spheroid); } template auto comparable_distance(Geometry1 const&, Geometry2 const&, std::enable_if_t < (util::is_pointlike::value && util::is_box::value) || (util::is_box::value && util::is_pointlike::value) > * = nullptr) const { return geometry::strategy::distance::geographic_cross_track_point_box < FormulaPolicy, Spheroid, CalculationType >(base_t::m_spheroid); } template auto comparable_distance(Geometry1 const&, Geometry2 const&, std::enable_if_t < (util::is_segment::value && util::is_box::value) || (util::is_box::value && util::is_segment::value) > * = nullptr) const { return geometry::strategy::distance::geographic_segment_box < FormulaPolicy, Spheroid, CalculationType >(base_t::m_spheroid); } template auto comparable_distance(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_segment::value && util::is_segment::value > * = nullptr) const { return geometry::strategy::distance::geographic_cross_track < FormulaPolicy, Spheroid, CalculationType >(base_t::m_spheroid); } }; namespace services { template struct default_strategy { using type = strategies::index::geographic<>; }; // TEMP - needed in distance until umbrella strategies are supported template struct strategy_converter> { static auto get(strategy::distance::geographic_cross_track const& strategy) { return strategies::index::geographic < FormulaPolicy, strategy::default_order::value, Spheroid, CalculationType >(strategy.model()); } }; // TEMP - needed in distance until umbrella strategies are supported template struct strategy_converter> { typedef strategies::index::geographic < FormulaPolicy, strategy::default_order::value, Spheroid, CalculationType > base_strategy; struct altered_strategy : base_strategy { explicit altered_strategy(Spheroid const& spheroid) : base_strategy(spheroid) {} // It seems that this declaration is needed because comparable_distance // is not static function. using base_strategy::comparable_distance; template auto comparable_distance(Geometry1 const&, Geometry2 const&, std::enable_if_t < (util::is_pointlike::value && util::is_segment::value) || (util::is_segment::value && util::is_pointlike::value) > * = nullptr) const { return geometry::strategy::distance::detail::geographic_cross_track < FormulaPolicy, Spheroid, CalculationType, Bisection, EnableClosestPoint >(base_strategy::m_spheroid); } template auto comparable_distance(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_segment::value && util::is_segment::value > * = nullptr) const { return geometry::strategy::distance::detail::geographic_cross_track < FormulaPolicy, Spheroid, CalculationType, Bisection, EnableClosestPoint >(base_strategy::m_spheroid); } }; static auto get(strategy::distance::detail::geographic_cross_track const& strategy) { return altered_strategy(strategy.model()); } }; // TEMP - needed in distance until umbrella strategies are supported template struct strategy_converter> { static auto get(strategy::distance::geographic const& strategy) { return strategies::index::geographic < FormulaPolicy, strategy::default_order::value, Spheroid, CalculationType >(strategy.model()); } }; // TEMP - needed in distance until umbrella strategies are supported template struct strategy_converter> { static auto get(strategy::distance::andoyer const& strategy) { return strategies::index::geographic < strategy::andoyer, strategy::default_order::value, Spheroid, CalculationType >(strategy.model()); } }; // TEMP - needed in distance until umbrella strategies are supported template struct strategy_converter> { static auto get(strategy::distance::thomas const& strategy) { return strategies::index::geographic < strategy::thomas, strategy::default_order::value, Spheroid, CalculationType >(strategy.model()); } }; // TEMP - needed in distance until umbrella strategies are supported template struct strategy_converter> { static auto get(strategy::distance::vincenty const& strategy) { return strategies::index::geographic < strategy::vincenty, strategy::default_order::value, Spheroid, CalculationType >(strategy.model()); } }; } // namespace services }}}} // namespace boost::geometry::strategy::index #endif // BOOST_GEOMETRY_STRATEGIES_INDEX_GEOGRAPHIC_HPP