Skip to content

Commit

Permalink
Fix incorrect calculation of raster layer units per pixel x/y
Browse files Browse the repository at this point in the history
(cherry-picked from cd052d3)
  • Loading branch information
nyalldawson committed Apr 6, 2018
1 parent 5a9fd0c commit 2e7990f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -557,7 +557,7 @@ double QgsRasterLayer::rasterUnitsPerPixelX() const
// We can only use one of the mGeoTransform[], so go with the
// horisontal one.

if ( mDataProvider->capabilities() & QgsRasterDataProvider::Size && mDataProvider->xSize() > 0 )
if ( mDataProvider->capabilities() & QgsRasterDataProvider::Size && !qgsDoubleNear( mDataProvider->xSize(), 0.0 ) )
{
return mDataProvider->extent().width() / mDataProvider->xSize();
}
Expand All @@ -566,7 +566,7 @@ double QgsRasterLayer::rasterUnitsPerPixelX() const

double QgsRasterLayer::rasterUnitsPerPixelY() const
{
if ( mDataProvider->capabilities() & QgsRasterDataProvider::Size && mDataProvider->xSize() > 0 )
if ( mDataProvider->capabilities() & QgsRasterDataProvider::Size && !qgsDoubleNear( mDataProvider->ySize(), 0.0 ) )
{
return mDataProvider->extent().height() / mDataProvider->ySize();
}
Expand Down

0 comments on commit 2e7990f

Please sign in to comment.