// 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_CARTESIAN_HPP #define BOOST_GEOMETRY_STRATEGIES_RELATE_CARTESIAN_HPP // TEMP - move to strategy #include #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace geometry { namespace strategies { namespace relate { template class cartesian : public strategies::envelope::cartesian { public: //area template static auto area(Geometry const&) { return strategy::area::cartesian(); } // 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::cartesian_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::cartesian_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::cartesian_box_box(); } template static auto disjoint(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_segment::value && util::is_box::value > * = nullptr) { // NOTE: Inconsistent name. return strategy::disjoint::segment_box(); } // 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::cartesian_point_point(); } template static auto relate(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_pointlike::value && ( util::is_linear::value || util::is_polygonal::value ) > * = nullptr) { return strategy::within::cartesian_winding(); } // The problem is that this strategy is often used with non-geometry ranges. // So dispatching only by geometry categories is impossible. // In the past it was taking two segments, now it takes 3-point sub-ranges. // So dispatching by segments is impossible. // It could be dispatched by (linear || polygonal || non-geometry point range). // For now implement as 0-parameter, special case relate. //template static 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*/) { return strategy::intersection::cartesian_segments(); } // side static auto side() { return strategy::side::side_by_triangle(); } // 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::cartesian_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::cartesian_box_box(); } }; namespace services { template struct default_strategy { using type = strategies::relate::cartesian<>; }; template <> struct strategy_converter { static auto get(strategy::within::cartesian_point_point const& ) { return strategies::relate::cartesian<>(); } }; template <> struct strategy_converter { static auto get(strategy::within::cartesian_point_box const&) { return strategies::relate::cartesian<>(); } }; template <> struct strategy_converter { static auto get(strategy::covered_by::cartesian_point_box const&) { return strategies::relate::cartesian<>(); } }; template <> struct strategy_converter { static auto get(strategy::covered_by::cartesian_box_box const&) { return strategies::relate::cartesian<>(); } }; template <> struct strategy_converter { static auto get(strategy::disjoint::cartesian_box_box const&) { return strategies::relate::cartesian<>(); } }; template <> struct strategy_converter { static auto get(strategy::disjoint::segment_box const&) { return strategies::relate::cartesian<>(); } }; template <> struct strategy_converter { static auto get(strategy::within::cartesian_box_box const&) { return strategies::relate::cartesian<>(); } }; template struct strategy_converter> { static auto get(strategy::within::cartesian_winding const& ) { return strategies::relate::cartesian(); } }; template struct strategy_converter> { static auto get(strategy::intersection::cartesian_segments const& ) { return strategies::relate::cartesian(); } }; template struct strategy_converter> { struct altered_strategy : strategies::relate::cartesian { 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::cartesian_point_box_by_side(); } template static auto within(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_pointlike::value && util::is_box::value > * = nullptr) { return strategy::within::cartesian_point_box_by_side(); } }; static auto get(strategy::covered_by::cartesian_point_box_by_side const&) { return altered_strategy(); } static auto get(strategy::within::cartesian_point_box_by_side const&) { return altered_strategy(); } }; template struct strategy_converter> : strategy_converter> {}; template struct strategy_converter> { struct altered_strategy : strategies::relate::cartesian { template static auto relate(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_pointlike::value && ( util::is_linear::value || util::is_polygonal::value ) > * = nullptr) { return strategy::within::franklin(); } }; static auto get(strategy::within::franklin const&) { return altered_strategy(); } }; template struct strategy_converter> { struct altered_strategy : strategies::relate::cartesian { template static auto relate(Geometry1 const&, Geometry2 const&, std::enable_if_t < util::is_pointlike::value && ( util::is_linear::value || util::is_polygonal::value ) > * = nullptr) { return strategy::within::crossings_multiply(); } }; static auto get(strategy::within::crossings_multiply const&) { return altered_strategy(); } }; // TEMP used in distance segment/box template struct strategy_converter> { static auto get(strategy::side::side_by_triangle const&) { return strategies::relate::cartesian(); } }; } // namespace services }} // namespace strategies::relate }} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_RELATE_CARTESIAN_HPP