Skip to content

Commit

Permalink
PG raster: fix raster size for untiled no metadata
Browse files Browse the repository at this point in the history
Fix unreported issue with a wierd raster that has
uncomplete metadata:

- wrong size 1px rounding error
- nodata values were not cleared after dropping out from
  the fast track
  • Loading branch information
elpaso committed Apr 6, 2020
1 parent ef1497f commit 1d4b909
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/providers/postgres/raster/qgspostgresrasterprovider.cpp
Expand Up @@ -825,7 +825,7 @@ void QgsPostgresRasterProvider::disconnectDb()
bool QgsPostgresRasterProvider::init()
{

// WARNING: multiple failure return points!
// WARNING: multiple failure and return points!

if ( !determinePrimaryKey() )
{
Expand Down Expand Up @@ -1143,6 +1143,10 @@ bool QgsPostgresRasterProvider::init()
if ( PGRES_TUPLES_OK == result.PQresultStatus() && result.PQntuples() > 0 )
{

// These may have been filled with defaults in the fast track
mSrcNoDataValue.clear();
mSrcHasNoDataValue.clear();
mUseSrcNoDataValue.clear();
mBandCount = result.PQntuples();

bool ok;
Expand Down Expand Up @@ -1205,10 +1209,10 @@ bool QgsPostgresRasterProvider::init()
return false;
}

// Compute raster size
mHeight = static_cast<long>( mExtent.height() / std::abs( mScaleY ) );
mWidth = static_cast<long>( mExtent.width() / std::abs( mScaleX ) );
mIsTiled = ( mWidth != mTileWidth ) || ( mHeight != mTileHeight );
// Compute raster size, it is untiled so just take tile dimensions
mHeight = mTileHeight;
mWidth = mTileWidth;
mIsTiled = false;

mCrs = QgsCoordinateReferenceSystem();
// FIXME: from Nyall's comment:
Expand Down

0 comments on commit 1d4b909

Please sign in to comment.