]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/srs/projections/par_data.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / geometry / srs / projections / par_data.hpp
1 // Boost.Geometry
2
3 // Copyright (c) 2018, Oracle and/or its affiliates.
4 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
5
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9
10 #ifndef BOOST_GEOMETRY_SRS_PROJECTIONS_PAR_DATA_HPP
11 #define BOOST_GEOMETRY_SRS_PROJECTIONS_PAR_DATA_HPP
12
13 #include <string>
14 #include <vector>
15
16 #include <boost/geometry/core/assert.hpp>
17 #include <boost/geometry/core/config.hpp>
18
19 namespace boost { namespace geometry { namespace srs
20 {
21
22 #ifndef DOXYGEN_NO_DETAIL
23 namespace detail
24 {
25
26 struct nadgrids
27 : std::vector<std::string>
28 {
29 typedef std::vector<std::string> base_t;
30
31 nadgrids()
32 {}
33
34 template <typename It>
35 nadgrids(It first, It last)
36 : base_t(first, last)
37 {}
38
39 #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
40 nadgrids(std::initializer_list<std::string> l)
41 : base_t(l)
42 {}
43 #endif
44
45 nadgrids(std::string const& g0)
46 : base_t(1)
47 {
48 base_t& d = *this;
49 d[0] = g0;
50 }
51 nadgrids(std::string const& g0, std::string const& g1)
52 : base_t(2)
53 {
54 base_t& d = *this;
55 d[0] = g0; d[1] = g1;
56 }
57 nadgrids(std::string const& g0, std::string const& g1, std::string const& g2)
58 : base_t(3)
59 {
60 base_t& d = *this;
61 d[0] = g0; d[1] = g1; d[2] = g2;
62 }
63 nadgrids(std::string const& g0, std::string const& g1, std::string const& g2, std::string const& g3)
64 : base_t(4)
65 {
66 base_t& d = *this;
67 d[0] = g0; d[1] = g1; d[2] = g2; d[3] = g3;
68 }
69 nadgrids(std::string const& g0, std::string const& g1, std::string const& g2, std::string const& g3, std::string const& g4)
70 : base_t(5)
71 {
72 base_t& d = *this;
73 d[0] = g0; d[1] = g1; d[2] = g2; d[3] = g3; d[4] = g4;
74 }
75 };
76
77 template <typename T = double>
78 struct towgs84
79 {
80 static const std::size_t static_capacity = 7;
81
82 typedef std::size_t size_type;
83 typedef T value_type;
84 typedef T* iterator;
85 typedef const T* const_iterator;
86 typedef T& reference;
87 typedef const T& const_reference;
88
89 towgs84()
90 : m_size(0)
91 #ifdef BOOST_GEOMETRY_CXX11_ARRAY_UNIFIED_INITIALIZATION
92 , m_data{0, 0, 0, 0, 0, 0, 0}
93 {}
94 #else
95 {
96 std::fill(m_data, m_data + 7, T(0));
97 }
98 #endif
99
100 template <typename It>
101 towgs84(It first, It last)
102 {
103 assign(first, last);
104 }
105
106 #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
107 towgs84(std::initializer_list<T> l)
108 {
109 assign(l.begin(), l.end());
110 }
111 #endif
112
113 towgs84(T const& v0, T const& v1, T const& v2)
114 : m_size(3)
115 {
116 m_data[0] = v0;
117 m_data[1] = v1;
118 m_data[2] = v2;
119 }
120
121 towgs84(T const& v0, T const& v1, T const& v2, T const& v3, T const& v4, T const& v5, T const& v6)
122 : m_size(7)
123 {
124 m_data[0] = v0;
125 m_data[1] = v1;
126 m_data[2] = v2;
127 m_data[3] = v3;
128 m_data[4] = v4;
129 m_data[5] = v5;
130 m_data[6] = v6;
131 }
132
133 void push_back(T const& v)
134 {
135 BOOST_GEOMETRY_ASSERT(m_size < static_capacity);
136 m_data[m_size] = v;
137 ++m_size;
138 }
139
140 template <typename It>
141 void assign(It first, It last)
142 {
143 for (m_size = 0 ; first != last && m_size < 7 ; ++first, ++m_size)
144 m_data[m_size] = *first;
145 }
146
147 #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
148 void assign(std::initializer_list<T> l)
149 {
150 assign(l.begin(), l.end());
151 }
152 #endif
153
154 const_reference operator[](size_type i) const
155 {
156 BOOST_GEOMETRY_ASSERT(i < m_size);
157 return m_data[i];
158 }
159
160 reference operator[](size_type i)
161 {
162 BOOST_GEOMETRY_ASSERT(i < m_size);
163 return m_data[i];
164 }
165
166 size_type size() const
167 {
168 return m_size;
169 }
170
171 bool empty() const
172 {
173 return m_size == 0;
174 }
175
176 void clear()
177 {
178 m_size = 0;
179 }
180
181 iterator begin() { return m_data; }
182 iterator end() { return m_data + m_size; }
183 const_iterator begin() const { return m_data; }
184 const_iterator end() const { return m_data + m_size; }
185
186 private:
187 size_type m_size;
188 T m_data[7];
189 };
190
191 } // namespace detail
192 #endif // DOXYGEN_NO_DETAIL
193
194 }}} // namespace boost::geometry::srs
195
196
197 #endif // BOOST_GEOMETRY_SRS_PROJECTIONS_SPAR_HPP