geographic.hpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Boost.Geometry
  2. // Copyright (c) 2019-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_IO_GEOGRAPHIC_HPP
  7. #define BOOST_GEOMETRY_STRATEGIES_IO_GEOGRAPHIC_HPP
  8. #include <boost/geometry/strategies/detail.hpp>
  9. #include <boost/geometry/strategies/io/services.hpp>
  10. #include <boost/geometry/strategies/geographic/point_order.hpp>
  11. #include <boost/geometry/strategies/geographic/point_in_poly_winding.hpp>
  12. #include <boost/geometry/strategies/spherical/point_in_point.hpp>
  13. namespace boost { namespace geometry
  14. {
  15. namespace strategies { namespace io
  16. {
  17. template
  18. <
  19. typename FormulaPolicy = strategy::andoyer,
  20. typename Spheroid = srs::spheroid<double>,
  21. typename CalculationType = void
  22. >
  23. class geographic
  24. : public strategies::detail::geographic_base<Spheroid>
  25. {
  26. using base_t = strategies::detail::geographic_base<Spheroid>;
  27. public:
  28. geographic() = default;
  29. explicit geographic(Spheroid const& spheroid)
  30. : base_t(spheroid)
  31. {}
  32. auto point_order() const
  33. {
  34. return strategy::point_order::geographic
  35. <
  36. FormulaPolicy, Spheroid, CalculationType
  37. >(base_t::m_spheroid);
  38. }
  39. template <typename Geometry1, typename Geometry2>
  40. static auto relate(Geometry1 const&, Geometry2 const&,
  41. std::enable_if_t
  42. <
  43. util::is_pointlike<Geometry1>::value
  44. && util::is_pointlike<Geometry2>::value
  45. > * = nullptr)
  46. {
  47. return strategy::within::spherical_point_point();
  48. }
  49. template <typename Geometry1, typename Geometry2>
  50. auto relate(Geometry1 const&, Geometry2 const&,
  51. std::enable_if_t
  52. <
  53. util::is_pointlike<Geometry1>::value
  54. && ( util::is_linear<Geometry2>::value
  55. || util::is_polygonal<Geometry2>::value )
  56. > * = nullptr) const
  57. {
  58. return strategy::within::geographic_winding
  59. <
  60. void, void,
  61. FormulaPolicy, Spheroid, CalculationType
  62. >(base_t::m_spheroid);
  63. }
  64. };
  65. namespace services
  66. {
  67. template <typename Geometry>
  68. struct default_strategy<Geometry, geographic_tag>
  69. {
  70. typedef geographic<> type;
  71. };
  72. } // namespace services
  73. }} // namespace strategies::io
  74. }} // namespace boost::geometry
  75. #endif // BOOST_GEOMETRY_STRATEGIES_IO_GEOGRAPHIC_HPP