Skip to content

Commit

Permalink
Remove OGRSpatialReferenceH member from proj 6 builds
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 15, 2019
1 parent 10850bc commit 927b053
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -51,6 +51,7 @@
#include <cpl_csv.h>



//! The length of the string "+lat_1="
const int LAT_PREFIX_LEN = 7;

Expand Down Expand Up @@ -1276,11 +1277,13 @@ void QgsCoordinateReferenceSystem::setMapUnits()
return;
}

#if PROJ_VERSION_MAJOR<6
#if GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(2,5,0)
// Of interest to us is that this call adds in a unit parameter if
// one doesn't already exist.
OSRFixup( d->mCRS );
#endif
#endif

#if PROJ_VERSION_MAJOR>=6
if ( !d->mPj )
Expand Down Expand Up @@ -2011,7 +2014,7 @@ bool QgsCoordinateReferenceSystem::loadIds( QHash<int, QString> &wkts )

int QgsCoordinateReferenceSystem::syncDatabase()
{
#if 0
#if 1
setlocale( LC_ALL, "C" );
QString dbFilePath = QgsApplication::srsDatabaseFilePath();
syncDatumTransform( dbFilePath );
Expand Down
19 changes: 14 additions & 5 deletions src/core/qgscoordinatereferencesystem_p.h
Expand Up @@ -30,11 +30,12 @@
//

#include "qgscoordinatereferencesystem.h"
#include <ogr_srs_api.h>

#if PROJ_VERSION_MAJOR>=6
#include <proj.h>
#include "qgsprojutils.h"
#else
#include <ogr_srs_api.h>
#endif

#ifdef DEBUG
Expand All @@ -48,7 +49,9 @@ class QgsCoordinateReferenceSystemPrivate : public QSharedData
public:

explicit QgsCoordinateReferenceSystemPrivate()
#if PROJ_VERSION_MAJOR<6
: mCRS( OSRNewSpatialReference( nullptr ) )
#endif
{
}

Expand All @@ -63,13 +66,19 @@ class QgsCoordinateReferenceSystemPrivate : public QSharedData
, mSRID( other.mSRID )
, mAuthId( other.mAuthId )
, mIsValid( other.mIsValid )
#if PROJ_VERSION_MAJOR<6
, mCRS( nullptr )
#endif
, mValidationHint( other.mValidationHint )
, mWkt( other.mWkt )
, mProj4( other.mProj4 )
, mAxisInvertedDirty( other.mAxisInvertedDirty )
, mAxisInverted( other.mAxisInverted )
{
#if PROJ_VERSION_MAJOR>=6
if ( mIsValid && mPj.get() )
mPj.reset( proj_clone( QgsProjContext::get(), mPj.get() ) );
#else
if ( mIsValid )
{
mCRS = OSRClone( other.mCRS );
Expand All @@ -78,15 +87,14 @@ class QgsCoordinateReferenceSystemPrivate : public QSharedData
{
mCRS = OSRNewSpatialReference( nullptr );
}
#if PROJ_VERSION_MAJOR>=6
if ( mIsValid && mPj.get() )
mPj.reset( proj_clone( QgsProjContext::get(), mPj.get() ) );
#endif
}

~QgsCoordinateReferenceSystemPrivate()
{
#if PROJ_VERSION_MAJOR<6
OSRDestroySpatialReference( mCRS );
#endif
}

//! The internal sqlite3 srs.db primary key for this CRS
Expand Down Expand Up @@ -118,8 +126,9 @@ class QgsCoordinateReferenceSystemPrivate : public QSharedData

#if PROJ_VERSION_MAJOR>=6
QgsProjUtils::proj_pj_unique_ptr mPj;
#endif
#else
OGRSpatialReferenceH mCRS;
#endif

QString mValidationHint;
mutable QString mWkt;
Expand Down

0 comments on commit 927b053

Please sign in to comment.