default_length_result.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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-2021.
  6. // Modifications copyright (c) 2014-2021, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  8. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  9. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  10. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  11. // Use, modification and distribution is subject to the Boost Software License,
  12. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #ifndef BOOST_GEOMETRY_STRATEGIES_DEFAULT_LENGTH_RESULT_HPP
  15. #define BOOST_GEOMETRY_STRATEGIES_DEFAULT_LENGTH_RESULT_HPP
  16. #include <boost/geometry/algorithms/detail/select_geometry_type.hpp>
  17. #include <boost/geometry/core/coordinate_type.hpp>
  18. #include <boost/geometry/util/select_most_precise.hpp>
  19. #include <boost/geometry/util/type_traits.hpp>
  20. namespace boost { namespace geometry
  21. {
  22. namespace resolve_strategy
  23. {
  24. // NOTE: The implementation was simplified greately preserving the old
  25. // behavior. In general case the result types of Strategies should be
  26. // taken into account.
  27. // It would probably be enough to use distance_result and
  28. // default_distance_result here.
  29. } // namespace resolve_strategy
  30. namespace resolve_dynamic
  31. {
  32. template <typename Sequence>
  33. struct default_length_result_impl;
  34. template <typename ...Geometries>
  35. struct default_length_result_impl<util::type_sequence<Geometries...>>
  36. {
  37. using type = typename select_most_precise
  38. <
  39. typename coordinate_type<Geometries>::type...,
  40. long double
  41. >::type;
  42. };
  43. template <typename Geometry>
  44. struct default_length_result
  45. : default_length_result_impl<typename detail::geometry_types<Geometry>::type>
  46. {};
  47. } // namespace resolve_dynamic
  48. /*!
  49. \brief Meta-function defining return type of length function
  50. \ingroup length
  51. \note Length of a line of integer coordinates can be double.
  52. So we take at least a double. If Big Number types are used,
  53. we take that type.
  54. */
  55. template <typename Geometry>
  56. struct default_length_result
  57. : resolve_dynamic::default_length_result<Geometry>
  58. {};
  59. }} // namespace boost::geometry
  60. #endif // BOOST_GEOMETRY_STRATEGIES_DEFAULT_LENGTH_RESULT_HPP