1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2015, Oracle and/or its affiliates.
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
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)
11 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_TRANSFORM_UNITS_HPP
12 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_TRANSFORM_UNITS_HPP
16 #include <boost/geometry/core/tag.hpp>
17 #include <boost/geometry/core/tags.hpp>
19 #include <boost/geometry/strategies/strategy_transform.hpp>
21 #include <boost/geometry/views/detail/indexed_point_view.hpp>
22 #include <boost/geometry/views/detail/two_dimensional_view.hpp>
24 #include <boost/geometry/algorithms/not_implemented.hpp>
25 #include <boost/geometry/algorithms/transform.hpp>
28 namespace boost { namespace geometry
31 #ifndef DOXYGEN_NO_DETAIL
32 namespace detail { namespace envelope
40 typename TagIn = typename tag<GeometryIn>::type,
41 typename TagOut = typename tag<GeometryOut>::type
43 struct transform_units_impl
44 : not_implemented<TagIn, TagOut>
47 template <typename PointIn, typename PointOut>
48 struct transform_units_impl<PointIn, PointOut, point_tag, point_tag>
50 static inline void apply(PointIn const& point_in, PointOut& point_out)
52 detail::two_dimensional_view<PointIn const> view_in(point_in);
53 detail::two_dimensional_view<PointOut> view_out(point_out);
55 geometry::transform(view_in, view_out);
59 template <typename BoxIn, typename BoxOut>
60 struct transform_units_impl<BoxIn, BoxOut, box_tag, box_tag>
62 template <std::size_t Index>
63 static inline void apply(BoxIn const& box_in, BoxOut& box_out)
65 typedef detail::indexed_point_view<BoxIn const, Index> view_in_type;
66 typedef detail::indexed_point_view<BoxOut, Index> view_out_type;
68 view_in_type view_in(box_in);
69 view_out_type view_out(box_out);
73 view_in_type, view_out_type
74 >::apply(view_in, view_out);
77 static inline void apply(BoxIn const& box_in, BoxOut& box_out)
79 apply<min_corner>(box_in, box_out);
80 apply<max_corner>(box_in, box_out);
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)
93 GeometryIn, GeometryOut
94 >::apply(geometry_in, geometry_out);
98 }} // namespace detail::envelope
99 #endif // DOXYGEN_NO_DETAIL
101 }} // namespace boost:geometry
103 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_TRANSFORM_UNITS_HPP