geographic.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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_GEOGRAPHIC_HPP
  7. #define BOOST_GEOMETRY_STRATEGIES_ENVELOPE_GEOGRAPHIC_HPP
  8. #include <type_traits>
  9. #include <boost/geometry/strategy/geographic/envelope.hpp>
  10. #include <boost/geometry/strategy/geographic/envelope_segment.hpp>
  11. #include <boost/geometry/strategy/geographic/expand_segment.hpp> // TEMP
  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()
  30. : base_t()
  31. {}
  32. explicit geographic(Spheroid const& spheroid)
  33. : base_t(spheroid)
  34. {}
  35. template <typename Geometry, typename Box>
  36. static auto envelope(Geometry const&, Box const&,
  37. typename util::enable_if_point_t<Geometry> * = nullptr)
  38. {
  39. return strategy::envelope::spherical_point();
  40. }
  41. template <typename Geometry, typename Box>
  42. static auto envelope(Geometry const&, Box const&,
  43. typename util::enable_if_multi_point_t<Geometry> * = nullptr)
  44. {
  45. return strategy::envelope::spherical_multipoint();
  46. }
  47. template <typename Geometry, typename Box>
  48. static auto envelope(Geometry const&, Box const&,
  49. typename util::enable_if_box_t<Geometry> * = nullptr)
  50. {
  51. return strategy::envelope::spherical_box();
  52. }
  53. template <typename Geometry, typename Box>
  54. auto envelope(Geometry const&, Box const&,
  55. typename util::enable_if_segment_t<Geometry> * = nullptr) const
  56. {
  57. return strategy::envelope::geographic_segment
  58. <
  59. FormulaPolicy, Spheroid, CalculationType
  60. >(base_t::m_spheroid);
  61. }
  62. template <typename Geometry, typename Box>
  63. auto envelope(Geometry const&, Box const&,
  64. typename util::enable_if_polysegmental_t<Geometry> * = nullptr) const
  65. {
  66. return strategy::envelope::geographic
  67. <
  68. FormulaPolicy, Spheroid, CalculationType
  69. >(base_t::m_spheroid);
  70. }
  71. };
  72. namespace services
  73. {
  74. template <typename Geometry, typename Box>
  75. struct default_strategy<Geometry, Box, geographic_tag>
  76. {
  77. using type = strategies::envelope::geographic<>;
  78. };
  79. template <typename FP, typename S, typename CT>
  80. struct strategy_converter<strategy::envelope::geographic_segment<FP, S, CT> >
  81. {
  82. static auto get(strategy::envelope::geographic_segment<FP, S, CT> const& s)
  83. {
  84. return strategies::envelope::geographic<FP, S, CT>(s.model());
  85. }
  86. };
  87. template <typename FP, typename S, typename CT>
  88. struct strategy_converter<strategy::envelope::geographic<FP, S, CT> >
  89. {
  90. static auto get(strategy::envelope::geographic<FP, S, CT> const& s)
  91. {
  92. return strategies::envelope::geographic<FP, S, CT>(s.model());
  93. }
  94. };
  95. } // namespace services
  96. }} // namespace strategies::envelope
  97. }} // namespace boost::geometry
  98. #endif // BOOST_GEOMETRY_STRATEGIES_ENVELOPE_GEOGRAPHIC_HPP