Files
HPPA/HPPA/RasterDataProvider.h
tangchao0503 09095592af fix
1、基于新框架实现点击显示光谱;
2、影像拉伸显示优化;
3、右键菜单新增:移除所有栅格图层;
2026-03-06 17:33:30 +08:00

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
};