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