Skip to content

Commit

Permalink
Merge branch 'master' of github.com:OSGeo/gdal
Browse files Browse the repository at this point in the history
* 'master' of github.com:OSGeo/gdal:
  GeoJSON writer: emit error msg when geometry type is not supported in GeoJSON (OSGeo#4006)
  GTiff signedbyte: do not write 0 values for tiles/strips entirely at a negative nodata value (fixes OSGeo#3984)
a0x8o committed Jun 10, 2022
1 parent 03b2261 commit 072b35e
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions frmts/gtiff/geotiff.cpp
Original file line number Diff line number Diff line change
@@ -6500,8 +6500,14 @@ void GTiffRasterBand::NullBlock( void *pData )
const GPtrDiff_t nWords = static_cast<GPtrDiff_t>(nBlockXSize) * nBlockYSize;
const int nChunkSize = std::max(1, GDALGetDataTypeSizeBytes(eDataType));

<<<<<<< HEAD:frmts/gtiff/geotiff.cpp
int l_bNoDataSet = FALSE;
if( eDataType == GDT_Int64 )
=======
int bNoDataSetIn = FALSE;
double dfNoData = GetNoDataValue( &bNoDataSetIn );
if( !bNoDataSetIn )
>>>>>>> 55d0ced90a (Merge branch 'master' of github.com:OSGeo/gdal):gdal/frmts/gtiff/geotiff.cpp
{
const auto nVal = GetNoDataValueAsInt64(&l_bNoDataSet);
if( !l_bNoDataSet )
@@ -6529,6 +6535,7 @@ void GTiffRasterBand::NullBlock( void *pData )
}
else
{
<<<<<<< HEAD:frmts/gtiff/geotiff.cpp
double dfNoData = GetNoDataValue( &l_bNoDataSet );
if( !l_bNoDataSet )
{
@@ -6558,6 +6565,22 @@ void GTiffRasterBand::NullBlock( void *pData )
GDALCopyWords64( &dfNoData, GDT_Float64, 0,
pData, eDataType, nChunkSize, nWords);
}
=======
// Hack for Signed Int8 case. As the data type is GDT_Byte (unsigned),
// we have to convert a negative nodata value in the range [-128,-1] in
// [128, 255]
if( m_poGDS->m_nBitsPerSample == 8 &&
m_poGDS->m_nSampleFormat == SAMPLEFORMAT_INT &&
dfNoData < 0 && dfNoData >= -128 &&
static_cast<int>(dfNoData) == dfNoData )
{
dfNoData = 256 + dfNoData;
}

// Will convert nodata value to the right type and copy efficiently.
GDALCopyWords64( &dfNoData, GDT_Float64, 0,
pData, eDataType, nChunkSize, nWords);
>>>>>>> 55d0ced90a (Merge branch 'master' of github.com:OSGeo/gdal):gdal/frmts/gtiff/geotiff.cpp
}
}

@@ -8664,9 +8687,26 @@ void GTiffDataset::FillEmptyTiles()
if( nDataTypeSize &&
nDataTypeSize * 8 == static_cast<int>(m_nBitsPerSample) )
{
<<<<<<< HEAD:frmts/gtiff/geotiff.cpp
if( m_bNoDataSetAsInt64 )
{
GDALCopyWords64( &m_nNoDataValueInt64, GDT_Int64, 0,
=======
double dfNoData = m_dfNoDataValue;

// Hack for Signed Int8 case. As the data type is GDT_Byte (unsigned),
// we have to convert a negative nodata value in the range [-128,-1] in
// [128, 255]
if( m_nBitsPerSample == 8 &&
m_nSampleFormat == SAMPLEFORMAT_INT &&
dfNoData < 0 && dfNoData >= -128 &&
static_cast<int>(dfNoData) == dfNoData )
{
dfNoData = 256 + dfNoData;
}

GDALCopyWords64( &dfNoData, GDT_Float64, 0,
>>>>>>> 55d0ced90a (Merge branch 'master' of github.com:OSGeo/gdal):gdal/frmts/gtiff/geotiff.cpp
pabyData, eDataType,
nDataTypeSize,
nBlockBytes / nDataTypeSize );

0 comments on commit 072b35e

Please sign in to comment.