123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- // 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_CARTESIAN_HPP
- #define BOOST_GEOMETRY_STRATEGIES_INDEX_CARTESIAN_HPP
- // TODO: move to strategy directory
- #include <boost/geometry/strategies/cartesian/distance_projected_point.hpp>
- #include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
- #include <boost/geometry/strategies/cartesian/distance_segment_box.hpp>
- #include <boost/geometry/strategies/index/services.hpp>
- #include <boost/geometry/strategies/relate/cartesian.hpp>
- namespace boost { namespace geometry { namespace strategies { namespace index
- {
- template <typename CalculationType = void>
- class cartesian
- : public relate::cartesian<CalculationType>
- {
- public:
- template <typename Geometry1, typename Geometry2>
- static auto comparable_distance(Geometry1 const&, Geometry2 const&,
- std::enable_if_t
- <
- util::is_pointlike<Geometry1>::value
- && util::is_pointlike<Geometry2>::value
- > * = nullptr)
- {
- //return geometry::strategy::distance::comparable::pythagoras<CalculationType>();
- return geometry::strategy::distance::pythagoras<CalculationType>();
- }
- template <typename Geometry1, typename Geometry2>
- static auto comparable_distance(Geometry1 const&, Geometry2 const&,
- std::enable_if_t
- <
- (util::is_pointlike<Geometry1>::value
- && util::is_segment<Geometry2>::value)
- || (util::is_segment<Geometry1>::value
- && util::is_pointlike<Geometry2>::value)
- > * = nullptr)
- {
- return geometry::strategy::distance::projected_point
- <
- CalculationType,
- //geometry::strategy::distance::comparable::pythagoras<CalculationType>
- geometry::strategy::distance::pythagoras<CalculationType>
- >();
- }
- template <typename Geometry1, typename Geometry2>
- static auto comparable_distance(Geometry1 const&, Geometry2 const&,
- std::enable_if_t
- <
- (util::is_pointlike<Geometry1>::value
- && util::is_box<Geometry2>::value)
- || (util::is_box<Geometry1>::value
- && util::is_pointlike<Geometry2>::value)
- > * = nullptr)
- {
- //return geometry::strategy::distance::comparable::pythagoras_point_box<CalculationType>();
- return geometry::strategy::distance::pythagoras_point_box<CalculationType>();
- }
- template <typename Geometry1, typename Geometry2>
- static auto comparable_distance(Geometry1 const&, Geometry2 const&,
- std::enable_if_t
- <
- (util::is_segment<Geometry1>::value
- && util::is_box<Geometry2>::value)
- || (util::is_box<Geometry1>::value
- && util::is_segment<Geometry2>::value)
- > * = nullptr)
- {
- return geometry::strategy::distance::cartesian_segment_box
- <
- CalculationType,
- //geometry::strategy::distance::comparable::pythagoras<CalculationType>
- geometry::strategy::distance::pythagoras<CalculationType>
- >();
- }
- template <typename Geometry1, typename Geometry2>
- static auto comparable_distance(Geometry1 const&, Geometry2 const&,
- std::enable_if_t
- <
- util::is_segment<Geometry1>::value
- && util::is_segment<Geometry2>::value
- > * = nullptr)
- {
- return strategy::distance::projected_point
- <
- CalculationType,
- //strategy::distance::comparable::pythagoras<CalculationType>
- strategy::distance::pythagoras<CalculationType>
- >();
- }
- };
- namespace services
- {
- template <typename Geometry>
- struct default_strategy<Geometry, cartesian_tag>
- {
- using type = strategies::index::cartesian<>;
- };
- // TEMP - needed in distance until umbrella strategies are supported
- template <typename CalculationType, typename SubStrategy>
- struct strategy_converter<strategy::distance::projected_point<CalculationType, SubStrategy>>
- {
- static auto get(strategy::distance::projected_point<CalculationType, SubStrategy> const& )
- {
- return strategies::index::cartesian<CalculationType>();
- }
- };
- // TEMP - needed in distance until umbrella strategies are supported
- template <typename CalculationType>
- struct strategy_converter<strategy::distance::comparable::pythagoras<CalculationType>>
- {
- static auto get(strategy::distance::comparable::pythagoras<CalculationType> const&)
- {
- return strategies::index::cartesian<CalculationType>();
- }
- };
- } // namespace services
- }}}} // namespace boost::geometry::strategy::index
- #endif // BOOST_GEOMETRY_STRATEGIES_INDEX_CARTESIAN_HPP
|