Commit 872eb638 authored by remicres's avatar remicres
Browse files

BUG: wrong block size in populate blocks offsets, fixed

parent 044952fc
......@@ -518,13 +518,24 @@ SimpleParallelTiffWriter<TInputImage>
* Raster creation
************************************************************************/
// When mode is tiled, check the GeoTiff tile size
int inputRegionMinSize = std::min(inputRegion.GetSize()[0], inputRegion.GetSize()[1]);
if (m_TiffTiledMode && m_TiffTileSize > inputRegionMinSize)
// First, compute the block size
int block_size_x = m_TiffTiledMode;
if (m_TiffTiledMode)
{
// When mode is tiled, check the GeoTiff tile size
int inputRegionMinSize = std::min(inputRegion.GetSize()[0], inputRegion.GetSize()[1]);
if (m_TiffTileSize > inputRegionMinSize)
{
// Find the nearest (floor) power of 2
block_size_x = (int) std::pow(2, std::floor(std::log((double) inputRegionMinSize)/std::log(2.0)));
itkWarningMacro(<<"GeoTiff tile size is bigger than image. Setting to " << block_size_x);
}
}
else
{
// Find the nearest (floor) power of 2
m_TiffTileSize = (int) std::pow(2, std::floor(std::log((double) inputRegionMinSize)/std::log(2.0)));
itkWarningMacro(<<"GeoTiff tile size is bigger than image. Setting to " << m_TiffTileSize);
// When mode is not tiled (i.e. striped)
block_size_x = inputPtr->GetLargestPossibleRegion().GetSize()[0];
}
// Master process (Rank 0) is responsible for the creation of the output raster.
......@@ -547,8 +558,8 @@ SimpleParallelTiffWriter<TInputImage>
dataType,
geotransform,
inputPtr->GetProjectionRef(),
m_TiffTiledMode,
m_TiffTileSize);
block_size_x,
m_TiffTiledMode);
if (sperr != sptw::SP_None)
{
......@@ -574,7 +585,7 @@ SimpleParallelTiffWriter<TInputImage>
if (otb::MPIConfig::Instance()->GetMyRank() == 0)
{
SPTW_ERROR sperr = populate_tile_offsets(output_raster,
m_TiffTileSize,
block_size_x,
m_TiffTiledMode);
if (sperr != sptw::SP_None)
{
......
......@@ -268,8 +268,8 @@ SPTW_ERROR create_generic_raster(string filename,
GDALDataType band_type,
double *geotransform,
string projection_srs,
bool tiled_mode,
int tiles_size) {
int block_size_x,
bool tiled_mode) {
GDALAllRegister();
......@@ -289,15 +289,11 @@ SPTW_ERROR create_generic_raster(string filename,
if (tiled_mode)
{
std::stringstream ts;
ts << tiles_size;
ts << block_size_x;
options = CSLSetNameValue(options, "TILED", "YES");
options = CSLSetNameValue(options, "BLOCKXSIZE", ts.str().c_str());
options = CSLSetNameValue(options, "BLOCKYSIZE", ts.str().c_str());
}
else
{
tiles_size = x_size;
}
// Create output raster
GDALDataset *output =
......
......@@ -104,8 +104,8 @@ namespace sptw {
GDALDataType band_type,
double *geotransform,
string projection_srs,
bool tiled_mode,
int tiles_size);
int block_size_x,
bool tiled_mode);
SPTW_ERROR create_raster(string filename,
int64_t x_size,
......
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