QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
23 #ifndef QGSRASTERDATAPROVIDER_H
24 #define QGSRASTERDATAPROVIDER_H
26 #include "qgis_core.h"
68 virtual void start() = 0;
76 void finish(
const QImage &legend );
78 void progress( qint64 received, qint64 total );
80 void error(
const QString &msg );
100 NoProviderCapabilities = 0,
101 ReadLayerMetadata = 1 << 1,
102 WriteLayerMetadata = 1 << 2,
103 ProviderHintBenefitsFromResampling = 1 << 3,
104 ProviderHintCanPerformProviderResampling = 1 << 4,
106 DpiDependentData = 1 << 6,
110 Q_DECLARE_FLAGS( ProviderCapabilities, ProviderCapability )
124 QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
132 virtual QgsRasterDataProvider::ProviderCapabilities providerCapabilities()
const;
156 virtual int colorInterpretation(
int bandNo )
const;
161 switch ( colorInterpretation )
164 return QStringLiteral(
"Undefined" );
167 return QStringLiteral(
"Gray" );
170 return QStringLiteral(
"Palette" );
173 return QStringLiteral(
"Red" );
176 return QStringLiteral(
"Green" );
179 return QStringLiteral(
"Blue" );
182 return QStringLiteral(
"Alpha" );
185 return QStringLiteral(
"Hue" );
188 return QStringLiteral(
"Saturation" );
191 return QStringLiteral(
"Lightness" );
194 return QStringLiteral(
"Cyan" );
197 return QStringLiteral(
"Magenta" );
200 return QStringLiteral(
"Yellow" );
203 return QStringLiteral(
"Black" );
206 return QStringLiteral(
"YCbCr_Y" );
209 return QStringLiteral(
"YCbCr_Cb" );
212 return QStringLiteral(
"YCbCr_Cr" );
215 return QStringLiteral(
"Unknown" );
227 virtual double bandScale(
int bandNo )
const { Q_UNUSED( bandNo )
return 1.0; }
233 virtual double bandOffset(
int bandNo )
const { Q_UNUSED( bandNo )
return 0.0; }
241 virtual
bool sourceHasNoDataValue(
int bandNo )
const {
return mSrcHasNoDataValue.value( bandNo - 1 ); }
247 virtual void setUseSourceNoDataValue(
int bandNo,
bool use );
250 virtual double sourceNoDataValue(
int bandNo )
const {
return mSrcNoDataValue.value( bandNo - 1 ); }
257 virtual QList<QgsColorRampShader::ColorRampItem>
colorTable(
int bandNo )
const
258 { Q_UNUSED( bandNo )
return QList<QgsColorRampShader::ColorRampItem>(); }
266 return QStringList();
273 virtual
bool supportsLegendGraphic()
const {
return false; }
289 Q_UNUSED( forceRefresh )
290 Q_UNUSED( visibleExtent )
309 Q_UNUSED( mapSettings )
330 const QString &resamplingMethod =
"NEAREST",
332 const QStringList &configOptions = QStringList(),
335 Q_UNUSED( pyramidList )
336 Q_UNUSED( resamplingMethod )
338 Q_UNUSED( configOptions )
340 return QStringLiteral(
"FAILED_NOT_SUPPORTED" );
361 virtual QList<QgsRasterPyramid>
buildPyramidList(
const QList<int> &overviewList = QList<int>() )
362 { Q_UNUSED( overviewList )
return QList<QgsRasterPyramid>(); }
379 virtual QString htmlMetadata() = 0;
421 virtual double sample(
const QgsPointXY &point,
int band,
433 virtual QString lastErrorTitle() = 0;
444 virtual QString lastError() = 0;
447 virtual QString lastErrorFormat();
450 int dpi()
const {
return mDpi; }
479 virtual bool setEditable(
bool enabled ) { Q_UNUSED( enabled )
return false; }
484 virtual bool write(
void *data,
int band,
int width,
int height,
int xOffset,
int yOffset )
511 bool writeBlock(
QgsRasterBlock *block,
int band,
int xOffset = 0,
int yOffset = 0 );
516 const QString &format,
int nBands,
518 int width,
int height,
double *geoTransform,
520 const QStringList &createOptions = QStringList() );
527 virtual bool setNoDataValue(
int bandNo,
double noDataValue ) { Q_UNUSED( bandNo ) Q_UNUSED( noDataValue );
return false; }
536 static QList<QPair<QString, QString> > pyramidResamplingMethods(
const QString &providerKey );
586 { Q_UNUSED( createOptions ) Q_UNUSED( format );
return QString(); }
593 const QStringList &configOptions,
const QString &fileFormat )
594 { Q_UNUSED( pyramidsFormat ) Q_UNUSED( configOptions ); Q_UNUSED( fileFormat );
return QString(); }
623 virtual QList< double > nativeResolutions()
const;
631 virtual bool ignoreExtents()
const;
655 virtual QgsPoint transformCoordinates(
const QgsPoint &point, TransformType type );
738 void readXml(
const QDomElement &filterElem )
override;
740 void writeXml( QDomDocument &doc, QDomElement &parentElem )
const override;
748 void statusChanged(
const QString & )
const;
758 { Q_UNUSED( bandNo ) Q_UNUSED( xBlock ); Q_UNUSED( yBlock ); Q_UNUSED( data );
return false; }
766 { Q_UNUSED( bandNo ) Q_UNUSED( viewExtent ); Q_UNUSED( width ); Q_UNUSED( height ); Q_UNUSED( data ); Q_UNUSED( feedback );
return false; }
769 bool userNoDataValuesContains(
int bandNo,
double value )
const;
808 bool mProviderResamplingEnabled =
false;
817 double mMaxOversampling = 2.0;
824 std::unique_ptr< QgsRasterDataProviderTemporalCapabilities > mTemporalCapabilities;
@ YCbCr_YBand
Y Luminance.
ResamplingMethod zoomedInResamplingMethod() const
Returns resampling method for zoomed-in operations.
@ MagentaBand
Magenta band of CMYK image.
Handles asynchronous download of images.
QList< double > mSrcNoDataValue
Source no data value is available and is set to be used or internal no data is available.
Setting options for creating vector data providers.
virtual void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
virtual Qgis::DataType sourceDataType(int bandNo) const
Returns source data type for the band specified by number, source data type may be shorter than dataT...
Abstract base class for spatial data provider implementations.
virtual QString validateCreationOptions(const QStringList &createOptions, const QString &format)
Validates creation options for a specific dataset and destination format.
virtual QImage getLegendGraphic(double scale=0, bool forceRefresh=false, const QgsRectangle *visibleExtent=nullptr)
Returns the legend rendered as pixmap.
Point geometry type, with support for z-dimension and m-values.
int dpi() const
Returns the dpi of the output device.
QStringList subLayers() const override
Returns the sublayers of this layer - useful for providers that manage their own layers,...
virtual bool useSourceNoDataValue(int bandNo) const
Returns the source nodata value usage.
@ AlphaBand
Alpha (0=transparent, 255=opaque)
const QgsCoordinateReferenceSystem & crs
virtual bool write(void *data, int band, int width, int height, int xOffset, int yOffset)
Writes into the provider datasource.
QDateTime dataTimestamp() const override
Current time stamp of data source.
@ GreenBand
Green band of RGBA image.
Container of fields for a vector layer.
QList< bool > mSrcHasNoDataValue
Source no data value exists.
DataType
Raster data types.
@ LightnessBand
Lightness band of HLS image.
Struct that stores the information about the parameters that should be given to the QgsVirtualRasterP...
virtual bool reload()
Reload data (data could change)
virtual bool setEditable(bool enabled)
Turns on/off editing mode of the provider.
QgsImageFetcher(QObject *parent=nullptr)
Constructor.
virtual double bandOffset(int bandNo) const
Read band offset for raster value.
virtual bool enableProviderResampling(bool enable)
Enable or disable provider-level resampling.
@ BlueBand
Blue band of RGBA image.
A rectangle specified with double values.
QList< QgsRasterRangeList > mUserNoDataValue
List of lists of user defined additional no data values for each band, indexed from 0.
virtual bool setZoomedInResamplingMethod(ResamplingMethod method)
Set resampling method to apply for zoomed-in operations.
bool setInput(QgsRasterInterface *input) override
Set input.
@ UndefinedColorInterpretation
ResamplingMethod
Resampling method for provider-level resampling.
virtual int stepHeight() const
Step height for raster iterations.
QDateTime mTimestamp
Timestamp of data in the moment when the data were loaded by provider.
@ TransformLayerToImage
Transforms layer (georeferenced) coordinates to image coordinates.
virtual QString validatePyramidsConfigOptions(QgsRaster::RasterPyramidsFormat pyramidsFormat, const QStringList &configOptions, const QString &fileFormat)
Validates pyramid creation options for a specific dataset and destination format.
virtual bool remove()
Remove dataset.
Raster identify results container.
virtual Qgis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
@ YellowBand
Yellow band of CMYK image.
@ CyanBand
Cyan band of CMYK image.
ProviderCapability
Enumeration with capabilities that raster providers might implement.
void setDpi(int dpi)
Sets the output device resolution.
@ SaturationBand
Saturation band of HLS image.
virtual QgsImageFetcher * getLegendGraphicFetcher(const QgsMapSettings *mapSettings)
Returns a new image downloader for the raster legend.
virtual int stepWidth() const
Step width for raster iterations.
static const int DEFAULT_MAXIMUM_TILE_HEIGHT
Default maximum tile height.
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
virtual QList< QgsRasterPyramid > buildPyramidList(const QList< int > &overviewList=QList< int >())
Returns the raster layers pyramid list.
virtual QString buildPyramids(const QList< QgsRasterPyramid > &pyramidList, const QString &resamplingMethod="NEAREST", QgsRaster::RasterPyramidsFormat format=QgsRaster::PyramidsGTiff, const QStringList &configOptions=QStringList(), QgsRasterBlockFeedback *feedback=nullptr)
Creates pyramid overviews.
virtual double bandScale(int bandNo) const
Read band scale for raster value.
QList< QgsRasterRange > QgsRasterRangeList
virtual double sourceNoDataValue(int bandNo) const
Value representing no data value.
virtual QList< QgsColorRampShader::ColorRampItem > colorTable(int bandNo) const
virtual void readXml(const QDomElement &filterElem)
Sets base class members from xml. Usually called from create() methods of subclasses.
virtual QgsFields fields() const
Returns the fields of the raster layer for data providers that expose them, the default implementatio...
This class represents a coordinate reference system (CRS).
virtual QgsDataProviderTemporalCapabilities * temporalCapabilities()
Returns the provider's temporal capabilities.
virtual bool readBlock(int bandNo, QgsRectangle const &viewExtent, int width, int height, void *data, QgsRasterBlockFeedback *feedback=nullptr)
Reads a block of raster data into data, using the given extent and size.
TransformType
Types of transformation in transformCoordinates() function.
A class to represent a 2D point.
virtual bool setMaxOversampling(double factor)
Sets maximum oversampling factor for zoomed-out operations.
QDateTime timestamp() const override
Time stamp of data source in the moment when data/metadata were loaded by provider.
double maxOversampling() const
Returns maximum oversampling factor for zoomed-out operations.
virtual bool setNoDataValue(int bandNo, double noDataValue)
Set no data value on created dataset.
Base class for processing filters like renderers, reprojector, resampler etc.
virtual QgsRasterRangeList userNoDataValues(int bandNo) const
Returns a list of user no data value ranges.
@ TransformImageToLayer
Transforms image coordinates to layer (georeferenced) coordinates.
QList< bool > mUseSrcNoDataValue
Use source nodata value.
virtual QgsRectangle extent() const =0
Returns the extent of the layer.
virtual bool readBlock(int bandNo, int xBlock, int yBlock, void *data)
Reads a block of raster data into data.
Feedback object tailored for raster block reading.
static const int DEFAULT_MAXIMUM_TILE_WIDTH
Default maximum tile width.
@ RedBand
Red band of RGBA image.
virtual QString colorInterpretationName(int bandNumber) const
Returns the name of the color interpretation for the specified bandNumber.
virtual bool isEditable() const
Checks whether the provider is in editing mode, i.e.
QList< QgsRasterDataProvider::VirtualRasterInputLayers > rInputLayers
virtual bool setZoomedOutResamplingMethod(ResamplingMethod method)
Set resampling method to apply for zoomed-out operations.
virtual QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr)=0
Read block of data using given extent and size.
@ BlackBand
Black band of CMLY image.
The QgsMapSettings class contains configuration for rendering of the map. The rendering itself is don...
@ HueBand
Hue band of HLS image.
@ PaletteIndex
Paletted (see associated color table)
ResamplingMethod zoomedOutResamplingMethod() const
Returns resampling method for zoomed-out operations.
Base class for raster data providers.
bool isProviderResamplingEnabled() const
Returns whether provider-level resampling is enabled.
Implementation of data provider temporal properties for QgsRasterDataProviders.
QString colorName(int colorInterpretation) const
QgsCoordinateReferenceSystem crs