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 , mProjType( other.mProjType )
59 , mIsGeographic( other.mIsGeographic )
60 , mMapUnits( other.mMapUnits )
61 , mSRID( other.mSRID )
62 , mAuthId( other.mAuthId )
63 , mIsValid( other.mIsValid )
64 , mCoordinateEpoch( other.mCoordinateEpoch )
66 , mPjParentContext( nullptr )
67 , mProj4( other.mProj4 )
68 , mWktPreferred( other.mWktPreferred )
69 , mAxisInvertedDirty( other.mAxisInvertedDirty )
70 , mAxisInverted( other.mAxisInverted )
76 ~QgsCoordinateReferenceSystemPrivate()
79 if ( !mProjObjects.empty() || mPj )
93 QString mProjectionAcronym;
96 QString mEllipsoidAcronym;
98 PJ_TYPE mProjType = PJ_TYPE::PJ_TYPE_UNKNOWN;
101 bool mIsGeographic =
false;
113 bool mIsValid =
false;
116 double mCoordinateEpoch = std::numeric_limits< double >::quiet_NaN();
125 void cleanPjObjects()
133 PJ_CONTEXT *tmpContext = proj_context_create();
134 for (
auto it = mProjObjects.begin(); it != mProjObjects.end(); ++it )
136 proj_assign_context( it.value(), tmpContext );
137 proj_destroy( it.value() );
139 mProjObjects.clear();
142 proj_assign_context( mPj.get(), tmpContext );
145 proj_context_destroy( tmpContext );
155 mPj = std::move( obj );
160 mProjType = proj_get_type( mPj.get() );
164 mProjType = PJ_TYPE_UNKNOWN;
171 return static_cast< bool >( mPj );
174 mutable QString mProj4;
176 mutable QString mWktPreferred;
179 mutable bool mAxisInvertedDirty =
false;
182 mutable bool mAxisInverted =
false;
185 mutable QReadWriteLock mProjLock{};
186 mutable QMap < PJ_CONTEXT *, PJ * > mProjObjects{};
190 PJ *threadLocalProjObject()
const
197 const QMap < PJ_CONTEXT *, PJ * >::const_iterator it = mProjObjects.constFind( context );
199 if ( it != mProjObjects.constEnd() )
207 PJ *res = proj_clone( context, mPj.get() );
208 mProjObjects.insert( context, res );
213 bool removeObjectsBelongingToCurrentThread(
PJ_CONTEXT *pj_context )
217 const QMap < PJ_CONTEXT *, PJ * >::iterator it = mProjObjects.find( pj_context );
218 if ( it != mProjObjects.end() )
220 proj_destroy( it.value() );
221 mProjObjects.erase( it );
224 if ( mPjParentContext == pj_context )
227 mPjParentContext =
nullptr;
230 return mProjObjects.isEmpty();
234 QgsCoordinateReferenceSystemPrivate &operator= (
const QgsCoordinateReferenceSystemPrivate & ) =
delete;
DistanceUnit
Units of distance.
@ Unknown
Unknown distance unit.
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