cartesian.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // Boost.Geometry
  2. // Copyright (c) 2020, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  4. // Licensed under the Boost Software License version 1.0.
  5. // http://www.boost.org/users/license.html
  6. #ifndef BOOST_GEOMETRY_STRATEGIES_ENVELOPE_CARTESIAN_HPP
  7. #define BOOST_GEOMETRY_STRATEGIES_ENVELOPE_CARTESIAN_HPP
  8. #include <type_traits>
  9. #include <boost/geometry/strategy/cartesian/envelope.hpp>
  10. #include <boost/geometry/strategy/cartesian/envelope_box.hpp>
  11. #include <boost/geometry/strategy/cartesian/envelope_point.hpp>
  12. #include <boost/geometry/strategy/cartesian/envelope_multipoint.hpp>
  13. #include <boost/geometry/strategy/cartesian/envelope_segment.hpp>
  14. #include <boost/geometry/strategies/detail.hpp>
  15. #include <boost/geometry/strategies/envelope/services.hpp>
  16. #include <boost/geometry/strategies/expand/cartesian.hpp>
  17. namespace boost { namespace geometry
  18. {
  19. namespace strategies { namespace envelope
  20. {
  21. template <typename CalculationType = void>
  22. struct cartesian
  23. : strategies::expand::cartesian<CalculationType>
  24. {
  25. template <typename Geometry, typename Box>
  26. static auto envelope(Geometry const&, Box const&,
  27. typename util::enable_if_point_t<Geometry> * = nullptr)
  28. {
  29. return strategy::envelope::cartesian_point();
  30. }
  31. template <typename Geometry, typename Box>
  32. static auto envelope(Geometry const&, Box const&,
  33. typename util::enable_if_multi_point_t<Geometry> * = nullptr)
  34. {
  35. return strategy::envelope::cartesian_multipoint();
  36. }
  37. template <typename Geometry, typename Box>
  38. static auto envelope(Geometry const&, Box const&,
  39. typename util::enable_if_box_t<Geometry> * = nullptr)
  40. {
  41. return strategy::envelope::cartesian_box();
  42. }
  43. template <typename Geometry, typename Box>
  44. static auto envelope(Geometry const&, Box const&,
  45. typename util::enable_if_segment_t<Geometry> * = nullptr)
  46. {
  47. return strategy::envelope::cartesian_segment<CalculationType>();
  48. }
  49. template <typename Geometry, typename Box>
  50. static auto envelope(Geometry const&, Box const&,
  51. typename util::enable_if_polysegmental_t<Geometry> * = nullptr)
  52. {
  53. return strategy::envelope::cartesian<CalculationType>();
  54. }
  55. };
  56. namespace services
  57. {
  58. template <typename Geometry, typename Box>
  59. struct default_strategy<Geometry, Box, cartesian_tag>
  60. {
  61. using type = strategies::envelope::cartesian<>;
  62. };
  63. template <>
  64. struct strategy_converter<strategy::envelope::cartesian_point>
  65. {
  66. static auto get(strategy::envelope::cartesian_point const& )
  67. {
  68. return strategies::envelope::cartesian<>();
  69. }
  70. };
  71. template <>
  72. struct strategy_converter<strategy::envelope::cartesian_multipoint>
  73. {
  74. static auto get(strategy::envelope::cartesian_multipoint const&)
  75. {
  76. return strategies::envelope::cartesian<>();
  77. }
  78. };
  79. template <>
  80. struct strategy_converter<strategy::envelope::cartesian_box>
  81. {
  82. static auto get(strategy::envelope::cartesian_box const& )
  83. {
  84. return strategies::envelope::cartesian<>();
  85. }
  86. };
  87. template <typename CT>
  88. struct strategy_converter<strategy::envelope::cartesian_segment<CT> >
  89. {
  90. static auto get(strategy::envelope::cartesian_segment<CT> const&)
  91. {
  92. return strategies::envelope::cartesian<CT>();
  93. }
  94. };
  95. template <typename CT>
  96. struct strategy_converter<strategy::envelope::cartesian<CT> >
  97. {
  98. static auto get(strategy::envelope::cartesian<CT> const&)
  99. {
  100. return strategies::envelope::cartesian<CT>();
  101. }
  102. };
  103. } // namespace services
  104. }} // namespace strategies::envelope
  105. }} // namespace boost::geometry
  106. #endif // BOOST_GEOMETRY_STRATEGIES_ENVELOPE_CARTESIAN_HPP