]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/include/boost/geometry/algorithms/detail/envelope/transform_units.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / algorithms / detail / envelope / transform_units.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2015, Oracle and/or its affiliates.
4
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
6
7 // Distributed under the Boost Software License, Version 1.0.
8 // (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10
11 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_TRANSFORM_UNITS_HPP
12 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_TRANSFORM_UNITS_HPP
13
14 #include <cstddef>
15
16 #include <boost/geometry/core/tag.hpp>
17 #include <boost/geometry/core/tags.hpp>
18
19 #include <boost/geometry/strategies/strategy_transform.hpp>
20
21 #include <boost/geometry/views/detail/indexed_point_view.hpp>
22 #include <boost/geometry/views/detail/two_dimensional_view.hpp>
23
24 #include <boost/geometry/algorithms/not_implemented.hpp>
25 #include <boost/geometry/algorithms/transform.hpp>
26
27
28 namespace boost { namespace geometry
29 {
30
31 #ifndef DOXYGEN_NO_DETAIL
32 namespace detail { namespace envelope
33 {
34
35
36 template
37 <
38 typename GeometryIn,
39 typename GeometryOut,
40 typename TagIn = typename tag<GeometryIn>::type,
41 typename TagOut = typename tag<GeometryOut>::type
42 >
43 struct transform_units_impl
44 : not_implemented<TagIn, TagOut>
45 {};
46
47 template <typename PointIn, typename PointOut>
48 struct transform_units_impl<PointIn, PointOut, point_tag, point_tag>
49 {
50 static inline void apply(PointIn const& point_in, PointOut& point_out)
51 {
52 detail::two_dimensional_view<PointIn const> view_in(point_in);
53 detail::two_dimensional_view<PointOut> view_out(point_out);
54
55 geometry::transform(view_in, view_out);
56 }
57 };
58
59 template <typename BoxIn, typename BoxOut>
60 struct transform_units_impl<BoxIn, BoxOut, box_tag, box_tag>
61 {
62 template <std::size_t Index>
63 static inline void apply(BoxIn const& box_in, BoxOut& box_out)
64 {
65 typedef detail::indexed_point_view<BoxIn const, Index> view_in_type;
66 typedef detail::indexed_point_view<BoxOut, Index> view_out_type;
67
68 view_in_type view_in(box_in);
69 view_out_type view_out(box_out);
70
71 transform_units_impl
72 <
73 view_in_type, view_out_type
74 >::apply(view_in, view_out);
75 }
76
77 static inline void apply(BoxIn const& box_in, BoxOut& box_out)
78 {
79 apply<min_corner>(box_in, box_out);
80 apply<max_corner>(box_in, box_out);
81 }
82 };
83
84
85 // Short utility to transform the units of the first two coordinates of
86 // geometry_in to the units of geometry_out
87 template <typename GeometryIn, typename GeometryOut>
88 inline void transform_units(GeometryIn const& geometry_in,
89 GeometryOut& geometry_out)
90 {
91 transform_units_impl
92 <
93 GeometryIn, GeometryOut
94 >::apply(geometry_in, geometry_out);
95 }
96
97
98 }} // namespace detail::envelope
99 #endif // DOXYGEN_NO_DETAIL
100
101 }} // namespace boost:geometry
102
103 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_TRANSFORM_UNITS_HPP