envelope.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. // This file was modified by Oracle on 2015-2020.
  6. // Modifications copyright (c) 2015-2020, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  8. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  9. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  10. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  11. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  12. // Distributed under the Boost Software License, Version 1.0.
  13. // (See accompanying file LICENSE_1_0.txt or copy at
  14. // http://www.boost.org/LICENSE_1_0.txt)
  15. #ifndef BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_HPP
  16. #define BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_HPP
  17. #include <boost/range/begin.hpp>
  18. #include <boost/range/end.hpp>
  19. #include <boost/geometry/algorithms/detail/envelope/initialize.hpp>
  20. #include <boost/geometry/strategy/cartesian/envelope_box.hpp>
  21. #include <boost/geometry/strategy/cartesian/envelope_segment.hpp>
  22. #include <boost/geometry/strategy/cartesian/expand_box.hpp>
  23. #include <boost/geometry/strategy/cartesian/expand_segment.hpp>
  24. namespace boost { namespace geometry
  25. {
  26. namespace strategy { namespace envelope
  27. {
  28. template <typename CalculationType = void>
  29. class cartesian
  30. {
  31. public:
  32. typedef cartesian_tag cs_tag;
  33. // Linestring, Ring, Polygon
  34. template <typename Range>
  35. static inline typename boost::range_iterator<Range const>::type begin(Range const& range)
  36. {
  37. return boost::begin(range);
  38. }
  39. template <typename Range>
  40. static inline typename boost::range_iterator<Range const>::type end(Range const& range)
  41. {
  42. return boost::end(range);
  43. }
  44. // MultiLinestring, MultiPolygon
  45. template <typename Box>
  46. struct multi_state
  47. {
  48. multi_state()
  49. : m_initialized(false)
  50. {}
  51. void apply(Box const& single_box)
  52. {
  53. if (! m_initialized)
  54. {
  55. m_box = single_box;
  56. m_initialized = true;
  57. }
  58. else
  59. {
  60. strategy::expand::cartesian_box::apply(m_box, single_box);
  61. }
  62. }
  63. void result(Box & box)
  64. {
  65. if (m_initialized)
  66. {
  67. box = m_box;
  68. }
  69. else
  70. {
  71. geometry::detail::envelope::initialize<Box, 0, dimension<Box>::value>::apply(box);
  72. }
  73. }
  74. private:
  75. bool m_initialized;
  76. Box m_box;
  77. };
  78. };
  79. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  80. namespace services
  81. {
  82. template <typename Tag, typename CalculationType>
  83. struct default_strategy<Tag, cartesian_tag, CalculationType>
  84. {
  85. typedef strategy::envelope::cartesian<CalculationType> type;
  86. };
  87. } // namespace services
  88. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  89. }} // namespace strategy::envelope
  90. }} //namepsace boost::geometry
  91. #endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_HPP