Skip to content
Snippets Groups Projects
Commit f8d2a873 authored by Joachim Pouderoux's avatar Joachim Pouderoux Committed by Kitware Robot
Browse files

Merge topic 'keep-gdal-nodatavalue'


bf1cd7e2 Change iterator from postincrement to preincrement
5c97e44a Move variable declaration inside loop to limit its scope
5e1fc1bf Fix indentation and restore empty line
761a643e Add field data to vtkUniformGrid to save GDALDataset NoDataValue

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !344
parents 4d0b8189 bf1cd7e2
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@
#include <vtkInformationVector.h>
#include <vtkInformation.h>
#include <vtkIntArray.h>
#include <vtkMath.h>
#include <vtkObjectFactory.h>
#include <vtkPointData.h>
#include <vtkPoints.h>
......@@ -746,6 +747,28 @@ int vtkGDALRasterReader::RequestData(vtkInformation* vtkNotUsed(request),
this->Implementation->UniformGridData->GetFieldData()->AddArray(
projectionData);
// Add NoDataValue as field data
// GDALDatset can have 1 value for each raster band
// Use NaN for undefined values
vtkSmartPointer<vtkDoubleArray> noDataArray =
vtkSmartPointer<vtkDoubleArray>::New();
noDataArray->SetName("NO_DATA_VALUE");
noDataArray->SetNumberOfComponents(1);
noDataArray->SetNumberOfTuples(this->Implementation->NumberOfBands);
for (int i=0; i<this->Implementation->NumberOfBands; ++i)
{
int success = 0;
double noDataValue = this->Implementation->GDALData->GetRasterBand(
i+1)->GetNoDataValue(&success);
if (!success)
{
noDataValue = vtkMath::Nan();
}
noDataArray->SetValue(i, noDataValue);
}
this->Implementation->UniformGridData->GetFieldData()->AddArray(
noDataArray);
// Check if file has been changed here.
// If changed then throw the vtxId time and load a new one.
vtkInformation* outInfo = outputVector->GetInformationObject(0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment