segment.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
  5. // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
  6. // This file was modified by Oracle on 2015, 2016, 2017.
  7. // Modifications copyright (c) 2015-2017, Oracle and/or its affiliates.
  8. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  9. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  10. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  11. // Distributed under the Boost Software License, Version 1.0.
  12. // (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_SEGMENT_HPP
  15. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_SEGMENT_HPP
  16. #include <boost/mpl/assert.hpp>
  17. #include <boost/type_traits/is_same.hpp>
  18. #include <boost/geometry/core/coordinate_dimension.hpp>
  19. #include <boost/geometry/core/tags.hpp>
  20. #include <boost/geometry/algorithms/detail/envelope/box.hpp>
  21. #include <boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp>
  22. #include <boost/geometry/algorithms/detail/envelope/segment.hpp>
  23. #include <boost/geometry/algorithms/detail/expand/indexed.hpp>
  24. #include <boost/geometry/algorithms/dispatch/expand.hpp>
  25. namespace boost { namespace geometry
  26. {
  27. #ifndef DOXYGEN_NO_DETAIL
  28. namespace detail { namespace expand
  29. {
  30. struct segment
  31. {
  32. template <typename Box, typename Segment, typename Strategy>
  33. static inline void apply(Box& box,
  34. Segment const& segment,
  35. Strategy const& strategy)
  36. {
  37. Box mbrs[2];
  38. // compute the envelope of the segment
  39. typename point_type<Segment>::type p[2];
  40. detail::assign_point_from_index<0>(segment, p[0]);
  41. detail::assign_point_from_index<1>(segment, p[1]);
  42. detail::envelope::envelope_segment
  43. <
  44. dimension<Segment>::value
  45. >::apply(p[0], p[1], mbrs[0], strategy);
  46. // normalize the box
  47. detail::envelope::envelope_box_on_spheroid::apply(box, mbrs[1], strategy);
  48. // compute the envelope of the two boxes
  49. detail::envelope::envelope_range_of_boxes::apply(mbrs, box, strategy);
  50. }
  51. };
  52. }} // namespace detail::expand
  53. #endif // DOXYGEN_NO_DETAIL
  54. #ifndef DOXYGEN_NO_DISPATCH
  55. namespace dispatch
  56. {
  57. template
  58. <
  59. typename Box, typename Segment,
  60. typename CSTagOut, typename CSTag
  61. >
  62. struct expand
  63. <
  64. Box, Segment,
  65. box_tag, segment_tag,
  66. CSTagOut, CSTag
  67. >
  68. {
  69. BOOST_MPL_ASSERT_MSG((false),
  70. NOT_IMPLEMENTED_FOR_THESE_COORDINATE_SYSTEMS,
  71. (types<CSTagOut, CSTag>()));
  72. };
  73. template
  74. <
  75. typename Box, typename Segment
  76. >
  77. struct expand
  78. <
  79. Box, Segment,
  80. box_tag, segment_tag,
  81. cartesian_tag, cartesian_tag
  82. > : detail::expand::expand_indexed
  83. <
  84. 0, dimension<Segment>::value
  85. >
  86. {};
  87. template <typename Box, typename Segment>
  88. struct expand
  89. <
  90. Box, Segment,
  91. box_tag, segment_tag,
  92. spherical_polar_tag, spherical_polar_tag
  93. > : detail::expand::segment
  94. {};
  95. template <typename Box, typename Segment>
  96. struct expand
  97. <
  98. Box, Segment,
  99. box_tag, segment_tag,
  100. spherical_equatorial_tag, spherical_equatorial_tag
  101. > : detail::expand::segment
  102. {};
  103. template <typename Box, typename Segment>
  104. struct expand
  105. <
  106. Box, Segment,
  107. box_tag, segment_tag,
  108. geographic_tag, geographic_tag
  109. > : detail::expand::segment
  110. {};
  111. } // namespace dispatch
  112. #endif // DOXYGEN_NO_DISPATCH
  113. }} // namespace boost::geometry
  114. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_SEGMENT_HPP