18#ifndef QGSCOORDINATEREFERENCESYSTEM_PRIVATE_H
19#define QGSCOORDINATEREFERENCESYSTEM_PRIVATE_H
38class QgsCoordinateReferenceSystemPrivate :
public QSharedData
41 explicit QgsCoordinateReferenceSystemPrivate() {}
43 QgsCoordinateReferenceSystemPrivate(
const QgsCoordinateReferenceSystemPrivate &other )
44 : QSharedData( other )
45 , mSrsId( other.mSrsId )
46 , mDescription( other.mDescription )
47 , mProjectionAcronym( other.mProjectionAcronym )
48 , mEllipsoidAcronym( other.mEllipsoidAcronym )
49 , mProjType( other.mProjType )
50 , mIsGeographic( other.mIsGeographic )
51 , mMapUnits( other.mMapUnits )
52 , mSRID( other.mSRID )
53 , mAuthId( other.mAuthId )
54 , mIsValid( other.mIsValid )
55 , mCoordinateEpoch( other.mCoordinateEpoch )
57 , mPjParentContext( nullptr )
58 , mProj4( other.mProj4 )
59 , mWktPreferred( other.mWktPreferred )
60 , mAxisInvertedDirty( other.mAxisInvertedDirty )
61 , mAxisInverted( other.mAxisInverted )
66 ~QgsCoordinateReferenceSystemPrivate()
69 if ( !mProjObjects.empty() || mPj )
83 QString mProjectionAcronym;
86 QString mEllipsoidAcronym;
88 PJ_TYPE mProjType = PJ_TYPE::PJ_TYPE_UNKNOWN;
91 bool mIsGeographic =
false;
103 bool mIsValid =
false;
106 double mCoordinateEpoch = std::numeric_limits< double >::quiet_NaN();
115 void cleanPjObjects()
122 PJ_CONTEXT *tmpContext = proj_context_create();
123 for (
auto it = mProjObjects.begin(); it != mProjObjects.end(); ++it )
125 proj_assign_context( it.value(), tmpContext );
126 proj_destroy( it.value() );
128 mProjObjects.clear();
131 proj_assign_context( mPj.get(), tmpContext );
134 proj_context_destroy( tmpContext );
143 mPj = std::move( obj );
148 mProjType = proj_get_type( mPj.get() );
152 mProjType = PJ_TYPE_UNKNOWN;
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 {};
177 PJ *threadLocalProjObject()
const
184 const QMap< PJ_CONTEXT *, PJ * >::const_iterator it = mProjObjects.constFind( context );
186 if ( it != mProjObjects.constEnd() )
194 PJ *res = proj_clone( context, mPj.get() );
195 mProjObjects.insert( context, res );
200 bool removeObjectsBelongingToCurrentThread(
PJ_CONTEXT *pj_context )
204 const QMap< PJ_CONTEXT *, PJ * >::iterator it = mProjObjects.find( pj_context );
205 if ( it != mProjObjects.end() )
207 proj_destroy( it.value() );
208 mProjObjects.erase( it );
211 if ( mPjParentContext == pj_context )
214 mPjParentContext =
nullptr;
217 return mProjObjects.isEmpty();
221 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.