Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:05

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         typename ring_return_type<Polygon const>::type ext_ring
0058             = exterior_ring(polygon);
0059 
0060         if (geometry::is_empty(ext_ring))
0061         {
0062             // use dummy multi polygon to get the strategy because there is no multi ring concept
0063             using strategy_t = decltype(strategy.envelope(detail::dummy_multi_polygon(),
0064                                                           detail::dummy_box()));
0065             // if the exterior ring is empty, consider the interior rings
0066             envelope_multi_range
0067                 <
0068                     envelope_hole
0069                 >::template apply<strategy_t>(interior_rings(polygon), mbr, strategy);
0070         }
0071         else
0072         {
0073             // otherwise, consider only the exterior ring
0074             envelope_range::apply(ext_ring, mbr, strategy);
0075         }
0076     }
0077 };
0078 
0079 
0080 }} // namespace detail::envelope
0081 #endif // DOXYGEN_NO_DETAIL
0082 
0083 #ifndef DOXYGEN_NO_DISPATCH
0084 namespace dispatch
0085 {
0086 
0087 
0088 template <typename Ring>
0089 struct envelope<Ring, ring_tag>
0090     : detail::envelope::envelope_range
0091 {};
0092 
0093 template <typename Polygon>
0094 struct envelope<Polygon, polygon_tag>
0095     : detail::envelope::envelope_polygon
0096 {};
0097 
0098 template <typename MultiPolygon>
0099 struct envelope<MultiPolygon, multi_polygon_tag>
0100     : detail::envelope::envelope_multi_range
0101         <
0102             detail::envelope::envelope_polygon
0103         >
0104 {};
0105 
0106 
0107 } // namespace dispatch
0108 #endif // DOXYGEN_NO_DISPATCH
0109 
0110 
0111 }} // namespace boost::geometry
0112 
0113 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_AREAL_HPP