13#ifndef OGR_PROJ_P_H_INCLUDED
14#define OGR_PROJ_P_H_INCLUDED
18#include "cpl_mem_cache.h"
20#include <unordered_map>
26PJ_CONTEXT CPL_DLL *OSRGetProjTLSContext();
27void OSRCleanupTLSContext();
33 void operator()(PJ *pj)
const
39 typedef std::unique_ptr<PJ, OSRPJDeleter> UniquePtrPJ;
44 bool bUseNonDeprecated_;
47 EPSGCacheKey(
int nCode,
bool bUseNonDeprecated,
bool bAddTOWGS84)
48 : nCode_(nCode), bUseNonDeprecated_(bUseNonDeprecated),
49 bAddTOWGS84_(bAddTOWGS84)
53 bool operator==(
const EPSGCacheKey &other)
const
55 return nCode_ == other.nCode_ &&
56 bUseNonDeprecated_ == other.bUseNonDeprecated_ &&
57 bAddTOWGS84_ == other.bAddTOWGS84_;
61 struct EPSGCacheKeyHasher
63 std::size_t operator()(
const EPSGCacheKey &k)
const
65 return k.nCode_ | ((k.bUseNonDeprecated_ ? 1 : 0) << 16) |
66 ((k.bAddTOWGS84_ ? 1 : 0) << 17);
70 PJ_CONTEXT *m_tlsContext =
72 lru11::Cache<EPSGCacheKey, UniquePtrPJ, lru11::NullLock,
73 std::unordered_map<EPSGCacheKey,
74 typename std::list<lru11::KeyValuePair<
75 EPSGCacheKey, UniquePtrPJ>>::iterator,
78 lru11::Cache<std::string, UniquePtrPJ> m_oCacheWKT{};
80 PJ_CONTEXT *GetPJContext();
82 OSRProjTLSCache(
const OSRProjTLSCache &) =
delete;
83 OSRProjTLSCache &operator=(
const OSRProjTLSCache &) =
delete;
86 explicit OSRProjTLSCache(PJ_CONTEXT *tlsContext) : m_tlsContext(tlsContext)
92 PJ *GetPJForEPSGCode(
int nCode,
bool bUseNonDeprecated,
bool bAddTOWGS84);
93 void CachePJForEPSGCode(
int nCode,
bool bUseNonDeprecated,
bool bAddTOWGS84,
96 PJ *GetPJForWKT(
const std::string &wkt);
97 void CachePJForWKT(
const std::string &wkt, PJ *pj);
100OSRProjTLSCache *OSRGetProjTLSCache();
102void OGRCTDumpStatistics();
104void OSRCTCleanCache();