• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry
2 
3 // Copyright (c) 2018 Oracle and/or its affiliates.
4 
5 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7 
8 // Use, modification and distribution is subject to the Boost Software License,
9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
11 
12 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_AREAL_HPP
13 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_AREAL_HPP
14 
15 #include <boost/geometry/core/cs.hpp>
16 #include <boost/geometry/core/tags.hpp>
17 
18 #include <boost/geometry/iterators/segment_iterator.hpp>
19 
20 #include <boost/geometry/algorithms/detail/envelope/range.hpp>
21 #include <boost/geometry/algorithms/detail/envelope/linear.hpp>
22 
23 #include <boost/geometry/algorithms/dispatch/envelope.hpp>
24 
25 namespace boost { namespace geometry
26 {
27 
28 #ifndef DOXYGEN_NO_DETAIL
29 namespace detail { namespace envelope
30 {
31 
32 struct envelope_polygon
33 {
34     template <typename Polygon, typename Box, typename Strategy>
applyboost::geometry::detail::envelope::envelope_polygon35     static inline void apply(Polygon const& polygon, Box& mbr, Strategy const& strategy)
36     {
37         typename ring_return_type<Polygon const>::type ext_ring
38             = exterior_ring(polygon);
39 
40         if (geometry::is_empty(ext_ring))
41         {
42             // if the exterior ring is empty, consider the interior rings
43             envelope_multi_range
44                 <
45                     envelope_range
46                 >::apply(interior_rings(polygon), mbr, strategy);
47         }
48         else
49         {
50             // otherwise, consider only the exterior ring
51             envelope_range::apply(ext_ring, mbr, strategy);
52         }
53     }
54 };
55 
56 
57 }} // namespace detail::envelope
58 #endif // DOXYGEN_NO_DETAIL
59 
60 #ifndef DOXYGEN_NO_DISPATCH
61 namespace dispatch
62 {
63 
64 
65 template <typename Ring>
66 struct envelope<Ring, ring_tag>
67     : detail::envelope::envelope_range
68 {};
69 
70 template <typename Polygon>
71 struct envelope<Polygon, polygon_tag>
72     : detail::envelope::envelope_polygon
73 {};
74 
75 template <typename MultiPolygon>
76 struct envelope<MultiPolygon, multi_polygon_tag>
77     : detail::envelope::envelope_multi_range
78         <
79             detail::envelope::envelope_polygon
80         >
81 {};
82 
83 
84 } // namespace dispatch
85 #endif // DOXYGEN_NO_DISPATCH
86 
87 
88 }} // namespace boost::geometry
89 
90 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_AREAL_HPP
91