Skip to content

Commit

Permalink
Fix spelling and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Jan 10, 2020
1 parent 56a5c37 commit c3a3dd8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
10 changes: 7 additions & 3 deletions src/providers/postgres/raster/qgspostgresrasterprovider.cpp
Expand Up @@ -480,7 +480,7 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE
if ( ! dstDS )
{
const QString lastError = QString::fromUtf8( CPLGetLastErrorMsg() ) ;
QgsMessageLog::logMessage( tr( "Unable to create detination raster for tiles from %1: %2" )
QgsMessageLog::logMessage( tr( "Unable to create destination raster for tiles from %1: %2" )
.arg( tableToQuery, lastError ), tr( "PostGIS" ), Qgis::Critical );
return false;
}
Expand Down Expand Up @@ -567,7 +567,11 @@ Qgis::DataType QgsPostgresRasterProvider::dataType( int bandNo ) const
{
if ( mDataTypes.size() < static_cast<unsigned long>( bandNo ) )
{
// TODO: raise or at least log!
QgsMessageLog::logMessage( tr( "Data type size for band %1 could not be found: num bands is: %2 and the type size map for bands contains: %3 items" )
.arg( bandNo )
.arg( mBandCount )
.arg( mDataSizes.size() ),
QStringLiteral( "PostGIS" ), Qgis::Warning );
return Qgis::DataType::UnknownDataType;
}
// Band is 1-based
Expand Down Expand Up @@ -1343,7 +1347,7 @@ void QgsPostgresRasterProvider::findOverviews()
}
if ( mOverViews.isEmpty() )
{
QgsMessageLog::logMessage( tr( "No overviews found, performaces may be affected" ), QStringLiteral( "PostGIS" ), Qgis::Info );
QgsMessageLog::logMessage( tr( "No overviews found, performances may be affected" ), QStringLiteral( "PostGIS" ), Qgis::Info );
}
}

Expand Down
Expand Up @@ -36,7 +36,7 @@ QgsPostgresRasterSharedData::TilesResponse QgsPostgresRasterSharedData::tiles( c

QgsPostgresRasterSharedData::TilesResponse result;

// First check for index existance
// First check for index existence
if ( mSpatialIndexes.find( request.overviewFactor ) == mSpatialIndexes.end() )
{
// Fetch the index
Expand Down
Expand Up @@ -91,7 +91,7 @@ class QgsPostgresRasterSharedData
QMutex mMutex;

/**
* The Tile struct represents a raster tile with metadata and data (intially NULL).
* The Tile struct represents a raster tile with metadata and data (initially NULL).
*/
struct Tile
{
Expand Down
20 changes: 6 additions & 14 deletions src/providers/postgres/raster/qgspostgresrasterutils.cpp
Expand Up @@ -26,7 +26,7 @@ QVariantMap QgsPostgresRasterUtils::parseWkb( const QByteArray &wkb, int bandNo
{
QgsMessageLog::logMessage( QStringLiteral( "Wrong wkb size: min expected = %1, actual = %2" )
.arg( minWkbSize )
.arg( wkb.size() ), QStringLiteral( "PostGIS" ), Qgis::Warning );
.arg( wkb.size() ), QStringLiteral( "PostGIS" ), Qgis::Critical );

return result;
}
Expand All @@ -47,9 +47,10 @@ QVariantMap QgsPostgresRasterUtils::parseWkb( const QByteArray &wkb, int bandNo
*/

// Endianness
result[ QStringLiteral( "endiannes" ) ] = static_cast<unsigned short int>( wkb[0] );
result[ QStringLiteral( "endiannes" ) ] = static_cast<unsigned short int>( wkb[0] ); //#spellok
// NOTE: For now only little endian is supported
Q_ASSERT( result[ QStringLiteral( "endiannes" ) ] == 1 );
// TODO: endianness
Q_ASSERT( result[ QStringLiteral( "endiannes" ) ] == 1 ); //#spellok
result[ QStringLiteral( "version" ) ] = *reinterpret_cast<const unsigned short int *>( &wkb.constData()[1] );
result[ QStringLiteral( "nBands" ) ] = *reinterpret_cast<const unsigned int *>( &wkb.constData()[3] );
const unsigned int nBands { *reinterpret_cast<const unsigned int *>( &wkb.constData()[3] ) };
Expand All @@ -69,7 +70,6 @@ QVariantMap QgsPostgresRasterUtils::parseWkb( const QByteArray &wkb, int bandNo

auto readBandHeader = [ & ]( )
{
// Band header data starts at offset 61
result[ QStringLiteral( "pxType" ) ] = *reinterpret_cast<const unsigned short int *>( &wkb.constData()[offset] ) & 0x0F;
/*
| 'Bool1' // unsupported
Expand Down Expand Up @@ -112,11 +112,11 @@ QVariantMap QgsPostgresRasterUtils::parseWkb( const QByteArray &wkb, int bandNo
result[ QStringLiteral( "nodata" ) ] = static_cast<unsigned long long>( *reinterpret_cast<const unsigned long int *>( &wkb.constData()[ offset ] ) );
pxSize = 4;
break;
case 10:
case 10: // float
result[ QStringLiteral( "nodata" ) ] = *reinterpret_cast<const float *>( &wkb.constData()[ offset ] );
pxSize = 4;
break;
case 11:
case 11: // double
result[ QStringLiteral( "nodata" ) ] = *reinterpret_cast<const double *>( &wkb.constData()[ offset ] );
pxSize = 8;
break;
Expand All @@ -130,7 +130,6 @@ QVariantMap QgsPostgresRasterUtils::parseWkb( const QByteArray &wkb, int bandNo
result[ QStringLiteral( "dataSize" ) ] = static_cast<unsigned int>( pxSize * result[ QStringLiteral( "width" ) ].toInt() * result[ QStringLiteral( "height" ) ].toInt() );
};


if ( bandNo > nBands )
{
QgsMessageLog::logMessage( QStringLiteral( "Band number is not valid: %1 (nBands: %2" )
Expand All @@ -152,12 +151,5 @@ QVariantMap QgsPostgresRasterUtils::parseWkb( const QByteArray &wkb, int bandNo

result[ QStringLiteral( "data" )] = wkb.mid( offset, result[ QStringLiteral( "dataSize" ) ].toInt() );

#if 0
// Spit it out floats
for ( int i = 0; i < result[ QStringLiteral( "dataSize" ) ].toInt() / result[ QStringLiteral( "pxSize" ) ].toInt( ); ++i )
{
qDebug() << *reinterpret_cast<const float *>( &result[ QStringLiteral( "data" )].toByteArray().constData()[ i * result[ QStringLiteral( "pxSize" ) ].toInt( ) ] );
}
#endif
return result;
}

0 comments on commit c3a3dd8

Please sign in to comment.