detail.hpp
2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// Boost.Geometry
// Copyright (c) 2020-2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#ifndef BOOST_GEOMETRY_STRATEGIES_DETAIL_HPP
#define BOOST_GEOMETRY_STRATEGIES_DETAIL_HPP
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/strategies/geographic/parameters.hpp>
#include <boost/geometry/strategies/spherical/get_radius.hpp>
#include <boost/geometry/srs/sphere.hpp>
#include <boost/geometry/srs/spheroid.hpp>
#include <boost/geometry/util/type_traits.hpp>
namespace boost { namespace geometry
{
namespace strategies
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
struct umbrella_strategy {};
struct not_implemented {};
template <typename Strategy>
struct is_umbrella_strategy
{
static const bool value = std::is_base_of<umbrella_strategy, Strategy>::value;
};
struct cartesian_base : umbrella_strategy
{
typedef cartesian_tag cs_tag;
};
template <typename RadiusTypeOrSphere>
class spherical_base : umbrella_strategy
{
protected:
typedef typename strategy_detail::get_radius
<
RadiusTypeOrSphere
>::type radius_type;
public:
typedef spherical_tag cs_tag;
spherical_base()
: m_radius(1.0)
{}
template <typename RadiusOrSphere>
explicit spherical_base(RadiusOrSphere const& radius_or_sphere)
: m_radius(strategy_detail::get_radius
<
RadiusOrSphere
>::apply(radius_or_sphere))
{}
srs::sphere<radius_type> model() const
{
return srs::sphere<radius_type>(m_radius);
}
protected:
radius_type const& radius() const
{
return m_radius;
}
radius_type m_radius;
};
template <>
class spherical_base<void> : umbrella_strategy
{
protected:
typedef double radius_type;
public:
typedef spherical_tag cs_tag;
srs::sphere<radius_type> model() const
{
return srs::sphere<radius_type>(1.0);
}
protected:
radius_type radius() const
{
return 1.0;
}
};
template <typename Spheroid>
class geographic_base : umbrella_strategy
{
public:
typedef geographic_tag cs_tag;
geographic_base()
: m_spheroid()
{}
explicit geographic_base(Spheroid const& spheroid)
: m_spheroid(spheroid)
{}
Spheroid model() const
{
return m_spheroid;
}
protected:
Spheroid m_spheroid;
};
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
} // namespace strategies
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_STRATEGIES_DETAIL_HPP