| 1 |
// Boost.Geometry |
| 2 |
|
| 3 |
// Copyright (c) 2018, 2026, 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 |
struct axis |
| 192 |
{ |
| 193 |
static const std::size_t static_capacity = 3; |
| 194 |
|
| 195 |
typedef std::size_t size_type; |
| 196 |
typedef int value_type; |
| 197 |
typedef int* iterator; |
| 198 |
typedef const int* const_iterator; |
| 199 |
typedef int& reference; |
| 200 |
typedef const int& const_reference; |
| 201 |
|
| 202 |
axis() |
| 203 |
: m_size(3) |
| 204 |
, m_data{0, 0, 0} |
| 205 |
{} |
| 206 |
|
| 207 |
template <typename It> |
| 208 |
axis(It first, It last) |
| 209 |
{ |
| 210 |
assign(first, last); |
| 211 |
} |
| 212 |
|
| 213 |
axis(std::initializer_list<int> l) |
| 214 |
{ |
| 215 |
assign(l.begin(), l.end()); |
| 216 |
} |
| 217 |
|
| 218 |
axis(int const& v0, int const& v1, int const& v2) |
| 219 |
: m_size(3) |
| 220 |
{ |
| 221 |
m_data[0] = v0; |
| 222 |
m_data[1] = v1; |
| 223 |
m_data[2] = v2; |
| 224 |
} |
| 225 |
|
| 226 |
void push_back(int const& v) |
| 227 |
{ |
| 228 |
BOOST_GEOMETRY_ASSERT(m_size < static_capacity); |
| 229 |
m_data[m_size] = v; |
| 230 |
++m_size; |
| 231 |
} |
| 232 |
|
| 233 |
template <typename It> |
| 234 |
void assign(It first, It last) |
| 235 |
{ |
| 236 |
for (m_size = 0 ; first != last && m_size < 3 ; ++first, ++m_size) |
| 237 |
m_data[m_size] = *first; |
| 238 |
} |
| 239 |
|
| 240 |
void assign(std::initializer_list<int> l) |
| 241 |
{ |
| 242 |
assign(l.begin(), l.end()); |
| 243 |
} |
| 244 |
|
| 245 |
const_reference operator[](size_type i) const |
| 246 |
{ |
| 247 |
BOOST_GEOMETRY_ASSERT(i < m_size); |
| 248 |
return m_data[i]; |
| 249 |
} |
| 250 |
|
| 251 |
reference operator[](size_type i) |
| 252 |
{ |
| 253 |
BOOST_GEOMETRY_ASSERT(i < m_size); |
| 254 |
return m_data[i]; |
| 255 |
} |
| 256 |
|
| 257 |
size_type size() const |
| 258 |
{ |
| 259 |
return m_size; |
| 260 |
} |
| 261 |
|
| 262 |
bool empty() const |
| 263 |
{ |
| 264 |
return m_size == 0; |
| 265 |
} |
| 266 |
|
| 267 |
void clear() |
| 268 |
{ |
| 269 |
m_size = 0; |
| 270 |
} |
| 271 |
|
| 272 |
iterator begin() { return m_data; } |
| 273 |
iterator end() { return m_data + m_size; } |
| 274 |
const_iterator begin() const { return m_data; } |
| 275 |
const_iterator end() const { return m_data + m_size; } |
| 276 |
|
| 277 |
private: |
| 278 |
size_type m_size; |
| 279 |
int m_data[3]; |
| 280 |
}; |
| 281 |
|
| 282 |
} // namespace detail |
| 283 |
#endif // DOXYGEN_NO_DETAIL |
| 284 |
|
| 285 |
}}} // namespace boost::geometry::srs |
| 286 |
|
| 287 |
|
| 288 |
#endif // BOOST_GEOMETRY_SRS_PROJECTIONS_SPAR_HPP |