bool QgsRasterBlock::isNoData( qgssize index )
{
  if ( !mHasNoDataValue && !mNoDataBitmap ) return false;
  if ( index >= static_cast< qgssize >( mWidth )*mHeight )
  {
    QgsDebugMsg( QString( "Index %1 out of range (%2 x %3)" ).arg( index ).arg( mWidth ).arg( mHeight ) );
    return true; // we consider no data if outside
  }
  if ( mHasNoDataValue )
  {
    double value = readValue( mData, mDataType, index );
    return isNoDataValue( value );
  }
  // use no data bitmap
  if ( !mNoDataBitmap )
  {
    // no data are not defined
    return false;
  }
  // TODO: optimize
  int row = static_cast< int >( index ) / mWidth;
  int column = index % mWidth;
  qgssize byte = static_cast< qgssize >( row ) * mNoDataBitmapWidth + column / 8;
  int bit = column % 8;
  int mask = 0x80 >> bit;
  //int x = mNoDataBitmap[byte] & mask;
  //QgsDebugMsg ( QString("byte = %1 bit = %2 mask = %3 nodata = %4 is nodata = %5").arg(byte).arg(bit).arg(mask, 0, 2 ).arg( x, 0, 2 ).arg( (bool)(x) ) );
  return mNoDataBitmap[byte] & mask;
}
QMap<QString, QString> QgsRasterDataProvider::identify( const QgsPoint & thePoint, const QgsRectangle &theExtent, int theWidth, int theHeight )
{
  QMap<QString, QString> results;

  QgsRasterDataProvider::IdentifyFormat identifyFormat;
  if ( capabilities() & QgsRasterDataProvider::IdentifyValue )
  {
    identifyFormat = QgsRasterDataProvider::IdentifyFormatValue;
  }
  else if ( capabilities() & QgsRasterDataProvider::IdentifyHtml )
  {
    identifyFormat = QgsRasterDataProvider::IdentifyFormatHtml;
  }
  else if ( capabilities() & QgsRasterDataProvider::IdentifyText )
  {
    identifyFormat = QgsRasterDataProvider::IdentifyFormatText;
  }
  else
  {
    return results;
  }

  QMap<int, QVariant> myResults = identify( thePoint, identifyFormat, theExtent, theWidth, theHeight );

  if ( identifyFormat == QgsRasterDataProvider::IdentifyFormatValue )
  {
    foreach ( int bandNo, myResults.keys() )
    {
      double value = myResults.value( bandNo ).toDouble();
      QString valueString;
      if ( isNoDataValue( bandNo, value ) )
      {
        valueString = tr( "no data" );
      }
      else
      {
        valueString = QgsRasterBlock::printValue( value );
      }
      results.insert( generateBandName( bandNo ), valueString );
    }
  }