Skip to content

Commit

Permalink
Fix nodata values
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuarte47 committed Jan 9, 2018
1 parent bf8bc4f commit 10db395
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/GDALTiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,25 @@ GDALTiler::createRasterTile(double (&adfGeoTransform)[6]) const {
psWarpOptions->panDstBands =
(int *) CPLMalloc(sizeof(int) * psWarpOptions->nBandCount );

psWarpOptions->padfSrcNoDataReal =
(double *)CPLCalloc(psWarpOptions->nBandCount, sizeof(double));
psWarpOptions->padfSrcNoDataImag =
(double *)CPLCalloc(psWarpOptions->nBandCount, sizeof(double));
psWarpOptions->padfDstNoDataReal =
(double *)CPLCalloc(psWarpOptions->nBandCount, sizeof(double));
psWarpOptions->padfDstNoDataImag =
(double *)CPLCalloc(psWarpOptions->nBandCount, sizeof(double));

for (short unsigned int i = 0; i < psWarpOptions->nBandCount; ++i) {
int bGotNoData = FALSE;
double noDataValue = dataset()->GetRasterBand(i + 1)->GetNoDataValue(&bGotNoData);
if (!bGotNoData) noDataValue = -32768;

psWarpOptions->padfSrcNoDataReal[i] = noDataValue;
psWarpOptions->padfSrcNoDataImag[i] = 0;
psWarpOptions->padfDstNoDataReal[i] = noDataValue;
psWarpOptions->padfDstNoDataImag[i] = 0;

psWarpOptions->panDstBands[i] = psWarpOptions->panSrcBands[i] = i + 1;
}

Expand Down

0 comments on commit 10db395

Please sign in to comment.