123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- // Boost.Geometry
- // Copyright (c) 2018, Oracle and/or its affiliates.
- // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
- // Use, modification and distribution is subject to the Boost Software License,
- // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- // http://www.boost.org/LICENSE_1_0.txt)
- #ifndef BOOST_GEOMETRY_SRS_PROJECTIONS_PAR_DATA_HPP
- #define BOOST_GEOMETRY_SRS_PROJECTIONS_PAR_DATA_HPP
- #include <string>
- #include <vector>
- #include <boost/geometry/core/assert.hpp>
- #include <boost/geometry/core/config.hpp>
- namespace boost { namespace geometry { namespace srs
- {
- #ifndef DOXYGEN_NO_DETAIL
- namespace detail
- {
- struct nadgrids
- : std::vector<std::string>
- {
- typedef std::vector<std::string> base_t;
- nadgrids()
- {}
- template <typename It>
- nadgrids(It first, It last)
- : base_t(first, last)
- {}
- #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
- nadgrids(std::initializer_list<std::string> l)
- : base_t(l)
- {}
- #endif
- nadgrids(std::string const& g0)
- : base_t(1)
- {
- base_t& d = *this;
- d[0] = g0;
- }
- nadgrids(std::string const& g0, std::string const& g1)
- : base_t(2)
- {
- base_t& d = *this;
- d[0] = g0; d[1] = g1;
- }
- nadgrids(std::string const& g0, std::string const& g1, std::string const& g2)
- : base_t(3)
- {
- base_t& d = *this;
- d[0] = g0; d[1] = g1; d[2] = g2;
- }
- nadgrids(std::string const& g0, std::string const& g1, std::string const& g2, std::string const& g3)
- : base_t(4)
- {
- base_t& d = *this;
- d[0] = g0; d[1] = g1; d[2] = g2; d[3] = g3;
- }
- nadgrids(std::string const& g0, std::string const& g1, std::string const& g2, std::string const& g3, std::string const& g4)
- : base_t(5)
- {
- base_t& d = *this;
- d[0] = g0; d[1] = g1; d[2] = g2; d[3] = g3; d[4] = g4;
- }
- };
- template <typename T = double>
- struct towgs84
- {
- static const std::size_t static_capacity = 7;
- typedef std::size_t size_type;
- typedef T value_type;
- typedef T* iterator;
- typedef const T* const_iterator;
- typedef T& reference;
- typedef const T& const_reference;
- towgs84()
- : m_size(0)
- #ifdef BOOST_GEOMETRY_CXX11_ARRAY_UNIFIED_INITIALIZATION
- , m_data{0, 0, 0, 0, 0, 0, 0}
- {}
- #else
- {
- std::fill(m_data, m_data + 7, T(0));
- }
- #endif
- template <typename It>
- towgs84(It first, It last)
- {
- assign(first, last);
- }
- #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
- towgs84(std::initializer_list<T> l)
- {
- assign(l.begin(), l.end());
- }
- #endif
- towgs84(T const& v0, T const& v1, T const& v2)
- : m_size(3)
- {
- m_data[0] = v0;
- m_data[1] = v1;
- m_data[2] = v2;
- }
- towgs84(T const& v0, T const& v1, T const& v2, T const& v3, T const& v4, T const& v5, T const& v6)
- : m_size(7)
- {
- m_data[0] = v0;
- m_data[1] = v1;
- m_data[2] = v2;
- m_data[3] = v3;
- m_data[4] = v4;
- m_data[5] = v5;
- m_data[6] = v6;
- }
- void push_back(T const& v)
- {
- BOOST_GEOMETRY_ASSERT(m_size < static_capacity);
- m_data[m_size] = v;
- ++m_size;
- }
- template <typename It>
- void assign(It first, It last)
- {
- for (m_size = 0 ; first != last && m_size < 7 ; ++first, ++m_size)
- m_data[m_size] = *first;
- }
- #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
- void assign(std::initializer_list<T> l)
- {
- assign(l.begin(), l.end());
- }
- #endif
- const_reference operator[](size_type i) const
- {
- BOOST_GEOMETRY_ASSERT(i < m_size);
- return m_data[i];
- }
- reference operator[](size_type i)
- {
- BOOST_GEOMETRY_ASSERT(i < m_size);
- return m_data[i];
- }
- size_type size() const
- {
- return m_size;
- }
- bool empty() const
- {
- return m_size == 0;
- }
- void clear()
- {
- m_size = 0;
- }
- iterator begin() { return m_data; }
- iterator end() { return m_data + m_size; }
- const_iterator begin() const { return m_data; }
- const_iterator end() const { return m_data + m_size; }
- private:
- size_type m_size;
- T m_data[7];
- };
- } // namespace detail
- #endif // DOXYGEN_NO_DETAIL
- }}} // namespace boost::geometry::srs
- #endif // BOOST_GEOMETRY_SRS_PROJECTIONS_SPAR_HPP
|