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

ENH: Added GDALOverviewsBuilder::ListResolutions().

parent 547f9d85
......@@ -21,6 +21,7 @@
// #include "itkLightObject.h"
#include "itkProcessObject.h"
#include "itkSize.h"
#include "otbGDALDatasetWrapper.h"
#include "otbConfigure.h"
......@@ -84,6 +85,9 @@ public:
typedef itk::SmartPointer< Self> Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
typedef itk::Size< 2 > Size;
typedef std::vector< Size > SizeVector;
/** Method for creation through the object factory. */
itkNewMacro( Self );
......@@ -94,8 +98,11 @@ public:
unsigned int
CountResolutions( unsigned int factor, unsigned int n =0 ) const;
unsigned int GetOverviewsCount() const;
void ListResolutions( SizeVector &, unsigned int factor, unsigned int count );
void ListResolutions( SizeVector & );
unsigned int GetOverviewsCount() const;
GDALResampling GetResamplingMethod() const;
......@@ -131,6 +138,7 @@ public:
protected:
GDALOverviewsBuilder();
virtual ~GDALOverviewsBuilder() {};
void PrintSelf( std::ostream & os, itk::Indent indent ) const;
......
......@@ -103,7 +103,7 @@ GDALOverviewsBuilder
unsigned int minSize = static_cast< unsigned int >( pow( factor, n ) );
unsigned int count = 1;
unsigned int count = 0;
unsigned int size =
std::min(
......@@ -121,6 +121,37 @@ GDALOverviewsBuilder
return count;
}
/***************************************************************************/
void
GDALOverviewsBuilder
::ListResolutions( SizeVector & sizes )
{
ListResolutions( sizes, m_ResolutionFactor, m_NbResolutions );
}
/***************************************************************************/
void
GDALOverviewsBuilder
::ListResolutions( SizeVector & sizes, unsigned int factor, unsigned int count )
{
assert( !m_GdalDataset.IsNull() );
Size s;
s[ 0 ] = m_GdalDataset->GetWidth();
s[ 1 ] = m_GdalDataset->GetHeight();
unsigned int n = std::min( count, CountResolutions( factor, 0 ) );
for( unsigned int i=0; i<n; ++i )
{
sizes.push_back( s );
s[ 0 ] /= factor;
s[ 1 ] /= factor;
}
}
/***************************************************************************/
unsigned int
GDALOverviewsBuilder
......
Markdown is supported
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