1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. 4 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. 5 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. 6 7 // This file was modified by Oracle on 2015, 2016, 2018, 2019. 8 // Modifications copyright (c) 2015-2019, Oracle and/or its affiliates. 9 10 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle 11 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle 12 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle 13 14 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library 15 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. 16 17 // Distributed under the Boost Software License, Version 1.0. 18 // (See accompanying file LICENSE_1_0.txt or copy at 19 // http://www.boost.org/LICENSE_1_0.txt) 20 21 #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_HPP 22 #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_HPP 23 24 #include <boost/range/begin.hpp> 25 #include <boost/range/end.hpp> 26 27 #include <boost/geometry/algorithms/detail/envelope/initialize.hpp> 28 29 #include <boost/geometry/strategies/cartesian/envelope_box.hpp> 30 #include <boost/geometry/strategies/cartesian/envelope_segment.hpp> 31 #include <boost/geometry/strategies/cartesian/expand_box.hpp> 32 #include <boost/geometry/strategies/cartesian/expand_segment.hpp> 33 34 namespace boost { namespace geometry 35 { 36 37 namespace strategy { namespace envelope 38 { 39 40 template <typename CalculationType = void> 41 class cartesian 42 { 43 public: 44 typedef cartesian_tag cs_tag; 45 46 typedef cartesian_point element_envelope_strategy_type; get_element_envelope_strategy()47 static inline element_envelope_strategy_type get_element_envelope_strategy() 48 { 49 return element_envelope_strategy_type(); 50 } 51 52 typedef expand::cartesian_point element_expand_strategy_type; get_element_expand_strategy()53 static inline element_expand_strategy_type get_element_expand_strategy() 54 { 55 return element_expand_strategy_type(); 56 } 57 58 typedef expand::cartesian_box box_expand_strategy_type; get_box_expand_strategy()59 static inline box_expand_strategy_type get_box_expand_strategy() 60 { 61 return box_expand_strategy_type(); 62 } 63 64 // Linestring, Ring, Polygon 65 66 template <typename Range> begin(Range const & range)67 static inline typename boost::range_iterator<Range const>::type begin(Range const& range) 68 { 69 return boost::begin(range); 70 } 71 72 template <typename Range> end(Range const & range)73 static inline typename boost::range_iterator<Range const>::type end(Range const& range) 74 { 75 return boost::end(range); 76 } 77 78 // MultiLinestring, MultiPolygon 79 80 template <typename Box> 81 struct multi_state 82 { multi_stateboost::geometry::strategy::envelope::cartesian::multi_state83 multi_state() 84 : m_initialized(false) 85 {} 86 applyboost::geometry::strategy::envelope::cartesian::multi_state87 void apply(Box const& single_box) 88 { 89 if (! m_initialized) 90 { 91 m_box = single_box; 92 m_initialized = true; 93 } 94 else 95 { 96 box_expand_strategy_type::apply(m_box, single_box); 97 } 98 } 99 resultboost::geometry::strategy::envelope::cartesian::multi_state100 void result(Box & box) 101 { 102 if (m_initialized) 103 { 104 box = m_box; 105 } 106 else 107 { 108 geometry::detail::envelope::initialize<Box, 0, dimension<Box>::value>::apply(box); 109 } 110 } 111 112 private: 113 bool m_initialized; 114 Box m_box; 115 }; 116 117 // Segment 118 119 template <typename Point1, typename Point2, typename Box> apply(Point1 const & point1,Point2 const & point2,Box & box)120 static inline void apply(Point1 const& point1, Point2 const& point2, 121 Box& box) 122 { 123 cartesian_segment<CalculationType>::apply(point1, point2, box); 124 } 125 126 // Box 127 128 template <typename BoxIn, typename Box> apply(BoxIn const & box_in,Box & box)129 static inline void apply(BoxIn const& box_in, Box& box) 130 { 131 cartesian_box::apply(box_in, box); 132 } 133 }; 134 135 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS 136 137 namespace services 138 { 139 140 template <typename Tag, typename CalculationType> 141 struct default_strategy<Tag, cartesian_tag, CalculationType> 142 { 143 typedef strategy::envelope::cartesian<CalculationType> type; 144 }; 145 146 } // namespace services 147 148 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS 149 150 151 }} // namespace strategy::envelope 152 153 }} //namepsace boost::geometry 154 155 #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_HPP 156