51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <QString>
|
|
#include <vector>
|
|
|
|
#if __has_include(<gdal_priv.h>)
|
|
#define HPPA_HAVE_GDAL 1
|
|
#include <gdal_priv.h>
|
|
#include <cpl_conv.h>
|
|
#else
|
|
#define HPPA_HAVE_GDAL 0
|
|
#endif
|
|
|
|
class RasterDataProvider
|
|
{
|
|
public:
|
|
explicit RasterDataProvider(const QString& uri);
|
|
~RasterDataProvider();
|
|
|
|
bool open();
|
|
void close();
|
|
|
|
int bandCount() const;
|
|
int width() const;
|
|
int height() const;
|
|
|
|
bool isValidPixel(int x, int y) const;
|
|
|
|
// Returns per-band wavelength metadata if available. If not available, returns empty vector.
|
|
std::vector<double> bandWavelengths() const;
|
|
|
|
// Read spectrum of one pixel (x,y) across all bands.
|
|
bool readPixelSpectrum(int x, int y, std::vector<double>& outSpectrum) const;
|
|
|
|
// Read a single band (0-based index) into a float buffer of size width()*height().
|
|
// Returns true on success.
|
|
bool readBandAsFloat(int bandIndex, std::vector<float>& outBuffer) const;
|
|
|
|
QString uri() const { return m_uri; }
|
|
|
|
private:
|
|
QString m_uri;
|
|
std::vector<double> parseEnviHdrWavelengths() const;
|
|
#if HPPA_HAVE_GDAL
|
|
GDALDataset* m_dataset = nullptr;
|
|
#else
|
|
// no-op when GDAL not available
|
|
void* m_dataset = nullptr;
|
|
#endif
|
|
};
|