29 #ifndef OGR_PROJ_P_H_INCLUDED
30 #define OGR_PROJ_P_H_INCLUDED
34 #include "cpl_mem_cache.h"
36 #include <unordered_map>
42 PJ_CONTEXT* OSRGetProjTLSContext();
43 void OSRCleanupTLSContext();
49 void operator()(PJ* pj)
const { proj_destroy(pj); }
51 typedef std::unique_ptr<PJ, OSRPJDeleter> UniquePtrPJ;
56 bool bUseNonDeprecated_;
59 EPSGCacheKey(
int nCode,
bool bUseNonDeprecated,
bool bAddTOWGS84):
60 nCode_(nCode), bUseNonDeprecated_(bUseNonDeprecated), bAddTOWGS84_(bAddTOWGS84) {}
62 bool operator==(
const EPSGCacheKey& other)
const
64 return nCode_ == other.nCode_ &&
65 bUseNonDeprecated_ == other.bUseNonDeprecated_ &&
66 bAddTOWGS84_ == other.bAddTOWGS84_;
69 struct EPSGCacheKeyHasher
71 std::size_t operator()(
const EPSGCacheKey& k)
const
74 ((k.bUseNonDeprecated_ ? 1 : 0) << 16) |
75 ((k.bAddTOWGS84_ ? 1 : 0) << 17);
79 PJ_CONTEXT* m_tlsContext =
nullptr;
80 lru11::Cache<EPSGCacheKey, UniquePtrPJ,
84 typename std::list<lru11::KeyValuePair<EPSGCacheKey,
85 UniquePtrPJ>>::iterator,
86 EPSGCacheKeyHasher>> m_oCacheEPSG{};
87 lru11::Cache<std::string, UniquePtrPJ> m_oCacheWKT{};
89 PJ_CONTEXT* GetPJContext();
91 OSRProjTLSCache(
const OSRProjTLSCache&) =
delete;
92 OSRProjTLSCache& operator=(
const OSRProjTLSCache&) =
delete;
95 explicit OSRProjTLSCache(PJ_CONTEXT* tlsContext): m_tlsContext(tlsContext) {}
99 PJ* GetPJForEPSGCode(
int nCode,
bool bUseNonDeprecated,
bool bAddTOWGS84);
100 void CachePJForEPSGCode(
int nCode,
bool bUseNonDeprecated,
bool bAddTOWGS84, PJ* pj);
102 PJ* GetPJForWKT(
const std::string& wkt);
103 void CachePJForWKT(
const std::string& wkt, PJ* pj);
106 OSRProjTLSCache* OSRGetProjTLSCache();
108 void OGRCTDumpStatistics();
110 void OSRCTCleanCache();