18#ifndef QGSCOORDINATEREFERENCESYSTEM_PRIVATE_H
19#define QGSCOORDINATEREFERENCESYSTEM_PRIVATE_H
44class QgsCoordinateReferenceSystemPrivate :
public QSharedData
48 explicit QgsCoordinateReferenceSystemPrivate()
52 QgsCoordinateReferenceSystemPrivate(
const QgsCoordinateReferenceSystemPrivate &other )
53 : QSharedData( other )
54 , mSrsId( other.mSrsId )
55 , mDescription( other.mDescription )
56 , mProjectionAcronym( other.mProjectionAcronym )
57 , mEllipsoidAcronym( other.mEllipsoidAcronym )
58 , mIsGeographic( other.mIsGeographic )
59 , mMapUnits( other.mMapUnits )
60 , mSRID( other.mSRID )
61 , mAuthId( other.mAuthId )
62 , mIsValid( other.mIsValid )
63 , mCoordinateEpoch( other.mCoordinateEpoch )
65 , mPjParentContext( nullptr )
66 , mProj4( other.mProj4 )
67 , mWktPreferred( other.mWktPreferred )
68 , mAxisInvertedDirty( other.mAxisInvertedDirty )
69 , mAxisInverted( other.mAxisInverted )
75 ~QgsCoordinateReferenceSystemPrivate()
78 if ( !mProjObjects.empty() || mPj )
92 QString mProjectionAcronym;
95 QString mEllipsoidAcronym;
98 bool mIsGeographic =
false;
110 bool mIsValid =
false;
113 double mCoordinateEpoch = std::numeric_limits< double >::quiet_NaN();
122 void cleanPjObjects()
130 PJ_CONTEXT *tmpContext = proj_context_create();
131 for (
auto it = mProjObjects.begin(); it != mProjObjects.end(); ++it )
133 proj_assign_context( it.value(), tmpContext );
134 proj_destroy( it.value() );
136 mProjObjects.clear();
139 proj_assign_context( mPj.get(), tmpContext );
142 proj_context_destroy( tmpContext );
152 mPj = std::move( obj );
159 return static_cast< bool >( mPj );
162 mutable QString mProj4;
164 mutable QString mWktPreferred;
167 mutable bool mAxisInvertedDirty =
false;
170 mutable bool mAxisInverted =
false;
173 mutable QReadWriteLock mProjLock{};
174 mutable QMap < PJ_CONTEXT *, PJ * > mProjObjects{};
178 PJ *threadLocalProjObject()
const
185 const QMap < PJ_CONTEXT *, PJ * >::const_iterator it = mProjObjects.constFind( context );
187 if ( it != mProjObjects.constEnd() )
195 PJ *res = proj_clone( context, mPj.get() );
196 mProjObjects.insert( context, res );
201 bool removeObjectsBelongingToCurrentThread(
PJ_CONTEXT *pj_context )
205 const QMap < PJ_CONTEXT *, PJ * >::iterator it = mProjObjects.find( pj_context );
206 if ( it != mProjObjects.end() )
208 proj_destroy( it.value() );
209 mProjObjects.erase( it );
212 if ( mPjParentContext == pj_context )
215 mPjParentContext =
nullptr;
218 return mProjObjects.isEmpty();
222 QgsCoordinateReferenceSystemPrivate &operator= (
const QgsCoordinateReferenceSystemPrivate & ) =
delete;
DistanceUnit
Units of distance.
static PJ_CONTEXT * get()
Returns a thread local instance of a proj context, safe for use in the current thread.
std::unique_ptr< PJ, ProjPJDeleter > proj_pj_unique_ptr
Scoped Proj PJ object.
The QgsReadWriteLocker class is a convenience class that simplifies locking and unlocking QReadWriteL...
void * OGRSpatialReferenceH
struct projCtx_t PJ_CONTEXT