18#ifndef QGSCOORDINATEREFERENCESYSTEM_PRIVATE_H 
   19#define QGSCOORDINATEREFERENCESYSTEM_PRIVATE_H 
   38class QgsCoordinateReferenceSystemPrivate : 
public QSharedData
 
   42    explicit QgsCoordinateReferenceSystemPrivate()
 
   46    QgsCoordinateReferenceSystemPrivate( 
const QgsCoordinateReferenceSystemPrivate &other )
 
   47      : QSharedData( other )
 
   48      , mSrsId( other.mSrsId )
 
   49      , mDescription( other.mDescription )
 
   50      , mProjectionAcronym( other.mProjectionAcronym )
 
   51      , mEllipsoidAcronym( other.mEllipsoidAcronym )
 
   52      , mProjType( other.mProjType )
 
   53      , mIsGeographic( other.mIsGeographic )
 
   54      , mMapUnits( other.mMapUnits )
 
   55      , mSRID( other.mSRID )
 
   56      , mAuthId( other.mAuthId )
 
   57      , mIsValid( other.mIsValid )
 
   58      , mCoordinateEpoch( other.mCoordinateEpoch )
 
   60      , mPjParentContext( nullptr )
 
   61      , mProj4( other.mProj4 )
 
   62      , mWktPreferred( other.mWktPreferred )
 
   63      , mAxisInvertedDirty( other.mAxisInvertedDirty )
 
   64      , mAxisInverted( other.mAxisInverted )
 
   70    ~QgsCoordinateReferenceSystemPrivate()
 
   73      if ( !mProjObjects.empty() || mPj )
 
   87    QString mProjectionAcronym;
 
   90    QString mEllipsoidAcronym;
 
   92    PJ_TYPE mProjType = PJ_TYPE::PJ_TYPE_UNKNOWN;
 
   95    bool mIsGeographic = 
false;
 
  107    bool mIsValid = 
false;
 
  110    double mCoordinateEpoch = std::numeric_limits< double >::quiet_NaN();
 
  119    void cleanPjObjects()
 
  127      PJ_CONTEXT *tmpContext = proj_context_create();
 
  128      for ( 
auto it = mProjObjects.begin(); it != mProjObjects.end(); ++it )
 
  130        proj_assign_context( it.value(), tmpContext );
 
  131        proj_destroy( it.value() );
 
  133      mProjObjects.clear();
 
  136        proj_assign_context( mPj.get(), tmpContext );
 
  139      proj_context_destroy( tmpContext );
 
  149      mPj = std::move( obj );
 
  154        mProjType = proj_get_type( mPj.get() );
 
  158        mProjType = PJ_TYPE_UNKNOWN;
 
  165      return static_cast< bool >( mPj );
 
  168    mutable QString mProj4;
 
  170    mutable QString mWktPreferred;
 
  173    mutable bool mAxisInvertedDirty = 
false;
 
  176    mutable bool mAxisInverted = 
false;
 
  179    mutable QReadWriteLock mProjLock{};
 
  180    mutable QMap < PJ_CONTEXT *, PJ * > mProjObjects{};
 
  184    PJ *threadLocalProjObject()
 const 
  191      const QMap < PJ_CONTEXT *, PJ * >::const_iterator it = mProjObjects.constFind( context );
 
  193      if ( it != mProjObjects.constEnd() )
 
  201      PJ *res = proj_clone( context, mPj.get() );
 
  202      mProjObjects.insert( context, res );
 
  207    bool removeObjectsBelongingToCurrentThread( 
PJ_CONTEXT *pj_context )
 
  211      const QMap < PJ_CONTEXT *, PJ * >::iterator it = mProjObjects.find( pj_context );
 
  212      if ( it != mProjObjects.end() )
 
  214        proj_destroy( it.value() );
 
  215        mProjObjects.erase( it );
 
  218      if ( mPjParentContext == pj_context )
 
  221        mPjParentContext = 
nullptr;
 
  224      return mProjObjects.isEmpty();
 
  228    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.
 
A convenience class that simplifies locking and unlocking QReadWriteLocks.