geographic.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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_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()
  28. : base_t()
  29. {}
  30. explicit geographic(Spheroid const& spheroid)
  31. : base_t(spheroid)
  32. {}
  33. template <typename Box, typename Geometry>
  34. static auto expand(Box const&, Geometry const&,
  35. typename util::enable_if_point_t<Geometry> * = nullptr)
  36. {
  37. return strategy::expand::spherical_point();
  38. }
  39. template <typename Box, typename Geometry>
  40. static auto expand(Box const&, Geometry const&,
  41. typename util::enable_if_box_t<Geometry> * = nullptr)
  42. {
  43. return strategy::expand::spherical_box();
  44. }
  45. template <typename Box, typename Geometry>
  46. auto expand(Box const&, Geometry const&,
  47. typename util::enable_if_segment_t<Geometry> * = nullptr) const
  48. {
  49. return strategy::expand::geographic_segment
  50. <
  51. FormulaPolicy, Spheroid, CalculationType
  52. >(base_t::m_spheroid);
  53. }
  54. };
  55. namespace services
  56. {
  57. template <typename Box, typename Geometry>
  58. struct default_strategy<Box, Geometry, geographic_tag>
  59. {
  60. using type = strategies::expand::geographic<>;
  61. };
  62. template <typename FP, typename S, typename CT>
  63. struct strategy_converter<strategy::expand::geographic_segment<FP, S, CT> >
  64. {
  65. static auto get(strategy::expand::geographic_segment<FP, S, CT> const& s)
  66. {
  67. return strategies::expand::geographic<FP, S, CT>(s.model());
  68. }
  69. };
  70. } // namespace services
  71. }} // namespace strategies::envelope
  72. }} // namespace boost::geometry
  73. #endif // BOOST_GEOMETRY_STRATEGIES_EXPAND_GEOGRAPHIC_HPP