]>
Commit | Line | Data |
---|---|---|
20effc67 TL |
1 | // Boost.Geometry |
2 | ||
3 | // Copyright (c) 2020, Oracle and/or its affiliates. | |
4 | ||
5 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
6 | ||
7 | // Licensed under the Boost Software License version 1.0. | |
8 | // http://www.boost.org/users/license.html | |
9 | ||
10 | #ifndef BOOST_GEOMETRY_STRATEGIES_ENVELOPE_CARTESIAN_HPP | |
11 | #define BOOST_GEOMETRY_STRATEGIES_ENVELOPE_CARTESIAN_HPP | |
12 | ||
13 | ||
14 | #include <type_traits> | |
15 | ||
1e59de90 | 16 | #include <boost/geometry/strategy/cartesian/envelope.hpp> // Not used, for backward compatibility |
20effc67 | 17 | #include <boost/geometry/strategy/cartesian/envelope_box.hpp> |
1e59de90 | 18 | #include <boost/geometry/strategy/cartesian/envelope_boxes.hpp> |
20effc67 | 19 | #include <boost/geometry/strategy/cartesian/envelope_multipoint.hpp> |
1e59de90 TL |
20 | #include <boost/geometry/strategy/cartesian/envelope_point.hpp> |
21 | #include <boost/geometry/strategy/cartesian/envelope_range.hpp> | |
20effc67 TL |
22 | #include <boost/geometry/strategy/cartesian/envelope_segment.hpp> |
23 | ||
20effc67 | 24 | #include <boost/geometry/strategies/envelope/services.hpp> |
1e59de90 | 25 | #include <boost/geometry/strategies/expand/cartesian.hpp> |
20effc67 TL |
26 | |
27 | ||
28 | namespace boost { namespace geometry | |
29 | { | |
30 | ||
31 | namespace strategies { namespace envelope | |
32 | { | |
33 | ||
34 | template <typename CalculationType = void> | |
1e59de90 TL |
35 | struct cartesian |
36 | : strategies::expand::cartesian<CalculationType> | |
20effc67 TL |
37 | { |
38 | template <typename Geometry, typename Box> | |
39 | static auto envelope(Geometry const&, Box const&, | |
1e59de90 | 40 | util::enable_if_point_t<Geometry> * = nullptr) |
20effc67 TL |
41 | { |
42 | return strategy::envelope::cartesian_point(); | |
43 | } | |
44 | ||
45 | template <typename Geometry, typename Box> | |
46 | static auto envelope(Geometry const&, Box const&, | |
1e59de90 | 47 | util::enable_if_multi_point_t<Geometry> * = nullptr) |
20effc67 TL |
48 | { |
49 | return strategy::envelope::cartesian_multipoint(); | |
50 | } | |
51 | ||
52 | template <typename Geometry, typename Box> | |
53 | static auto envelope(Geometry const&, Box const&, | |
1e59de90 | 54 | util::enable_if_box_t<Geometry> * = nullptr) |
20effc67 TL |
55 | { |
56 | return strategy::envelope::cartesian_box(); | |
57 | } | |
58 | ||
59 | template <typename Geometry, typename Box> | |
60 | static auto envelope(Geometry const&, Box const&, | |
1e59de90 | 61 | util::enable_if_segment_t<Geometry> * = nullptr) |
20effc67 TL |
62 | { |
63 | return strategy::envelope::cartesian_segment<CalculationType>(); | |
64 | } | |
65 | ||
66 | template <typename Geometry, typename Box> | |
67 | static auto envelope(Geometry const&, Box const&, | |
1e59de90 TL |
68 | std::enable_if_t |
69 | < | |
70 | util::is_linestring<Geometry>::value | |
71 | || util::is_ring<Geometry>::value | |
72 | || util::is_polygon<Geometry>::value | |
73 | > * = nullptr) | |
20effc67 | 74 | { |
1e59de90 | 75 | return strategy::envelope::cartesian_range(); |
20effc67 TL |
76 | } |
77 | ||
1e59de90 TL |
78 | template <typename Geometry, typename Box> |
79 | static auto envelope(Geometry const&, Box const&, | |
80 | std::enable_if_t | |
81 | < | |
82 | util::is_multi_linestring<Geometry>::value | |
83 | || util::is_multi_polygon<Geometry>::value | |
84 | || util::is_geometry_collection<Geometry>::value | |
85 | > * = nullptr) | |
20effc67 | 86 | { |
1e59de90 | 87 | return strategy::envelope::cartesian_boxes(); |
20effc67 TL |
88 | } |
89 | }; | |
90 | ||
91 | ||
92 | namespace services | |
93 | { | |
94 | ||
95 | template <typename Geometry, typename Box> | |
96 | struct default_strategy<Geometry, Box, cartesian_tag> | |
97 | { | |
98 | using type = strategies::envelope::cartesian<>; | |
99 | }; | |
100 | ||
101 | ||
102 | template <> | |
103 | struct strategy_converter<strategy::envelope::cartesian_point> | |
104 | { | |
105 | static auto get(strategy::envelope::cartesian_point const& ) | |
106 | { | |
107 | return strategies::envelope::cartesian<>(); | |
108 | } | |
109 | }; | |
110 | ||
111 | template <> | |
112 | struct strategy_converter<strategy::envelope::cartesian_multipoint> | |
113 | { | |
114 | static auto get(strategy::envelope::cartesian_multipoint const&) | |
115 | { | |
116 | return strategies::envelope::cartesian<>(); | |
117 | } | |
118 | }; | |
119 | ||
120 | template <> | |
121 | struct strategy_converter<strategy::envelope::cartesian_box> | |
122 | { | |
123 | static auto get(strategy::envelope::cartesian_box const& ) | |
124 | { | |
125 | return strategies::envelope::cartesian<>(); | |
126 | } | |
127 | }; | |
128 | ||
129 | template <typename CT> | |
130 | struct strategy_converter<strategy::envelope::cartesian_segment<CT> > | |
131 | { | |
132 | static auto get(strategy::envelope::cartesian_segment<CT> const&) | |
133 | { | |
134 | return strategies::envelope::cartesian<CT>(); | |
135 | } | |
136 | }; | |
137 | ||
138 | template <typename CT> | |
139 | struct strategy_converter<strategy::envelope::cartesian<CT> > | |
140 | { | |
141 | static auto get(strategy::envelope::cartesian<CT> const&) | |
142 | { | |
143 | return strategies::envelope::cartesian<CT>(); | |
144 | } | |
145 | }; | |
146 | ||
147 | ||
148 | } // namespace services | |
149 | ||
150 | }} // namespace strategies::envelope | |
151 | ||
152 | }} // namespace boost::geometry | |
153 | ||
154 | #endif // BOOST_GEOMETRY_STRATEGIES_ENVELOPE_CARTESIAN_HPP |