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
55 typedef std::unique_ptr<PJ, OSRPJDeleter> UniquePtrPJ;
60 bool bUseNonDeprecated_;
63 EPSGCacheKey(
int nCode,
bool bUseNonDeprecated,
bool bAddTOWGS84)
64 : nCode_(nCode), bUseNonDeprecated_(bUseNonDeprecated),
65 bAddTOWGS84_(bAddTOWGS84)
69 bool operator==(
const EPSGCacheKey &other)
const
71 return nCode_ == other.nCode_ &&
72 bUseNonDeprecated_ == other.bUseNonDeprecated_ &&
73 bAddTOWGS84_ == other.bAddTOWGS84_;
77 struct EPSGCacheKeyHasher
79 std::size_t operator()(
const EPSGCacheKey &k)
const
81 return k.nCode_ | ((k.bUseNonDeprecated_ ? 1 : 0) << 16) |
82 ((k.bAddTOWGS84_ ? 1 : 0) << 17);
86 PJ_CONTEXT *m_tlsContext =
88 lru11::Cache<EPSGCacheKey, UniquePtrPJ, lru11::NullLock,
89 std::unordered_map<EPSGCacheKey,
90 typename std::list<lru11::KeyValuePair<
91 EPSGCacheKey, UniquePtrPJ>>::iterator,
94 lru11::Cache<std::string, UniquePtrPJ> m_oCacheWKT{};
96 PJ_CONTEXT *GetPJContext();
98 OSRProjTLSCache(
const OSRProjTLSCache &) =
delete;
99 OSRProjTLSCache &operator=(
const OSRProjTLSCache &) =
delete;
102 explicit OSRProjTLSCache(PJ_CONTEXT *tlsContext) : m_tlsContext(tlsContext)
108 PJ *GetPJForEPSGCode(
int nCode,
bool bUseNonDeprecated,
bool bAddTOWGS84);
109 void CachePJForEPSGCode(
int nCode,
bool bUseNonDeprecated,
bool bAddTOWGS84,
112 PJ *GetPJForWKT(
const std::string &wkt);
113 void CachePJForWKT(
const std::string &wkt, PJ *pj);
116 OSRProjTLSCache *OSRGetProjTLSCache();
118 void OGRCTDumpStatistics();
120 void OSRCTCleanCache();