// 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_RELATE_GEOGRAPHIC_HPP #define BOOST_GEOMETRY_STRATEGIES_RELATE_GEOGRAPHIC_HPP // TEMP - move to strategy #include #include #include #include #include #include #include #include #include #include namespace boost { namespace geometry { namespace strategies { namespace relate { 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 strategies::envelope::geographic { using base_t = strategies::envelope::geographic; public: geographic() : base_t() {} explicit geographic(Spheroid const& spheroid) : base_t(spheroid) {} // area template auto area(Geometry const&) const { return strategy::area::geographic < FormulaPolicy, SeriesOrder, Spheroid, CalculationType >(base_t::m_spheroid); } // covered_by template static auto covered_by(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_pointlike::value && util::is_box::value > * = nullptr) { return strategy::covered_by::spherical_point_box(); } template static auto covered_by(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_box::value && util::is_box::value > * = nullptr) { return strategy::covered_by::spherical_box_box(); } // disjoint template static auto disjoint(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_box::value && util::is_box::value > * = nullptr) { return strategy::disjoint::spherical_box_box(); } template auto disjoint(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_segment::value && util::is_box::value > * = nullptr) const { // NOTE: Inconsistent name // The only disjoint(Seg, Box) strategy that takes CalculationType. return strategy::disjoint::segment_box_geographic < FormulaPolicy, Spheroid, CalculationType >(base_t::m_spheroid); } // relate template static auto relate(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_pointlike::value && util::is_pointlike::value > * = nullptr) { return strategy::within::spherical_point_point(); } template auto relate(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_pointlike::value && ( util::is_linear::value || util::is_polygonal::value ) > * = nullptr) const { return strategy::within::geographic_winding < void, void, FormulaPolicy, Spheroid, CalculationType >(base_t::m_spheroid); } //template auto relate(/*Geometry1 const&, Geometry2 const&, std::enable_if_t < ( util::is_linear::value || util::is_polygonal::value ) && ( util::is_linear::value || util::is_polygonal::value ) > * = nullptr*/) const { return strategy::intersection::geographic_segments < FormulaPolicy, SeriesOrder, Spheroid, CalculationType >(base_t::m_spheroid); } // side auto side() const { return strategy::side::geographic < FormulaPolicy, Spheroid, CalculationType >(base_t::m_spheroid); } // within template static auto within(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_pointlike::value && util::is_box::value > * = nullptr) { return strategy::within::spherical_point_box(); } template static auto within(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_box::value && util::is_box::value > * = nullptr) { return strategy::within::spherical_box_box(); } }; namespace services { template struct default_strategy { using type = strategies::relate::geographic<>; }; template struct strategy_converter> { static auto get(strategy::disjoint::segment_box_geographic const& s) { return strategies::relate::geographic < FormulaPolicy, strategy::default_order::value, Spheroid, CalculationType >(s.model()); } }; template struct strategy_converter> { static auto get(strategy::within::geographic_winding const& s) { return strategies::relate::geographic < FormulaPolicy, strategy::default_order::value, Spheroid, CalculationType >(s.model()); } }; template struct strategy_converter> { static auto get(strategy::intersection::geographic_segments const& s) { return strategies::relate::geographic < FormulaPolicy, SeriesOrder, Spheroid, CalculationType >(s.model()); } }; template struct strategy_converter> { struct altered_strategy : strategies::relate::geographic < FormulaPolicy, strategy::default_order::value, Spheroid, CalculationType > { altered_strategy(Spheroid const& spheroid) : strategies::relate::geographic < FormulaPolicy, strategy::default_order::value, Spheroid, CalculationType >(spheroid) {} template auto covered_by(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_pointlike::value && util::is_box::value > * = nullptr) const { return strategy::covered_by::geographic_point_box_by_side < FormulaPolicy, Spheroid, CalculationType >(this->model()); } template auto within(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_pointlike::value && util::is_box::value > * = nullptr) const { return strategy::within::geographic_point_box_by_side < FormulaPolicy, Spheroid, CalculationType >(this->model()); } }; static auto get(strategy::covered_by::geographic_point_box_by_side const& s) { return altered_strategy(s.model()); } static auto get(strategy::within::geographic_point_box_by_side const& s) { return altered_strategy(s.model()); } }; template struct strategy_converter> : strategy_converter> {}; // TEMP used in distance segment/box template struct strategy_converter> { static auto get(strategy::side::geographic const& s) { return strategies::relate::geographic < FormulaPolicy, strategy::default_order::value, Spheroid, CalculationType >(s.model()); } }; } // namespace services }} // namespace strategies::relate }} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_RELATE_GEOGRAPHIC_HPP