1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 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. 6 7 // This file was modified by Oracle on 2015, 2016. 8 // Modifications copyright (c) 2015-2016, Oracle and/or its affiliates. 9 10 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle 11 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle 12 13 // Distributed under the Boost Software License, Version 1.0. 14 // (See accompanying file LICENSE_1_0.txt or copy at 15 // http://www.boost.org/LICENSE_1_0.txt) 16 17 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_POINT_HPP 18 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_POINT_HPP 19 20 #include <cstddef> 21 22 #include <boost/geometry/core/access.hpp> 23 #include <boost/geometry/core/cs.hpp> 24 #include <boost/geometry/core/coordinate_dimension.hpp> 25 #include <boost/geometry/core/coordinate_system.hpp> 26 #include <boost/geometry/core/tags.hpp> 27 28 #include <boost/geometry/views/detail/indexed_point_view.hpp> 29 30 #include <boost/geometry/algorithms/detail/convert_point_to_point.hpp> 31 #include <boost/geometry/algorithms/detail/normalize.hpp> 32 33 #include <boost/geometry/algorithms/detail/envelope/transform_units.hpp> 34 35 #include <boost/geometry/algorithms/dispatch/envelope.hpp> 36 37 38 namespace boost { namespace geometry 39 { 40 41 #ifndef DOXYGEN_NO_DETAIL 42 namespace detail { namespace envelope 43 { 44 45 46 template <std::size_t Dimension, std::size_t DimensionCount> 47 struct envelope_one_point 48 { 49 template <std::size_t Index, typename Point, typename Box> applyboost::geometry::detail::envelope::envelope_one_point50 static inline void apply(Point const& point, Box& mbr) 51 { 52 detail::indexed_point_view<Box, Index> box_corner(mbr); 53 detail::conversion::point_to_point 54 < 55 Point, 56 detail::indexed_point_view<Box, Index>, 57 Dimension, 58 DimensionCount 59 >::apply(point, box_corner); 60 } 61 62 template <typename Point, typename Box, typename Strategy> applyboost::geometry::detail::envelope::envelope_one_point63 static inline void apply(Point const& point, Box& mbr, Strategy const&) 64 { 65 apply<min_corner>(point, mbr); 66 apply<max_corner>(point, mbr); 67 } 68 }; 69 70 71 struct envelope_point_on_spheroid 72 { 73 template<typename Point, typename Box, typename Strategy> applyboost::geometry::detail::envelope::envelope_point_on_spheroid74 static inline void apply(Point const& point, Box& mbr, Strategy const& strategy) 75 { 76 Point normalized_point = detail::return_normalized<Point>(point); 77 78 typename point_type<Box>::type box_point; 79 80 // transform units of input point to units of a box point 81 transform_units(normalized_point, box_point); 82 83 geometry::set<min_corner, 0>(mbr, geometry::get<0>(box_point)); 84 geometry::set<min_corner, 1>(mbr, geometry::get<1>(box_point)); 85 86 geometry::set<max_corner, 0>(mbr, geometry::get<0>(box_point)); 87 geometry::set<max_corner, 1>(mbr, geometry::get<1>(box_point)); 88 89 envelope_one_point 90 < 91 2, dimension<Point>::value 92 >::apply(normalized_point, mbr, strategy); 93 } 94 }; 95 96 97 }} // namespace detail::envelope 98 #endif // DOXYGEN_NO_DETAIL 99 100 #ifndef DOXYGEN_NO_DISPATCH 101 namespace dispatch 102 { 103 104 105 template <typename Point, typename CS_Tag> 106 struct envelope<Point, point_tag, CS_Tag> 107 : detail::envelope::envelope_one_point<0, dimension<Point>::value> 108 {}; 109 110 111 template <typename Point> 112 struct envelope<Point, point_tag, spherical_equatorial_tag> 113 : detail::envelope::envelope_point_on_spheroid 114 {}; 115 116 117 template <typename Point> 118 struct envelope<Point, point_tag, geographic_tag> 119 : detail::envelope::envelope_point_on_spheroid 120 {}; 121 122 123 } // namespace dispatch 124 #endif // DOXYGEN_NO_DISPATCH 125 126 }} // namespace boost::geometry 127 128 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_POINT_HPP 129