QGIS/external/mdal/frmts/mdal_netcdf.hpp

51 lines
1.7 KiB
C++
Raw Normal View History

/*
MDAL - Mesh Data Abstraction Library (MIT License)
Copyright (C) 2018 Peter Petrik (zilolv at gmail dot com)
*/
#ifndef MDAL_NETCDF_HPP
#define MDAL_NETCDF_HPP
#include <string>
#include <vector>
//! C++ Wrapper around netcdf C library
class NetCDFFile
{
public:
//! Create file with invalid handle
NetCDFFile();
//! Closes the file
~NetCDFFile();
int handle() const;
void openFile( const std::string &fileName );
std::vector<int> readIntArr( const std::string &name, size_t dim ) const;
std::vector<double> readDoubleArr( const std::string &name, size_t dim ) const;
bool hasArr( const std::string &name ) const;
std::vector<std::string> readArrNames() const;
2019-10-14 09:19:14 +02:00
bool hasAttrInt( const std::string &name, const std::string &attr_name ) const;
int getAttrInt( const std::string &name, const std::string &attr_name ) const;
double getAttrDouble( int varid, const std::string &attr_name ) const;
2019-05-03 10:33:13 +02:00
/**
* Get string attribute
* \param name name of the variable
* \param attr_name name of the attribute of the variable
* \returns empty string if attribute is missing, else attribute value
*/
std::string getAttrStr( const std::string &name, const std::string &attr_name ) const;
2019-05-03 10:33:13 +02:00
std::string getAttrStr( const std::string &attr_name, int varid ) const;
double getFillValue( int varid ) const;
int getVarId( const std::string &name );
void getDimension( const std::string &name, size_t *val, int *ncid_val ) const;
2019-10-14 09:19:14 +02:00
void getDimensions( const std::string &variableName, std::vector<size_t> &dimensionsId, std::vector<int> &dimensionIds );
2019-05-03 10:33:13 +02:00
bool hasDimension( const std::string &name ) const;
private:
int mNcid; // C handle to the file
};
#endif // MDAL_NETCDF_HPP