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
  • Loading branch information
nyalldawson committed Apr 2, 2018
1 parent 1bf1058 commit cd052d3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -540,7 +540,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 @@ -549,7 +549,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 cd052d3

Please sign in to comment.