envelope_range.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // Boost.Geometry
  2. // Copyright (c) 2021-2022, 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_STRATEGY_GEOGRAPHIC_ENVELOPE_RANGE_HPP
  7. #define BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_ENVELOPE_RANGE_HPP
  8. #include <boost/geometry/strategy/geographic/envelope_segment.hpp>
  9. #include <boost/geometry/strategy/geographic/expand_segment.hpp>
  10. #include <boost/geometry/strategy/spherical/envelope_range.hpp>
  11. // Get rid of this dependency?
  12. #include <boost/geometry/strategies/spherical/point_in_poly_winding.hpp>
  13. namespace boost { namespace geometry
  14. {
  15. namespace strategy { namespace envelope
  16. {
  17. template
  18. <
  19. typename FormulaPolicy = strategy::andoyer,
  20. typename Spheroid = geometry::srs::spheroid<double>,
  21. typename CalculationType = void
  22. >
  23. class geographic_linestring
  24. {
  25. public:
  26. using model_type = Spheroid;
  27. geographic_linestring()
  28. : m_spheroid()
  29. {}
  30. explicit geographic_linestring(Spheroid const& spheroid)
  31. : m_spheroid(spheroid)
  32. {}
  33. template <typename Range, typename Box>
  34. void apply(Range const& range, Box& mbr) const
  35. {
  36. auto const envelope_s = envelope::geographic_segment
  37. <
  38. FormulaPolicy, Spheroid, CalculationType
  39. >(m_spheroid);
  40. auto const expand_s = expand::geographic_segment
  41. <
  42. FormulaPolicy, Spheroid, CalculationType
  43. >(m_spheroid);
  44. detail::spheroidal_linestring(range, mbr, envelope_s, expand_s);
  45. }
  46. Spheroid model() const
  47. {
  48. return m_spheroid;
  49. }
  50. private:
  51. Spheroid m_spheroid;
  52. };
  53. template
  54. <
  55. typename FormulaPolicy = strategy::andoyer,
  56. typename Spheroid = geometry::srs::spheroid<double>,
  57. typename CalculationType = void
  58. >
  59. class geographic_ring
  60. {
  61. public:
  62. using model_type = Spheroid;
  63. geographic_ring()
  64. : m_spheroid()
  65. {}
  66. explicit geographic_ring(Spheroid const& spheroid)
  67. : m_spheroid(spheroid)
  68. {}
  69. template <typename Range, typename Box>
  70. void apply(Range const& range, Box& mbr) const
  71. {
  72. auto const envelope_s = envelope::geographic_segment
  73. <
  74. FormulaPolicy, Spheroid, CalculationType
  75. >(m_spheroid);
  76. auto const expand_s = expand::geographic_segment
  77. <
  78. FormulaPolicy, Spheroid, CalculationType
  79. >(m_spheroid);
  80. auto const within_s = within::detail::spherical_winding_base
  81. <
  82. envelope::detail::side_of_pole<CalculationType>, CalculationType
  83. >();
  84. detail::spheroidal_ring(range, mbr, envelope_s, expand_s, within_s);
  85. }
  86. Spheroid model() const
  87. {
  88. return m_spheroid;
  89. }
  90. private:
  91. Spheroid m_spheroid;
  92. };
  93. }} // namespace strategy::envelope
  94. }} //namepsace boost::geometry
  95. #endif // BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_ENVELOPE_RANGE_HPP