Skip to content
Permalink
Browse files

Fix QgsMapSettings {mapToLayer,layerToMap}Coordinates failing with po…

…ints having a nan z value
  • Loading branch information
nirvn committed Oct 15, 2020
1 parent ab6e615 commit e951aead535e9355d861ac0d2adccf6a6d1cd8a9
Showing with 10 additions and 10 deletions.
  1. +2 −2 python/core/auto_generated/qgsmapsettings.sip.in
  2. +6 −6 src/core/qgsmapsettings.cpp
  3. +2 −2 src/core/qgsmapsettings.h
@@ -526,7 +526,7 @@ transform point coordinates from layer's CRS to output CRS
:return: the transformed point
%End

QgsPoint layerToMapCoordinates( const QgsMapLayer *layer, QgsPoint point ) const;
QgsPoint layerToMapCoordinates( const QgsMapLayer *layer, const QgsPoint &point ) const;
%Docstring
transform point coordinates from layer's CRS to output CRS

@@ -551,7 +551,7 @@ transform point coordinates from output CRS to layer's CRS
:return: the transformed point
%End

QgsPoint mapToLayerCoordinates( const QgsMapLayer *layer, QgsPoint point ) const;
QgsPoint mapToLayerCoordinates( const QgsMapLayer *layer, const QgsPoint &point ) const;
%Docstring
transform point coordinates from output CRS to layer's CRS

@@ -496,11 +496,11 @@ QgsPointXY QgsMapSettings::layerToMapCoordinates( const QgsMapLayer *layer, QgsP
return point;
}

QgsPoint QgsMapSettings::layerToMapCoordinates( const QgsMapLayer *layer, QgsPoint point ) const
QgsPoint QgsMapSettings::layerToMapCoordinates( const QgsMapLayer *layer, const QgsPoint &point ) const
{
double x = point.x();
double y = point.y();
double z = point.z();
double z = !std::isnan( point.z() ) ? point.z() : 0.0;

try
{
@@ -513,7 +513,7 @@ QgsPoint QgsMapSettings::layerToMapCoordinates( const QgsMapLayer *layer, QgsPoi
QgsMessageLog::logMessage( QObject::tr( "Transform error caught: %1" ).arg( cse.what() ), QObject::tr( "CRS" ) );
}

return QgsPoint( x, y, z );
return QgsPoint( x, y, !std::isnan( point.z() ) ? z : point.z() );
}


@@ -550,11 +550,11 @@ QgsPointXY QgsMapSettings::mapToLayerCoordinates( const QgsMapLayer *layer, QgsP
return point;
}

QgsPoint QgsMapSettings::mapToLayerCoordinates( const QgsMapLayer *layer, QgsPoint point ) const
QgsPoint QgsMapSettings::mapToLayerCoordinates( const QgsMapLayer *layer, const QgsPoint &point ) const
{
double x = point.x();
double y = point.y();
double z = point.z();
double z = !std::isnan( point.z() ) ? point.z() : 0.0;

try
{
@@ -567,7 +567,7 @@ QgsPoint QgsMapSettings::mapToLayerCoordinates( const QgsMapLayer *layer, QgsPoi
QgsMessageLog::logMessage( QObject::tr( "Transform error caught: %1" ).arg( cse.what() ), QObject::tr( "CRS" ) );
}

return QgsPoint( x, y, z );
return QgsPoint( x, y, !std::isnan( point.z() ) ? z : point.z() );
}


@@ -468,7 +468,7 @@ class CORE_EXPORT QgsMapSettings : public QgsTemporalRangeObject
* \returns the transformed point
* \since QGIS 3.16
*/
QgsPoint layerToMapCoordinates( const QgsMapLayer *layer, QgsPoint point ) const;
QgsPoint layerToMapCoordinates( const QgsMapLayer *layer, const QgsPoint &point ) const;

/**
* \brief transform rectangle from layer's CRS to output CRS
@@ -488,7 +488,7 @@ class CORE_EXPORT QgsMapSettings : public QgsTemporalRangeObject
* \returns the transformed point
* \since QGIS 3.16
*/
QgsPoint mapToLayerCoordinates( const QgsMapLayer *layer, QgsPoint point ) const;
QgsPoint mapToLayerCoordinates( const QgsMapLayer *layer, const QgsPoint &point ) const;

/**
* \brief transform rectangle from output CRS to layer's CRS

0 comments on commit e951aea

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