34#include <QApplication>
50QReadWriteLock QgsCoordinateTransform::sCacheLock;
52bool QgsCoordinateTransform::sDisableCache =
false;
56 const QString &desiredOperation )> QgsCoordinateTransform::sFallbackOperationOccurredHandler =
nullptr;
60 d =
new QgsCoordinateTransformPrivate();
66 d =
new QgsCoordinateTransformPrivate( source, destination, mContext );
69 mIgnoreImpossible =
true;
81 if ( !d->checkValidity() )
85 if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mProjCoordinateOperation, d->mAllowFallbackTransforms ) )
93 mBallparkTransformsAreAppropriate =
true;
99 d =
new QgsCoordinateTransformPrivate( source, destination, mContext );
106 mIgnoreImpossible =
true;
114 if ( !d->checkValidity() )
118 if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mProjCoordinateOperation, d->mAllowFallbackTransforms ) )
126 mBallparkTransformsAreAppropriate =
true;
131 d =
new QgsCoordinateTransformPrivate( source, destination, sourceDatumTransform, destinationDatumTransform );
136 if ( !d->checkValidity() )
140 if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mProjCoordinateOperation, d->mAllowFallbackTransforms ) )
149 : mContext( o.mContext )
151 , mHasContext( o.mHasContext )
157 , mIgnoreImpossible( false )
158 , mBallparkTransformsAreAppropriate( false )
159 , mDisableFallbackHandler( false )
160 , mFallbackOperationOccurred( false )
172 mHasContext = o.mHasContext;
174 mContext = o.mContext;
175 mLastError = QString();
183 return d->mSourceCRS == other.d->mSourceCRS
184 && d->mDestCRS == other.d->mDestCRS
185 && mBallparkTransformsAreAppropriate == other.mBallparkTransformsAreAppropriate
186 && d->mProjCoordinateOperation == other.d->mProjCoordinateOperation
192 return !( *
this == other );
217 if ( !d->checkValidity() )
220 d->calculateTransforms( mContext );
222 if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mProjCoordinateOperation, d->mAllowFallbackTransforms ) )
240 if ( !d->checkValidity() )
243 d->calculateTransforms( mContext );
245 if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mProjCoordinateOperation, d->mAllowFallbackTransforms ) )
267 if ( !d->checkValidity() )
270 d->calculateTransforms( mContext );
272 if ( !setFromCache( d->mSourceCRS, d->mDestCRS, d->mProjCoordinateOperation, d->mAllowFallbackTransforms ) )
287 return d->mSourceCRS;
297 if ( !d->mIsValid || d->mShortCircuit )
301 double x = point.
x();
302 double y = point.
y();
335 if ( !d->mIsValid || d->mShortCircuit )
359#ifdef COORDINATE_TRANSFORM_VERBOSE
371 double x = point.
x();
372 double y = point.
y();
373 double z = point.
z();
390 if ( !d->mIsValid || d->mShortCircuit )
411 double xd =
static_cast< double >( x ), yd =
static_cast< double >( y );
420 if ( !d->mIsValid || d->mShortCircuit )
446 if ( !d->mIsValid || d->mShortCircuit )
452 const int nVertices = poly.size();
454 QVector<double> x( nVertices );
455 QVector<double> y( nVertices );
456 QVector<double> z( nVertices );
457 double *destX = x.data();
458 double *destY = y.data();
459 double *destZ = z.data();
461 const QPointF *polyData = poly.constData();
462 for (
int i = 0; i < nVertices; ++i )
464 *destX++ = polyData->x();
465 *destY++ = polyData->y();
481 QPointF *destPoint = poly.data();
482 const double *srcX = x.constData();
483 const double *srcY = y.constData();
484 for (
int i = 0; i < nVertices; ++i )
486 destPoint->rx() = *srcX++;
487 destPoint->ry() = *srcY++;
492 if ( !err.isEmpty() )
500 if ( !d->mIsValid || d->mShortCircuit )
503 Q_ASSERT( x.size() == y.size() );
526 if ( !d->mIsValid || d->mShortCircuit )
529 Q_ASSERT( x.size() == y.size() );
539 const int vectorSize = x.size();
540 QVector<double> xd( x.size() );
541 QVector<double> yd( y.size() );
542 QVector<double> zd( z.size() );
544 double *destX = xd.data();
545 double *destY = yd.data();
546 double *destZ = zd.data();
548 const float *srcX = x.constData();
549 const float *srcY = y.constData();
550 const float *srcZ = z.constData();
552 for (
int i = 0; i < vectorSize; ++i )
554 *destX++ =
static_cast< double >( *srcX++ );
555 *destY++ =
static_cast< double >( *srcY++ );
556 *destZ++ =
static_cast< double >( *srcZ++ );
562 float *destFX = x.data();
563 float *destFY = y.data();
564 float *destFZ = z.data();
565 const double *srcXD = xd.constData();
566 const double *srcYD = yd.constData();
567 const double *srcZD = zd.constData();
568 for (
int i = 0; i < vectorSize; ++i )
570 *destFX++ =
static_cast< float >( *srcXD++ );
571 *destFY++ =
static_cast< float >( *srcYD++ );
572 *destFZ++ =
static_cast< float >( *srcZD++ );
590 if ( !d->mIsValid || d->mShortCircuit )
602 QgsDebugMsgLevel( QStringLiteral(
"No QgsCoordinateTransformContext context set for transform" ), 4 );
610 throw QgsCsException( QObject::tr(
"Could not transform bounding box for geocentric CRS %1" ).arg( d->mSourceCRS.authid() ) );
614 throw QgsCsException( QObject::tr(
"Could not transform bounding box for geocentric CRS %1" ).arg( d->mDestCRS.authid() ) );
617 const double xMin = rect.
xMinimum();
618 const double xMax = rect.
xMaximum();
621 if ( d->mGeographicToWebMercator &&
629 constexpr double EPS = 1e-1;
630 if ( yMin < -90 + EPS )
632 if ( yMax < -90 + EPS )
633 throw QgsCsException( QObject::tr(
"Could not transform bounding box to target CRS" ) );
636 if ( yMax > 90 - EPS )
638 if ( yMin > 90 - EPS )
639 throw QgsCsException( QObject::tr(
"Could not transform bounding box to target CRS" ) );
646 QgsDebugMsgLevel( QStringLiteral(
"Entering transformBoundingBox..." ), 4 );
648#if PROJ_VERSION_MAJOR< 9 || (PROJ_VERSION_MAJOR==9 && PROJ_VERSION_MINOR<7)
649 const auto legacyImplementation = [
this, &rect, xMin, yMin, yMax, direction, handle180Crossover]()
657 const int nPoints = 1000;
658 const double dst = std::sqrt( ( rect.
width() * ( yMax - yMin ) ) / std::pow( std::sqrt(
static_cast< double >( nPoints ) ) - 1, 2.0 ) );
659 const int nXPoints =
static_cast<int>( std::clamp( std::ceil( rect.
width() / dst ) + 1, 3.0, 1000.0 ) );
660 const int nYPoints =
static_cast<int>( std::clamp( std::ceil( ( yMax - yMin ) / dst ) + 1, 3.0, 1000.0 ) );
665 std::vector<double> x( nXPoints *
static_cast< std::size_t
>( nYPoints ) );
666 std::vector<double> y( nXPoints *
static_cast< std::size_t
>( nYPoints ) );
667 std::vector<double> z( nXPoints *
static_cast< std::size_t
>( nYPoints ) );
671 const double dx = rect.
width() /
static_cast< double >( nXPoints - 1 );
672 const double dy = ( yMax - yMin ) /
static_cast< double >( nYPoints - 1 );
674 double pointY = yMin;
676 for (
int i = 0; i < nYPoints ; i++ )
680 double pointX = xMin;
682 for (
int j = 0; j < nXPoints; j++ )
684 x[( i * nXPoints ) + j] = pointX;
685 y[( i * nXPoints ) + j] = pointY;
687 z[( i * nXPoints ) + j] = 0.0;
698 transformCoords( nXPoints * nYPoints, x.data(), y.data(), z.data(), direction );
708 bool doHandle180Crossover =
false;
711 const double xMin = std::fmod( x[0], 180.0 );
712 const double xMax = std::fmod( x[nXPoints - 1], 180.0 );
713 if ( handle180Crossover
716 && xMin > 0.0 && xMin <= 180.0 && xMax < 0.0 && xMax >= -180.0 )
718 doHandle180Crossover =
true;
723 for (
int i = 0; i < nXPoints * nYPoints; i++ )
725 if ( !std::isfinite( x[i] ) || !std::isfinite( y[i] ) )
730 if ( doHandle180Crossover )
744 throw QgsCsException( QObject::tr(
"Could not transform bounding box to target CRS" ) );
747 if ( doHandle180Crossover )
768#if PROJ_VERSION_MAJOR>8 || (PROJ_VERSION_MAJOR==8 && PROJ_VERSION_MINOR>=2)
770#if PROJ_VERSION_MAJOR< 9 || (PROJ_VERSION_MAJOR==9 && PROJ_VERSION_MINOR<7)
778 return legacyImplementation();
782 ProjData projData = d->threadLocalProjData();
785#if PROJ_VERSION_MAJOR< 9 || (PROJ_VERSION_MAJOR==9 && PROJ_VERSION_MINOR<6)
800 transform2D.reset( proj_create_crs_to_crs_from_pj( projContext, srcCrsHorizontal.get(), destCrsHorizontal.get(),
nullptr,
nullptr ) );
803 const QString err = QStringLiteral(
"proj_create_crs_to_crs_from_pj(horizontalCrs(%1), horizontalCrs(%2)) failed" ).arg( d->mSourceCRS.authid(), d->mSourceCRS.authid() );
804 throw QgsCsException( QObject::tr(
"Could not transform bounding box to target CRS: %1" ).arg( err ) );
806 transform2D.reset( proj_normalize_for_visualization( projContext, transform2D.get() ) );
809 const QString err = QStringLiteral(
"Cannot normalize transform between horizontalCrs(%1) and horizontalCrs(%2)" ).arg( d->mSourceCRS.authid(), d->mDestCRS.authid() );
810 throw QgsCsException( QObject::tr(
"Could not transform bounding box to target CRS: %1" ).arg( err ) );
812 projData = transform2D.get();
816 double transXMin = 0;
817 double transYMin = 0;
818 double transXMax = 0;
819 double transYMax = 0;
821 proj_errno_reset( projData );
824 constexpr int DENSIFY_POINTS = 30;
826 xMin, yMin, xMax, yMax,
827 &transXMin, &transYMin, &transXMax, &transYMax, DENSIFY_POINTS );
829 if ( ( projResult != 1
830 || !std::isfinite( transXMin )
831 || !std::isfinite( transXMax )
832 || !std::isfinite( transYMin )
833 || !std::isfinite( transYMax ) )
834 && ( d->mAvailableOpCount > 1 || d->mAvailableOpCount == -1 )
838 if (
PJ *
transform = d->threadLocalFallbackProjData() )
841 xMin, yMin, xMax, yMax,
842 &transXMin, &transYMin, &transXMax, &transYMax, DENSIFY_POINTS );
847 || !std::isfinite( transXMin )
848 || !std::isfinite( transXMax )
849 || !std::isfinite( transYMin )
850 || !std::isfinite( transYMax ) )
852#if PROJ_VERSION_MAJOR< 9 || (PROJ_VERSION_MAJOR==9 && PROJ_VERSION_MINOR<7)
856 return legacyImplementation();
858 const QString projErr = QString::fromUtf8( proj_context_errno_string( projContext, proj_errno( projData ) ) );
860 const QString msg = QObject::tr(
"%1 (%2 to %3) of bounding box failed: %4" )
871 bool doHandle180Crossover =
false;
873 if ( handle180Crossover
876 && ( transXMax < transXMin ) )
879 std::swap( transXMax, transXMin );
884 doHandle180Crossover =
true;
887 QgsRectangle boundingBoxRect{ transXMin, transYMin, transXMax, transYMax };
888 if ( boundingBoxRect.
isNull() )
891 throw QgsCsException( QObject::tr(
"Could not transform bounding box to target CRS" ) );
894 if ( doHandle180Crossover )
897 if ( boundingBoxRect.
xMinimum() > 180.0 )
899 if ( boundingBoxRect.
xMaximum() > 180.0 )
905 if ( boundingBoxRect.
isEmpty() )
910 return boundingBoxRect;
912#if PROJ_VERSION_MAJOR< 9 || (PROJ_VERSION_MAJOR==9 && PROJ_VERSION_MINOR<7)
913 return legacyImplementation();
919 if ( !d->mIsValid || d->mShortCircuit )
922 if ( !d->mSourceCRS.isValid() )
925 "The coordinates can not be reprojected. The CRS is: %1" )
926 .arg( d->mSourceCRS.toProj() ), QObject::tr(
"CRS" ) );
929 if ( !d->mDestCRS.isValid() )
932 "The coordinates can not be reprojected. The CRS is: %1" ).arg( d->mDestCRS.toProj() ), QObject::tr(
"CRS" ) );
936 std::vector< int > zNanPositions;
937 for (
int i = 0; i < numPoints; i++ )
939 if ( std::isnan( z[i] ) )
941 zNanPositions.push_back( i );
946 std::vector< double > xprev( numPoints );
947 memcpy( xprev.data(), x,
sizeof(
double ) * numPoints );
948 std::vector< double > yprev( numPoints );
949 memcpy( yprev.data(), y,
sizeof(
double ) * numPoints );
950 std::vector< double > zprev( numPoints );
951 memcpy( zprev.data(), z,
sizeof(
double ) * numPoints );
953 const bool useTime = !std::isnan( d->mDefaultTime );
954 std::vector< double > t( useTime ? numPoints : 0, d->mDefaultTime );
956#ifdef COORDINATE_TRANSFORM_VERBOSE
959 QgsDebugMsgLevel( QStringLiteral(
"[[[[[[ Number of points to transform: %1 ]]]]]]" ).arg( numPoints ), 2 );
965 QgsDebugMsgLevel( QStringLiteral(
"No QgsCoordinateTransformContext context set for transform" ), 4 );
970 ProjData projData = d->threadLocalProjData();
974 proj_errno_reset( projData );
976 x,
sizeof(
double ), numPoints,
977 y,
sizeof(
double ), numPoints,
978 z,
sizeof(
double ), numPoints,
979 useTime ? t.data() :
nullptr,
sizeof(
double ), useTime ? numPoints : 0 );
989 if ( numPoints == 1 )
991 projResult = proj_errno( projData );
992 actualRes = projResult;
996 actualRes = proj_errno( projData );
998 if ( actualRes == 0 )
1002 if ( std::any_of( x, x + numPoints, [](
double v ) {
return std::isinf( v ); } )
1003 || std::any_of( y, y + numPoints, [](
double v ) {
return std::isinf( v ); } )
1004 || std::any_of( z, z + numPoints, [](
double v ) {
return std::isinf( v ); } ) )
1010 mFallbackOperationOccurred =
false;
1011 bool errorOccurredDuringFallbackOperation =
false;
1013 && ( d->mAvailableOpCount > 1 || d->mAvailableOpCount == -1 )
1014 && ( d->mAllowFallbackTransforms || mBallparkTransformsAreAppropriate ) )
1017 if (
PJ *
transform = d->threadLocalFallbackProjData() )
1021 memcpy( x, xprev.data(),
sizeof(
double ) * numPoints );
1022 memcpy( y, yprev.data(),
sizeof(
double ) * numPoints );
1023 memcpy( z, zprev.data(),
sizeof(
double ) * numPoints );
1025 x,
sizeof(
double ), numPoints,
1026 y,
sizeof(
double ), numPoints,
1027 z,
sizeof(
double ), numPoints,
1028 useTime ? t.data() :
nullptr,
sizeof(
double ), useTime ? numPoints : 0 );
1037 if ( numPoints == 1 )
1043 errorOccurredDuringFallbackOperation = std::isinf( x[0] ) || std::isinf( y[0] ) || std::isinf( z[0] );
1046 if ( !errorOccurredDuringFallbackOperation )
1048 mFallbackOperationOccurred =
true;
1051 if ( !mBallparkTransformsAreAppropriate && !mDisableFallbackHandler && sFallbackOperationOccurredHandler )
1053 sFallbackOperationOccurredHandler( d->mSourceCRS, d->mDestCRS, d->mProjCoordinateOperation );
1055 const QString warning = QStringLiteral(
"A fallback coordinate operation was used between %1 and %2" ).arg( d->mSourceCRS.authid(),
1056 d->mDestCRS.authid() );
1057 qWarning(
"%s", warning.toLatin1().constData() );
1063 for (
const int &pos : zNanPositions )
1065 z[pos] = std::numeric_limits<double>::quiet_NaN();
1068 if ( projResult != 0 || errorOccurredDuringFallbackOperation )
1073 const QChar delim = numPoints > 1 ?
'\n' :
' ';
1074 for (
int i = 0; i < numPoints; ++i )
1076 points += QStringLiteral(
"(%1, %2)" ).arg( xprev[i], 0,
'f' ).arg( yprev[i], 0,
'f' ) + delim;
1082 const QString projError = !errorOccurredDuringFallbackOperation ? QString::fromUtf8( proj_context_errno_string( projContext, projResult ) ) : QObject::tr(
"Fallback transform failed" );
1084 const QString msg = QObject::tr(
"%1 (%2 to %3) of%4%5Error: %6" )
1093 if ( msg != mLastError )
1095 QgsDebugError(
"Projection failed emitting invalid transform signal: " + msg );
1103#ifdef COORDINATE_TRANSFORM_VERBOSE
1104 QgsDebugMsgLevel( QStringLiteral(
"[[[[[[ Projected %1, %2 to %3, %4 ]]]]]]" )
1105 .arg( xorg, 0,
'g', 15 ).arg( yorg, 0,
'g', 15 )
1106 .arg( *x, 0,
'g', 15 ).arg( *y, 0,
'g', 15 ), 2 );
1117 return !d->mIsValid || d->mShortCircuit;
1122 return d->mIsValid && d->mHasVerticalComponent;
1127 return d->mProjCoordinateOperation;
1132 ProjData projData = d->threadLocalProjData();
1139 d->mProjCoordinateOperation = operation;
1140 d->mShouldReverseCoordinateOperation =
false;
1146 d->mAllowFallbackTransforms = allowed;
1151 return d->mAllowFallbackTransforms;
1156 mBallparkTransformsAreAppropriate = appropriate;
1161 mDisableFallbackHandler = disabled;
1166 return mFallbackOperationOccurred;
1173 proj = QApplication::applicationDirPath()
1174 +
"/share/proj/" + QString( name );
1178 return proj.toUtf8();
1186 const QString sourceKey = src.
authid().isEmpty() ?
1188 const QString destKey = dest.
authid().isEmpty() ?
1191 if ( sourceKey.isEmpty() || destKey.isEmpty() )
1195 if ( sDisableCache )
1198 const QList< QgsCoordinateTransform > values = sTransforms.values( qMakePair( sourceKey, destKey ) );
1199 for (
auto valIt = values.constBegin(); valIt != values.constEnd(); ++valIt )
1201 if ( ( *valIt ).coordinateOperation() == coordinateOperationProj
1202 && ( *valIt ).allowFallbackTransforms() == allowFallback
1208 const QgsCoordinateTransformContext
context = mContext;
1210 const bool hasContext = mHasContext;
1217 mHasContext = hasContext;
1226void QgsCoordinateTransform::addToCache()
1228 if ( !d->mSourceCRS.isValid() || !d->mDestCRS.isValid() )
1231 const QString sourceKey = d->mSourceCRS.authid().isEmpty() ?
1233 const QString destKey = d->mDestCRS.authid().isEmpty() ?
1236 if ( sourceKey.isEmpty() || destKey.isEmpty() )
1240 if ( sDisableCache )
1243 sTransforms.insert( qMakePair( sourceKey, destKey ), *
this );
1249 return d->mSourceDatumTransform;
1257 d->mSourceDatumTransform = dt;
1264 return d->mDestinationDatumTransform;
1272 d->mDestinationDatumTransform = dt;
1279 if ( sDisableCache )
1284 sDisableCache =
true;
1287 sTransforms.clear();
1290void QgsCoordinateTransform::removeFromCacheObjectsBelongingToCurrentThread(
void *pj_context )
1296 if ( sDisableCache )
1301 if ( sDisableCache )
1304 for (
auto it = sTransforms.begin(); it != sTransforms.end(); )
1306 auto &v = it.value();
1307 if ( v.d->removeObjectsBelongingToCurrentThread( pj_context ) )
1308 it = sTransforms.erase( it );
1318 const double distSourceUnits = std::sqrt( source1.
sqrDist( source2 ) );
1321 const double distDestUnits = std::sqrt( dest1.
sqrDist( dest2 ) );
1322 return distDestUnits / distSourceUnits;
1327 QgsCoordinateTransformPrivate::setCustomMissingRequiredGridHandler( handler );
1332 QgsCoordinateTransformPrivate::setCustomMissingPreferredGridHandler( handler );
1337 QgsCoordinateTransformPrivate::setCustomCoordinateOperationCreationErrorHandler( handler );
1342 QgsCoordinateTransformPrivate::setCustomMissingGridUsedByContextHandler( handler );
1347 sFallbackOperationOccurredHandler = handler;
1352 QgsCoordinateTransformPrivate::setDynamicCrsToDynamicCrsWarningHandler( handler );
@ Geocentric
Geocentric CRS.
QFlags< CoordinateTransformationFlag > CoordinateTransformationFlags
Coordinate transformation flags.
@ Preferred
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
@ BallparkTransformsAreAppropriate
Indicates that approximate "ballpark" results are appropriate for this coordinate transform....
@ IgnoreImpossibleTransformations
Indicates that impossible transformations (such as those which attempt to transform between two diffe...
TransformDirection
Indicates the direction (forward or inverse) of a transform.
@ Forward
Forward transform (from source to destination).
@ Reverse
Reverse/inverse transform (from destination to source).
Represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QString toWkt(Qgis::CrsWktVariant variant=Qgis::CrsWktVariant::Wkt1Gdal, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
QString celestialBodyName() const
Attempts to retrieve the name of the celestial body associated with the CRS (e.g.
double coordinateEpoch() const
Returns the coordinate epoch, as a decimal year.
Contains information about the context in which a coordinate transform is executed.
Custom exception class for Coordinate Reference System related exceptions.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE())
Adds a message to the log instance (and creates it if necessary).
double sqrDist(double x, double y) const
Returns the squared distance between this point a specified x, y coordinate.
static PJ_CONTEXT * get()
Returns a thread local instance of a proj context, safe for use in the current thread.
static proj_pj_unique_ptr crsToHorizontalCrs(const PJ *crs)
Given a PROJ crs (which may be a compound or bound crs, or some other type), extract the horizontal c...
static bool hasVerticalAxis(const PJ *crs)
Returns true if a PROJ crs has a vertical axis.
std::unique_ptr< PJ, ProjPJDeleter > proj_pj_unique_ptr
Scoped Proj PJ object.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QgsCoordinateTransformContext transformContext
A convenience class that simplifies locking and unlocking QReadWriteLocks.
A rectangle specified with double values.
Q_INVOKABLE QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
void setXMinimum(double x)
Set the minimum x value.
void setXMaximum(double x)
Set the maximum x value.
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle.
void setNull()
Mark a rectangle as being null (holding no spatial information).
Scoped object for temporary suppression of PROJ logging output.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
double y() const
Returns Y coordinate.
double z() const
Returns Z coordinate.
double x() const
Returns X coordinate.
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH
bool qgsNanCompatibleEquals(double a, double b)
Compare two doubles, treating nan values as equal.
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)