default_length_result.hpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
  5. // This file was modified by Oracle on 2014.
  6. // Modifications copyright (c) 2014, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  8. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  9. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  10. // Use, modification and distribution is subject to the Boost Software License,
  11. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. #ifndef BOOST_GEOMETRY_STRATEGIES_DEFAULT_LENGTH_RESULT_HPP
  14. #define BOOST_GEOMETRY_STRATEGIES_DEFAULT_LENGTH_RESULT_HPP
  15. #include <boost/variant/variant_fwd.hpp>
  16. #include <boost/geometry/core/coordinate_type.hpp>
  17. #include <boost/geometry/util/compress_variant.hpp>
  18. #include <boost/geometry/util/select_most_precise.hpp>
  19. #include <boost/geometry/util/transform_variant.hpp>
  20. namespace boost { namespace geometry
  21. {
  22. namespace resolve_strategy
  23. {
  24. template <typename Geometry>
  25. struct default_length_result
  26. {
  27. typedef typename select_most_precise
  28. <
  29. typename coordinate_type<Geometry>::type,
  30. long double
  31. >::type type;
  32. };
  33. } // namespace resolve_strategy
  34. namespace resolve_variant
  35. {
  36. template <typename Geometry>
  37. struct default_length_result
  38. : resolve_strategy::default_length_result<Geometry>
  39. {};
  40. template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
  41. struct default_length_result<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
  42. {
  43. typedef typename compress_variant<
  44. typename transform_variant<
  45. boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>,
  46. resolve_strategy::default_length_result<boost::mpl::placeholders::_>
  47. >::type
  48. >::type type;
  49. };
  50. } // namespace resolve_variant
  51. /*!
  52. \brief Meta-function defining return type of length function
  53. \ingroup length
  54. \note Length of a line of integer coordinates can be double.
  55. So we take at least a double. If Big Number types are used,
  56. we take that type.
  57. */
  58. template <typename Geometry>
  59. struct default_length_result
  60. : resolve_variant::default_length_result<Geometry>
  61. {};
  62. }} // namespace boost::geometry
  63. #endif // BOOST_GEOMETRY_STRATEGIES_DEFAULT_LENGTH_RESULT_HPP