Skip to content
Permalink
Browse files

Fix proj < 6 build

(cherry picked from commit 7441141)
  • Loading branch information
nyalldawson committed Mar 13, 2020
1 parent e1c2ddc commit 6b1fffa447e0a5302a0a8a46910e700089b7bfe6
Showing with 13 additions and 2 deletions.
  1. +13 −2 src/core/qgscoordinatetransformcontext.cpp
@@ -147,7 +147,11 @@ void QgsCoordinateTransformContext::removeSourceDestinationDatumTransform( const

void QgsCoordinateTransformContext::removeCoordinateOperation( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs )
{
#if PROJ_VERSION_MAJOR>=6
d->mSourceDestDatumTransforms.remove( qMakePair( sourceCrs, destinationCrs ) );
#else
d->mSourceDestDatumTransforms.remove( qMakePair( sourceCrs.authid(), destinationCrs.authid() ) );
#endif
}

bool QgsCoordinateTransformContext::hasTransform( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination ) const
@@ -376,7 +380,7 @@ void QgsCoordinateTransformContext::writeXml( QDomElement &element, const QgsRea
for ( auto it = d->mSourceDestDatumTransforms.constBegin(); it != d->mSourceDestDatumTransforms.constEnd(); ++ it )
{
QDomElement transformElem = doc.createElement( QStringLiteral( "srcDest" ) );

#if PROJ_VERSION_MAJOR>=6
QDomElement srcElem = doc.createElement( QStringLiteral( "src" ) );
QDomElement destElem = doc.createElement( QStringLiteral( "dest" ) );

@@ -386,10 +390,12 @@ void QgsCoordinateTransformContext::writeXml( QDomElement &element, const QgsRea
transformElem.appendChild( srcElem );
transformElem.appendChild( destElem );

#if PROJ_VERSION_MAJOR>=6
transformElem.setAttribute( QStringLiteral( "coordinateOp" ), it.value().operation );
transformElem.setAttribute( QStringLiteral( "allowFallback" ), it.value().allowFallback ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
#else
transformElem.setAttribute( QStringLiteral( "source" ), it.key().first );
transformElem.setAttribute( QStringLiteral( "dest" ), it.key().second );

Q_NOWARN_DEPRECATED_PUSH
transformElem.setAttribute( QStringLiteral( "sourceTransform" ), it.value().sourceTransformId < 0 ? QString() : QgsDatumTransform::datumTransformToProj( it.value().sourceTransformId ) );
transformElem.setAttribute( QStringLiteral( "destTransform" ), it.value().destinationTransformId < 0 ? QString() : QgsDatumTransform::datumTransformToProj( it.value().destinationTransformId ) );
@@ -507,8 +513,13 @@ void QgsCoordinateTransformContext::writeSettings()

for ( auto transformIt = d->mSourceDestDatumTransforms.constBegin(); transformIt != d->mSourceDestDatumTransforms.constEnd(); ++transformIt )
{
#if PROJ_VERSION_MAJOR>=6
const QString srcAuthId = transformIt.key().first.authid();
const QString destAuthId = transformIt.key().second.authid();
#else
const QString srcAuthId = transformIt.key().first;
const QString destAuthId = transformIt.key().second;
#endif

if ( srcAuthId.isEmpty() || destAuthId.isEmpty() )
continue; // not so nice, but alternative would be to shove whole CRS wkt into the settings values...

0 comments on commit 6b1fffa

Please sign in to comment.
You can’t perform that action at this time.