liuxiaolong
2021-07-20 58d904a328c0d849769b483e901a0be9426b8209
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
// Boost.Geometry
 
// This file was modified by Oracle on 2018, 2019.
// Modifications copyright (c) 2018, 2019, 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_GRIDS_HPP
#define BOOST_GEOMETRY_SRS_PROJECTIONS_GRIDS_HPP
 
 
#include <boost/geometry/srs/projections/impl/pj_gridinfo.hpp>
 
#include <fstream>
 
 
namespace boost { namespace geometry
{
 
 
namespace projections { namespace detail
{
 
 
struct grids_tag {};
struct shared_grids_tag {};
 
 
}} // namespace projections::detail
 
namespace srs
{
 
class grids
{
public:
    std::size_t size() const
    {
        return gridinfo.size();
    }
 
    bool empty() const
    {
        return gridinfo.empty();
    }
 
    typedef projections::detail::grids_tag tag;
 
    projections::detail::pj_gridinfo gridinfo;
};
 
struct ifstream_policy
{
    typedef std::ifstream stream_type;
 
    static inline void open(stream_type & is, std::string const& gridname)
    {
        is.open(gridname.c_str(), std::ios::binary);
    }
};
 
template
<
    typename StreamPolicy = srs::ifstream_policy,
    typename Grids = grids
>
struct grids_storage
{
    typedef StreamPolicy stream_policy_type;
    typedef Grids grids_type;
 
    grids_storage()
    {}
 
    explicit grids_storage(stream_policy_type const& policy)
        : stream_policy(policy)
    {}
 
    stream_policy_type stream_policy;
    grids_type hgrids;
};
 
 
template <typename GridsStorage = grids_storage<> >
class projection_grids
{
public:
    projection_grids(GridsStorage & storage)
        : m_storage_ptr(boost::addressof(storage))
    {}
 
    typedef GridsStorage grids_storage_type;
 
    GridsStorage & grids_storage() const
    {
        return *m_storage_ptr;
    }
 
private:
    GridsStorage * const m_storage_ptr;
 
public:
    std::vector<std::size_t> hindexes;
};
 
 
template <typename GridsStorage = grids_storage<> >
struct transformation_grids
{
    explicit transformation_grids(GridsStorage & storage)
        : src_grids(storage)
        , dst_grids(storage)
    {}
 
    projection_grids<GridsStorage> src_grids;
    projection_grids<GridsStorage> dst_grids;
};
 
 
namespace detail
{
 
struct empty_grids_storage {};
struct empty_projection_grids {};
 
} // namespace detail
 
 
template <>
struct transformation_grids<detail::empty_grids_storage>
{
    detail::empty_projection_grids src_grids;
    detail::empty_projection_grids dst_grids;
};
 
 
}}} // namespace boost::geometry::srs
 
 
#endif // BOOST_GEOMETRY_SRS_PROJECTIONS_GRIDS_HPP