geographic.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Boost.Geometry
  2. // Copyright (c) 2025 Adam Wulkiewicz, Lodz, Poland.
  3. // Copyright (c) 2021, Oracle and/or its affiliates.
  4. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  5. // Licensed under the Boost Software License version 1.0.
  6. // http://www.boost.org/users/license.html
  7. #ifndef BOOST_GEOMETRY_STRATEGIES_CENTROID_GEOGRAPHIC_HPP
  8. #define BOOST_GEOMETRY_STRATEGIES_CENTROID_GEOGRAPHIC_HPP
  9. #include <boost/geometry/strategies/detail.hpp>
  10. #include <boost/geometry/strategies/centroid.hpp>
  11. #include <boost/geometry/strategies/centroid/services.hpp>
  12. namespace boost { namespace geometry
  13. {
  14. namespace strategies { namespace centroid
  15. {
  16. #ifndef DOXYGEN_NO_DETAIL
  17. namespace detail
  18. {
  19. class geographic
  20. {
  21. public:
  22. // TODO: Box and Segment should have proper strategies.
  23. template <typename Geometry, typename Point>
  24. static auto centroid(Geometry const&, Point const&,
  25. std::enable_if_t
  26. <
  27. util::is_segment<Geometry>::value
  28. || util::is_box<Geometry>::value
  29. > * = nullptr)
  30. {
  31. return strategy::centroid::not_applicable_strategy();
  32. }
  33. };
  34. } // namespace detail
  35. #endif // DOXYGEN_NO_DETAIL
  36. template
  37. <
  38. typename FormulaPolicy = strategy::andoyer,
  39. typename Spheroid = srs::spheroid<double>,
  40. typename CalculationType = void
  41. >
  42. class geographic
  43. : public strategies::detail::geographic_base<Spheroid>
  44. , public strategies::centroid::detail::geographic
  45. {
  46. using base_t = strategies::detail::geographic_base<Spheroid>;
  47. public:
  48. geographic() = default;
  49. explicit geographic(Spheroid const& spheroid)
  50. : base_t(spheroid)
  51. {}
  52. };
  53. namespace services
  54. {
  55. template <typename Geometry>
  56. struct default_strategy<Geometry, geographic_tag>
  57. {
  58. using type = strategies::centroid::geographic<>;
  59. };
  60. } // namespace services
  61. }} // namespace strategies::centroid
  62. }} // namespace boost::geometry
  63. #endif // BOOST_GEOMETRY_STRATEGIES_CENTROID_GEOGRAPHIC_HPP