diff --git a/IO/NetCDF/vtkNetCDFCFReader.cxx b/IO/NetCDF/vtkNetCDFCFReader.cxx index 4d466266fbb088d2034a2820ee08f3c103398a9e..8dde50fecea0d67857a43417dd3b1c68110b5480 100644 --- a/IO/NetCDF/vtkNetCDFCFReader.cxx +++ b/IO/NetCDF/vtkNetCDFCFReader.cxx @@ -2065,4 +2065,39 @@ void vtkNetCDFCFReader::SetVerticalDimensionName(const char* name) this->SpecialDimensionOverrideNames[vtkDimensionInfo::VERTICAL_UNITS] = name; } +//------------------------------------------------------------------------------ +const char* vtkNetCDFCFReader::GetTimeDimensionName() +{ + return GetSpecialDimensionName(vtkDimensionInfo::TIME_UNITS); +} + +//------------------------------------------------------------------------------ +const char* vtkNetCDFCFReader::GetLatitudeDimensionName() +{ + return GetSpecialDimensionName(vtkDimensionInfo::LATITUDE_UNITS); +} + +//------------------------------------------------------------------------------ +const char* vtkNetCDFCFReader::GetLongitudeDimensionName() +{ + return GetSpecialDimensionName(vtkDimensionInfo::LONGITUDE_UNITS); +} + +//------------------------------------------------------------------------------ +const char* vtkNetCDFCFReader::GetVerticalDimensionName() +{ + return GetSpecialDimensionName(vtkDimensionInfo::VERTICAL_UNITS); +} + +//------------------------------------------------------------------------------ +const char* vtkNetCDFCFReader::GetSpecialDimensionName(vtkDimensionInfo::UnitsEnum units) +{ + auto it = std::find_if(this->DimensionInfo->v.begin(), this->DimensionInfo->v.end(), + [units](const vtkDimensionInfo& di) { return di.GetUnits() == units; }); + if (it == this->DimensionInfo->v.end()) + return nullptr; + else + return it->GetName(); +} + VTK_ABI_NAMESPACE_END diff --git a/IO/NetCDF/vtkNetCDFCFReader.h b/IO/NetCDF/vtkNetCDFCFReader.h index 53f1de4a9c3c8befa6d116ecf10be4ce65b7686c..c08802ce7087b61727b4a43b3ec404f99b0616ef 100644 --- a/IO/NetCDF/vtkNetCDFCFReader.h +++ b/IO/NetCDF/vtkNetCDFCFReader.h @@ -96,6 +96,17 @@ public: void SetVerticalDimensionName(const char* name); ///@} + ///@{ + /** + * Names for Time, Latitude, Longitude and Vertical. These are either + * deduced from CF attributes or overwritten by the user + */ + const char* GetTimeDimensionName(); + const char* GetLatitudeDimensionName(); + const char* GetLongitudeDimensionName(); + const char* GetVerticalDimensionName(); + ///@} + protected: vtkNetCDFCFReader(); ~vtkNetCDFCFReader() override; @@ -168,6 +179,7 @@ protected: { this->SpecialDimensionOverrideNames[dim] = name; } + const char* GetSpecialDimensionName(vtkDimensionInfo::UnitsEnum dim); class vtkDimensionInfoVector; friend class vtkDimensionInfoVector;