Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:35:04

0001 // Boost.Geometry
0002 
0003 // Copyright (c) 2018-2021 Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0006 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0007 
0008 // Use, modification and distribution is subject to the Boost Software License,
0009 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0010 // http://www.boost.org/LICENSE_1_0.txt)
0011 
0012 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_AREAL_HPP
0013 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_AREAL_HPP
0014 
0015 #include <boost/geometry/core/cs.hpp>
0016 #include <boost/geometry/core/tags.hpp>
0017 
0018 #include <boost/geometry/iterators/segment_iterator.hpp>
0019 
0020 #include <boost/geometry/algorithms/detail/envelope/range.hpp>
0021 #include <boost/geometry/algorithms/detail/envelope/linear.hpp>
0022 
0023 #include <boost/geometry/algorithms/dispatch/envelope.hpp>
0024 
0025 #include <boost/geometry/views/reversible_view.hpp>
0026 
0027 namespace boost { namespace geometry
0028 {
0029 
0030 #ifndef DOXYGEN_NO_DETAIL
0031 namespace detail { namespace envelope
0032 {
0033 
0034 
0035 struct envelope_hole
0036 {
0037     template <typename Range, typename Box, typename Strategies>
0038     static inline void apply(Range const& range, Box& mbr, Strategies const& strategies)
0039     {
0040         // Reverse holes to avoid calculating the envelope for the outside
0041         // in spherical and geographic coordinate systems
0042         detail::clockwise_view
0043             <
0044                 Range const,
0045                 geometry::point_order<Range>::value == counterclockwise
0046                     ? clockwise : counterclockwise
0047             > view(range);
0048         strategies.envelope(range, mbr).apply(view, mbr);
0049     }
0050 };
0051 
0052 struct envelope_polygon
0053 {
0054     template <typename Polygon, typename Box, typename Strategy>
0055     static inline void apply(Polygon const& polygon, Box& mbr, Strategy const& strategy)
0056     {
0057         ring_return_type_t<Polygon const> ext_ring = exterior_ring(polygon);
0058 
0059         if (geometry::is_empty(ext_ring))
0060         {
0061             // use dummy multi polygon to get the strategy because there is no multi ring concept
0062             using strategy_t = decltype(strategy.envelope(detail::dummy_multi_polygon(),
0063                                                           detail::dummy_box()));
0064             // if the exterior ring is empty, consider the interior rings
0065             envelope_multi_range
0066                 <
0067                     envelope_hole
0068                 >::template apply<strategy_t>(interior_rings(polygon), mbr, strategy);
0069         }
0070         else
0071         {
0072             // otherwise, consider only the exterior ring
0073             envelope_range::apply(ext_ring, mbr, strategy);
0074         }
0075     }
0076 };
0077 
0078 
0079 }} // namespace detail::envelope
0080 #endif // DOXYGEN_NO_DETAIL
0081 
0082 #ifndef DOXYGEN_NO_DISPATCH
0083 namespace dispatch
0084 {
0085 
0086 
0087 template <typename Ring>
0088 struct envelope<Ring, ring_tag>
0089     : detail::envelope::envelope_range
0090 {};
0091 
0092 template <typename Polygon>
0093 struct envelope<Polygon, polygon_tag>
0094     : detail::envelope::envelope_polygon
0095 {};
0096 
0097 template <typename MultiPolygon>
0098 struct envelope<MultiPolygon, multi_polygon_tag>
0099     : detail::envelope::envelope_multi_range
0100         <
0101             detail::envelope::envelope_polygon
0102         >
0103 {};
0104 
0105 
0106 } // namespace dispatch
0107 #endif // DOXYGEN_NO_DISPATCH
0108 
0109 
0110 }} // namespace boost::geometry
0111 
0112 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_AREAL_HPP