1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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.
7 // This file was modified by Oracle on 2015.
8 // Modifications copyright (c) 2015, Oracle and/or its affiliates.
10 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15 // Distributed under the Boost Software License, Version 1.0.
16 // (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
19 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_IMPLEMENTATION_HPP
20 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_IMPLEMENTATION_HPP
22 #include <boost/geometry/core/exterior_ring.hpp>
23 #include <boost/geometry/core/interior_rings.hpp>
24 #include <boost/geometry/core/tags.hpp>
26 #include <boost/geometry/algorithms/is_empty.hpp>
28 #include <boost/geometry/algorithms/detail/envelope/box.hpp>
29 #include <boost/geometry/algorithms/detail/envelope/linear.hpp>
30 #include <boost/geometry/algorithms/detail/envelope/multipoint.hpp>
31 #include <boost/geometry/algorithms/detail/envelope/point.hpp>
32 #include <boost/geometry/algorithms/detail/envelope/range.hpp>
33 #include <boost/geometry/algorithms/detail/envelope/segment.hpp>
35 #include <boost/geometry/algorithms/dispatch/envelope.hpp>
38 namespace boost { namespace geometry
41 #ifndef DOXYGEN_NO_DETAIL
42 namespace detail { namespace envelope
46 struct envelope_polygon
48 template <typename Polygon, typename Box>
49 static inline void apply(Polygon const& polygon, Box& mbr)
51 typename ring_return_type<Polygon const>::type ext_ring
52 = exterior_ring(polygon);
54 if (geometry::is_empty(ext_ring))
56 // if the exterior ring is empty, consider the interior rings
60 >::apply(interior_rings(polygon), mbr);
64 // otherwise, consider only the exterior ring
65 envelope_range::apply(ext_ring, mbr);
71 }} // namespace detail::envelope
72 #endif // DOXYGEN_NO_DETAIL
74 #ifndef DOXYGEN_NO_DISPATCH
79 template <typename Ring>
80 struct envelope<Ring, ring_tag>
81 : detail::envelope::envelope_range
85 template <typename Polygon>
86 struct envelope<Polygon, polygon_tag>
87 : detail::envelope::envelope_polygon
91 template <typename MultiPolygon>
92 struct envelope<MultiPolygon, multi_polygon_tag>
93 : detail::envelope::envelope_multi_range
95 detail::envelope::envelope_polygon
100 } // namespace dispatch
101 #endif // DOXYGEN_NO_DISPATCH
104 }} // namespace boost::geometry
106 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_IMPLEMENTATION_HPP