1 // Boost.Geometry 2 3 // Copyright (c) 2017-2018, Oracle and/or its affiliates. 4 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle 5 6 // Use, modification and distribution is subject to the Boost Software License, 7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 8 // http://www.boost.org/LICENSE_1_0.txt) 9 10 #ifndef BOOST_GEOMETRY_PROJECTIONS_CODE_HPP 11 #define BOOST_GEOMETRY_PROJECTIONS_CODE_HPP 12 13 14 #include <algorithm> 15 16 #include <boost/geometry/srs/projections/dpar.hpp> 17 18 19 namespace boost { namespace geometry { namespace projections 20 { 21 22 23 #ifndef DOXYGEN_NO_DETAIL 24 namespace detail 25 { 26 27 struct code_element 28 { 29 int code; 30 srs::dpar::parameters<> parameters; 31 }; 32 33 struct code_element_less 34 { operator ()boost::geometry::projections::detail::code_element_less35 inline bool operator()(code_element const& l, code_element const& r) const 36 { 37 return l.code < r.code; 38 } 39 }; 40 41 template<typename RandIt> binary_find_code_element(RandIt first,RandIt last,int code)42 inline RandIt binary_find_code_element(RandIt first, RandIt last, int code) 43 { 44 code_element_less comp; 45 code_element value; 46 value.code = code; 47 first = std::lower_bound(first, last, value, comp); 48 return first != last && !comp(value, *first) ? first : last; 49 } 50 51 } 52 #endif // DOXYGEN_NO_DETAIL 53 54 55 }}} // namespace boost::geometry::projections 56 57 #endif 58