GDAL
ogr_proj_p.h
1/******************************************************************************
2 *
3 * Project: GDAL
4 * Purpose: Private header
5 * Author: Even Rouault <even dot rouault at spatialys dot com>
6 *
7 ******************************************************************************
8 * Copyright (c) 2018, Even Rouault <even dot rouault at spatialys dot com>
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 ****************************************************************************/
28
29#ifndef OGR_PROJ_P_H_INCLUDED
30#define OGR_PROJ_P_H_INCLUDED
31
32#include "proj.h"
33
34#include "cpl_mem_cache.h"
35
36#include <unordered_map>
37#include <memory>
38#include <utility>
39
42PJ_CONTEXT* OSRGetProjTLSContext();
43void OSRCleanupTLSContext();
44
45class OSRProjTLSCache
46{
47 struct EPSGCacheKey
48 {
49 int nCode_;
50 bool bUseNonDeprecated_;
51 bool bAddTOWGS84_;
52
53 EPSGCacheKey(int nCode, bool bUseNonDeprecated, bool bAddTOWGS84):
54 nCode_(nCode), bUseNonDeprecated_(bUseNonDeprecated), bAddTOWGS84_(bAddTOWGS84) {}
55
56 bool operator==(const EPSGCacheKey& other) const
57 {
58 return nCode_ == other.nCode_ &&
59 bUseNonDeprecated_ == other.bUseNonDeprecated_ &&
60 bAddTOWGS84_ == other.bAddTOWGS84_;
61 }
62 };
63 struct EPSGCacheKeyHasher
64 {
65 std::size_t operator()(const EPSGCacheKey& k) const
66 {
67 return k.nCode_ |
68 ((k.bUseNonDeprecated_ ? 1 : 0) << 16) |
69 ((k.bAddTOWGS84_ ? 1 : 0) << 17);
70 }
71 };
72
73 lru11::Cache<EPSGCacheKey, std::shared_ptr<PJ>,
74 lru11::NullLock,
75 std::unordered_map<
76 EPSGCacheKey,
77 typename std::list<lru11::KeyValuePair<EPSGCacheKey,
78 std::shared_ptr<PJ>>>::iterator,
79 EPSGCacheKeyHasher>> m_oCacheEPSG{};
80 lru11::Cache<std::string, std::shared_ptr<PJ>> m_oCacheWKT{};
81
82 public:
83 OSRProjTLSCache() = default;
84
85 void clear();
86
87 PJ* GetPJForEPSGCode(int nCode, bool bUseNonDeprecated, bool bAddTOWGS84);
88 void CachePJForEPSGCode(int nCode, bool bUseNonDeprecated, bool bAddTOWGS84, PJ* pj);
89
90 PJ* GetPJForWKT(const std::string& wkt);
91 void CachePJForWKT(const std::string& wkt, PJ* pj);
92};
93
94OSRProjTLSCache* OSRGetProjTLSCache();
95
98#endif

Generated for GDAL by doxygen 1.9.4.