geographic.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Boost.Geometry
  2. // Copyright (c) 2019-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_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()
  29. : base_t()
  30. {}
  31. explicit geographic(Spheroid const& spheroid)
  32. : base_t(spheroid)
  33. {}
  34. auto point_order() const
  35. {
  36. return strategy::point_order::geographic
  37. <
  38. FormulaPolicy, Spheroid, CalculationType
  39. >(base_t::m_spheroid);
  40. }
  41. template <typename Geometry1, typename Geometry2>
  42. static auto relate(Geometry1 const&, Geometry2 const&,
  43. std::enable_if_t
  44. <
  45. util::is_pointlike<Geometry1>::value
  46. && util::is_pointlike<Geometry2>::value
  47. > * = nullptr)
  48. {
  49. return strategy::within::spherical_point_point();
  50. }
  51. template <typename Geometry1, typename Geometry2>
  52. auto relate(Geometry1 const&, Geometry2 const&,
  53. std::enable_if_t
  54. <
  55. util::is_pointlike<Geometry1>::value
  56. && ( util::is_linear<Geometry2>::value
  57. || util::is_polygonal<Geometry2>::value )
  58. > * = nullptr) const
  59. {
  60. return strategy::within::geographic_winding
  61. <
  62. void, void,
  63. FormulaPolicy, Spheroid, CalculationType
  64. >(base_t::m_spheroid);
  65. }
  66. };
  67. namespace services
  68. {
  69. template <typename Geometry>
  70. struct default_strategy<Geometry, geographic_tag>
  71. {
  72. typedef geographic<> type;
  73. };
  74. } // namespace services
  75. }} // namespace strategies::io
  76. }} // namespace boost::geometry
  77. #endif // BOOST_GEOMETRY_STRATEGIES_IO_GEOGRAPHIC_HPP