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.
8 // Modifications copyright (c) 2015-2016, 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 
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15 
16 // Distributed under the Boost Software License, Version 1.0.
17 // (See accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
19 
20 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_IMPLEMENTATION_HPP
21 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_IMPLEMENTATION_HPP
22 
23 #include <boost/geometry/core/exterior_ring.hpp>
24 #include <boost/geometry/core/interior_rings.hpp>
25 #include <boost/geometry/core/tags.hpp>
26 
27 #include <boost/geometry/algorithms/is_empty.hpp>
28 
29 #include <boost/geometry/algorithms/detail/envelope/box.hpp>
30 #include <boost/geometry/algorithms/detail/envelope/linear.hpp>
31 #include <boost/geometry/algorithms/detail/envelope/multipoint.hpp>
32 #include <boost/geometry/algorithms/detail/envelope/point.hpp>
33 #include <boost/geometry/algorithms/detail/envelope/range.hpp>
34 #include <boost/geometry/algorithms/detail/envelope/segment.hpp>
35 
36 #include <boost/geometry/algorithms/dispatch/envelope.hpp>
37 
38 
39 namespace boost { namespace geometry
40 {
41 
42 #ifndef DOXYGEN_NO_DETAIL
43 namespace detail { namespace envelope
44 {
45 
46 
47 struct envelope_polygon
48 {
49     template <typename Polygon, typename Box, typename Strategy>
applyboost::geometry::detail::envelope::envelope_polygon50     static inline void apply(Polygon const& polygon, Box& mbr, Strategy const& strategy)
51     {
52         typename ring_return_type<Polygon const>::type ext_ring
53             = exterior_ring(polygon);
54 
55         if (geometry::is_empty(ext_ring))
56         {
57             // if the exterior ring is empty, consider the interior rings
58             envelope_multi_range
59                 <
60                     envelope_range
61                 >::apply(interior_rings(polygon), mbr, strategy);
62         }
63         else
64         {
65             // otherwise, consider only the exterior ring
66             envelope_range::apply(ext_ring, mbr, strategy);
67         }
68     }
69 };
70 
71 
72 }} // namespace detail::envelope
73 #endif // DOXYGEN_NO_DETAIL
74 
75 #ifndef DOXYGEN_NO_DISPATCH
76 namespace dispatch
77 {
78 
79 
80 template <typename Ring>
81 struct envelope<Ring, ring_tag>
82     : detail::envelope::envelope_range
83 {};
84 
85 
86 template <typename Polygon>
87 struct envelope<Polygon, polygon_tag>
88     : detail::envelope::envelope_polygon
89 {};
90 
91 
92 template <typename MultiPolygon>
93 struct envelope<MultiPolygon, multi_polygon_tag>
94     : detail::envelope::envelope_multi_range
95         <
96             detail::envelope::envelope_polygon
97         >
98 {};
99 
100 
101 } // namespace dispatch
102 #endif // DOXYGEN_NO_DISPATCH
103 
104 
105 }} // namespace boost::geometry
106 
107 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_IMPLEMENTATION_HPP
108