geographic.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_EXPAND_GEOGRAPHIC_HPP
  7. #define BOOST_GEOMETRY_STRATEGIES_EXPAND_GEOGRAPHIC_HPP
  8. #include <type_traits>
  9. #include <boost/geometry/strategy/geographic/expand_segment.hpp>
  10. #include <boost/geometry/strategies/detail.hpp>
  11. #include <boost/geometry/strategies/expand/spherical.hpp>
  12. namespace boost { namespace geometry
  13. {
  14. namespace strategies { namespace expand
  15. {
  16. template
  17. <
  18. typename FormulaPolicy = strategy::andoyer,
  19. typename Spheroid = srs::spheroid<double>,
  20. typename CalculationType = void
  21. >
  22. class geographic
  23. : public strategies::detail::geographic_base<Spheroid>
  24. {
  25. using base_t = strategies::detail::geographic_base<Spheroid>;
  26. public:
  27. geographic() = default;
  28. explicit geographic(Spheroid const& spheroid)
  29. : base_t(spheroid)
  30. {}
  31. template <typename Box, typename Geometry>
  32. static auto expand(Box const&, Geometry const&,
  33. typename util::enable_if_point_t<Geometry> * = nullptr)
  34. {
  35. return strategy::expand::spherical_point();
  36. }
  37. template <typename Box, typename Geometry>
  38. static auto expand(Box const&, Geometry const&,
  39. typename util::enable_if_box_t<Geometry> * = nullptr)
  40. {
  41. return strategy::expand::spherical_box();
  42. }
  43. template <typename Box, typename Geometry>
  44. auto expand(Box const&, Geometry const&,
  45. typename util::enable_if_segment_t<Geometry> * = nullptr) const
  46. {
  47. return strategy::expand::geographic_segment
  48. <
  49. FormulaPolicy, Spheroid, CalculationType
  50. >(base_t::m_spheroid);
  51. }
  52. };
  53. namespace services
  54. {
  55. template <typename Box, typename Geometry>
  56. struct default_strategy<Box, Geometry, geographic_tag>
  57. {
  58. using type = strategies::expand::geographic<>;
  59. };
  60. template <typename FP, typename S, typename CT>
  61. struct strategy_converter<strategy::expand::geographic_segment<FP, S, CT> >
  62. {
  63. static auto get(strategy::expand::geographic_segment<FP, S, CT> const& s)
  64. {
  65. return strategies::expand::geographic<FP, S, CT>(s.model());
  66. }
  67. };
  68. } // namespace services
  69. }} // namespace strategies::envelope
  70. }} // namespace boost::geometry
  71. #endif // BOOST_GEOMETRY_STRATEGIES_EXPAND_GEOGRAPHIC_HPP