1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
7 // This file was modified by Oracle on 2015.
8 // Modifications copyright (c) 2015, Oracle and/or its affiliates.
10 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
12 // Distributed under the Boost Software License, Version 1.0.
13 // (See accompanying file LICENSE_1_0.txt or copy at
14 // http://www.boost.org/LICENSE_1_0.txt)
16 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_POINT_HPP
17 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_POINT_HPP
21 #include <boost/geometry/core/access.hpp>
22 #include <boost/geometry/core/cs.hpp>
23 #include <boost/geometry/core/coordinate_dimension.hpp>
24 #include <boost/geometry/core/coordinate_system.hpp>
25 #include <boost/geometry/core/tags.hpp>
27 #include <boost/geometry/views/detail/indexed_point_view.hpp>
29 #include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
30 #include <boost/geometry/algorithms/detail/normalize.hpp>
32 #include <boost/geometry/algorithms/detail/envelope/transform_units.hpp>
34 #include <boost/geometry/algorithms/dispatch/envelope.hpp>
37 namespace boost { namespace geometry
40 #ifndef DOXYGEN_NO_DETAIL
41 namespace detail { namespace envelope
45 template <std::size_t Dimension, std::size_t DimensionCount>
46 struct envelope_one_point
48 template <std::size_t Index, typename Point, typename Box>
49 static inline void apply(Point const& point, Box& mbr)
51 detail::indexed_point_view<Box, Index> box_corner(mbr);
52 detail::conversion::point_to_point
55 detail::indexed_point_view<Box, Index>,
58 >::apply(point, box_corner);
61 template <typename Point, typename Box>
62 static inline void apply(Point const& point, Box& mbr)
64 apply<min_corner>(point, mbr);
65 apply<max_corner>(point, mbr);
70 struct envelope_point_on_spheroid
72 template<typename Point, typename Box>
73 static inline void apply(Point const& point, Box& mbr)
75 Point normalized_point = detail::return_normalized<Point>(point);
77 typename point_type<Box>::type box_point;
79 // transform units of input point to units of a box point
80 transform_units(normalized_point, box_point);
82 geometry::set<min_corner, 0>(mbr, geometry::get<0>(box_point));
83 geometry::set<min_corner, 1>(mbr, geometry::get<1>(box_point));
85 geometry::set<max_corner, 0>(mbr, geometry::get<0>(box_point));
86 geometry::set<max_corner, 1>(mbr, geometry::get<1>(box_point));
90 2, dimension<Point>::value
91 >::apply(normalized_point, mbr);
96 }} // namespace detail::envelope
97 #endif // DOXYGEN_NO_DETAIL
99 #ifndef DOXYGEN_NO_DISPATCH
104 template <typename Point, typename CS_Tag>
105 struct envelope<Point, point_tag, CS_Tag>
106 : detail::envelope::envelope_one_point<0, dimension<Point>::value>
110 template <typename Point>
111 struct envelope<Point, point_tag, spherical_equatorial_tag>
112 : detail::envelope::envelope_point_on_spheroid
116 template <typename Point>
117 struct envelope<Point, point_tag, geographic_tag>
118 : detail::envelope::envelope_point_on_spheroid
122 } // namespace dispatch
123 #endif // DOXYGEN_NO_DISPATCH
125 }} // namespace boost::geometry
127 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_POINT_HPP