Commit c4cb01aa authored by Stéphane Albert's avatar Stéphane Albert
Browse files

ENH: Added GDALDatasetWrapper::GetPixelBytes() and GDALOverviewsBuilder::GetEstimatedSize().

parent 7e3c8301
......@@ -69,6 +69,10 @@ public:
*/
unsigned int GetHeight() const;
/**
*/
size_t GetPixelBytes() const;
protected :
GDALDatasetWrapper();
......
......@@ -112,6 +112,9 @@ public:
unsigned int GetOverviewsCount() const;
size_t GetEstimatedSize() const;
GDALResampling GetResamplingMethod() const;
void SetResamplingMethod( GDALResampling );
......
......@@ -112,4 +112,57 @@ GDALDatasetWrapper
return m_Dataset->GetRasterYSize();
}
size_t
GDALDatasetWrapper
::GetPixelBytes() const
{
assert( m_Dataset!=NULL );
size_t size = 0;
int count = m_Dataset->GetRasterCount();
for( int i=1; i<=count; ++i )
{
assert( m_Dataset->GetRasterBand( i )!=NULL );
switch( m_Dataset->GetRasterBand( i )->GetRasterDataType() )
{
case GDT_Unknown:
assert( false && "Unexpected GDALDataType GDT_Unknown value." );
break;
case GDT_Byte:
size += 1;
break;
case GDT_UInt16:
case GDT_Int16 :
case GDT_CInt16:
size += 2;
break;
case GDT_UInt32:
case GDT_Int32:
case GDT_Float32:
case GDT_CInt32:
case GDT_CFloat32:
size += 4;
break;
case GDT_Float64:
case GDT_CFloat64:
size += 8;
break;
default:
assert( false && "Unhandled GDALDataType enum value." );
break;
}
}
return size;
}
} // end namespace otb
......@@ -250,6 +250,39 @@ GDALOverviewsBuilder
return m_GDALDataset->GetOverviewsCount();
}
/***************************************************************************/
size_t
GDALOverviewsBuilder
::GetEstimatedSize() const
{
assert( !m_IsBypassEnabled );
if( m_IsBypassEnabled )
return 0;
assert( !m_GDALDataset.IsNull() );
assert( m_ResolutionFactor>0 );
size_t bytes = m_GDALDataset->GetPixelBytes();
assert( bytes>0 );
size_t size = 0;
unsigned int w = m_GDALDataset->GetWidth();
unsigned int h = m_GDALDataset->GetHeight();
for( unsigned int i=0; i<m_NbResolutions; ++i )
{
w /= m_ResolutionFactor;
h /= m_ResolutionFactor;
size += w * h * bytes;
}
return size;
}
/***************************************************************************/
GDALResampling
GDALOverviewsBuilder
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment