code.hpp 1.3 KB

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