default_length_result.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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-2020.
  6. // Modifications copyright (c) 2014-2020, 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/select_most_precise.hpp>
  18. #include <boost/geometry/util/type_traits.hpp>
  19. namespace boost { namespace geometry
  20. {
  21. namespace resolve_strategy
  22. {
  23. // NOTE: The implementation was simplified greately preserving the old
  24. // behavior. In general case the result types of Strategies should be
  25. // taken into account.
  26. // It would probably be enough to use distance_result and
  27. // default_distance_result here.
  28. // Workaround for VS2015
  29. #if defined(_MSC_VER) && (_MSC_VER < 1910)
  30. template
  31. <
  32. typename Geometry,
  33. bool IsGeometry = util::is_geometry<Geometry>::value
  34. >
  35. struct coordinate_type
  36. : geometry::coordinate_type<Geometry>
  37. {};
  38. template <typename Geometry>
  39. struct coordinate_type<Geometry, false>
  40. {
  41. typedef long double type;
  42. };
  43. #endif
  44. template <typename ...Geometries>
  45. struct default_length_result
  46. {
  47. typedef typename select_most_precise
  48. <
  49. typename coordinate_type<Geometries>::type...,
  50. long double
  51. >::type type;
  52. };
  53. } // namespace resolve_strategy
  54. namespace resolve_variant
  55. {
  56. template <typename Geometry>
  57. struct default_length_result
  58. : resolve_strategy::default_length_result<Geometry>
  59. {};
  60. template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
  61. struct default_length_result<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
  62. : resolve_strategy::default_length_result<BOOST_VARIANT_ENUM_PARAMS(T)>
  63. {};
  64. } // namespace resolve_variant
  65. /*!
  66. \brief Meta-function defining return type of length function
  67. \ingroup length
  68. \note Length of a line of integer coordinates can be double.
  69. So we take at least a double. If Big Number types are used,
  70. we take that type.
  71. */
  72. template <typename Geometry>
  73. struct default_length_result
  74. : resolve_variant::default_length_result<Geometry>
  75. {};
  76. }} // namespace boost::geometry
  77. #endif // BOOST_GEOMETRY_STRATEGIES_DEFAULT_LENGTH_RESULT_HPP