Skip to content

Commit

Permalink
Better map lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 22, 2024
1 parent a5ef140 commit cfbb13f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/core/proj/qgscoordinatetransformcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,17 @@ QString QgsCoordinateTransformContext::calculateCoordinateOperation( const QgsCo
return QString();

d->mLock.lockForRead();
QgsCoordinateTransformContextPrivate::OperationDetails res = d->mSourceDestDatumTransforms.value( qMakePair( source, destination ), QgsCoordinateTransformContextPrivate::OperationDetails() );
if ( res.operation.isEmpty() )

auto it = d->mSourceDestDatumTransforms.constFind( qMakePair( source, destination ) );
if ( it == d->mSourceDestDatumTransforms.constEnd() )
{
// try to reverse
res = d->mSourceDestDatumTransforms.value( qMakePair( destination, source ), QgsCoordinateTransformContextPrivate::OperationDetails() );
it = d->mSourceDestDatumTransforms.constFind( qMakePair( destination, source ) );
}

const QString result = it == d->mSourceDestDatumTransforms.constEnd() ? QString() : it.value().operation;
d->mLock.unlock();
return res.operation;
return result;
}

bool QgsCoordinateTransformContext::allowFallbackTransform( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination ) const
Expand Down

0 comments on commit cfbb13f

Please sign in to comment.