geographic.hpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // Boost.Geometry
  2. // Copyright (c) 2020-2021, 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_GEOGRAPHIC_HPP
  7. #define BOOST_GEOMETRY_STRATEGIES_ENVELOPE_GEOGRAPHIC_HPP
  8. #include <type_traits>
  9. #include <boost/geometry/strategy/geographic/envelope.hpp> // Not used, for backward compatibility
  10. #include <boost/geometry/strategy/geographic/envelope_range.hpp>
  11. #include <boost/geometry/strategy/geographic/envelope_segment.hpp>
  12. #include <boost/geometry/strategies/envelope/spherical.hpp>
  13. #include <boost/geometry/strategies/expand/geographic.hpp>
  14. namespace boost { namespace geometry
  15. {
  16. namespace strategies { namespace envelope
  17. {
  18. template
  19. <
  20. typename FormulaPolicy = strategy::andoyer,
  21. typename Spheroid = srs::spheroid<double>,
  22. typename CalculationType = void
  23. >
  24. class geographic
  25. : public strategies::expand::geographic<FormulaPolicy, Spheroid, CalculationType>
  26. {
  27. using base_t = strategies::expand::geographic<FormulaPolicy, Spheroid, CalculationType>;
  28. public:
  29. geographic() = default;
  30. explicit geographic(Spheroid const& spheroid)
  31. : base_t(spheroid)
  32. {}
  33. template <typename Geometry, typename Box>
  34. static auto envelope(Geometry const&, Box const&,
  35. util::enable_if_point_t<Geometry> * = nullptr)
  36. {
  37. return strategy::envelope::spherical_point();
  38. }
  39. template <typename Geometry, typename Box>
  40. static auto envelope(Geometry const&, Box const&,
  41. util::enable_if_multi_point_t<Geometry> * = nullptr)
  42. {
  43. return strategy::envelope::spherical_multipoint();
  44. }
  45. template <typename Geometry, typename Box>
  46. static auto envelope(Geometry const&, Box const&,
  47. util::enable_if_box_t<Geometry> * = nullptr)
  48. {
  49. return strategy::envelope::spherical_box();
  50. }
  51. template <typename Geometry, typename Box>
  52. auto envelope(Geometry const&, Box const&,
  53. util::enable_if_segment_t<Geometry> * = nullptr) const
  54. {
  55. return strategy::envelope::geographic_segment
  56. <
  57. FormulaPolicy, Spheroid, CalculationType
  58. >(base_t::m_spheroid);
  59. }
  60. template <typename Geometry, typename Box>
  61. auto envelope(Geometry const&, Box const&,
  62. util::enable_if_linestring_t<Geometry> * = nullptr) const
  63. {
  64. return strategy::envelope::geographic_linestring
  65. <
  66. FormulaPolicy, Spheroid, CalculationType
  67. >(base_t::m_spheroid);
  68. }
  69. template <typename Geometry, typename Box>
  70. auto envelope(Geometry const&, Box const&,
  71. std::enable_if_t
  72. <
  73. util::is_ring<Geometry>::value
  74. || util::is_polygon<Geometry>::value
  75. > * = nullptr) const
  76. {
  77. return strategy::envelope::geographic_ring
  78. <
  79. FormulaPolicy, Spheroid, CalculationType
  80. >(base_t::m_spheroid);
  81. }
  82. template <typename Geometry, typename Box>
  83. auto envelope(Geometry const&, Box const&,
  84. std::enable_if_t
  85. <
  86. util::is_multi_linestring<Geometry>::value
  87. || util::is_multi_polygon<Geometry>::value
  88. || util::is_geometry_collection<Geometry>::value
  89. > * = nullptr) const
  90. {
  91. return strategy::envelope::spherical_boxes();
  92. }
  93. };
  94. namespace services
  95. {
  96. template <typename Geometry, typename Box>
  97. struct default_strategy<Geometry, Box, geographic_tag>
  98. {
  99. using type = strategies::envelope::geographic<>;
  100. };
  101. template <typename FP, typename S, typename CT>
  102. struct strategy_converter<strategy::envelope::geographic_segment<FP, S, CT> >
  103. {
  104. static auto get(strategy::envelope::geographic_segment<FP, S, CT> const& s)
  105. {
  106. return strategies::envelope::geographic<FP, S, CT>(s.model());
  107. }
  108. };
  109. template <typename FP, typename S, typename CT>
  110. struct strategy_converter<strategy::envelope::geographic<FP, S, CT> >
  111. {
  112. static auto get(strategy::envelope::geographic<FP, S, CT> const& s)
  113. {
  114. return strategies::envelope::geographic<FP, S, CT>(s.model());
  115. }
  116. };
  117. } // namespace services
  118. }} // namespace strategies::envelope
  119. }} // namespace boost::geometry
  120. #endif // BOOST_GEOMETRY_STRATEGIES_ENVELOPE_GEOGRAPHIC_HPP