QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
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
107 Q_DECLARE_FLAGS( ProviderCapabilities, ProviderCapability )
127 virtual QgsRasterDataProvider::ProviderCapabilities providerCapabilities()
const;
160 switch ( colorInterpretation )
163 return QStringLiteral(
"Undefined" );
166 return QStringLiteral(
"Gray" );
169 return QStringLiteral(
"Palette" );
172 return QStringLiteral(
"Red" );
175 return QStringLiteral(
"Green" );
178 return QStringLiteral(
"Blue" );
181 return QStringLiteral(
"Alpha" );
184 return QStringLiteral(
"Hue" );
187 return QStringLiteral(
"Saturation" );
190 return QStringLiteral(
"Lightness" );
193 return QStringLiteral(
"Cyan" );
196 return QStringLiteral(
"Magenta" );
199 return QStringLiteral(
"Yellow" );
202 return QStringLiteral(
"Black" );
205 return QStringLiteral(
"YCbCr_Y" );
208 return QStringLiteral(
"YCbCr_Cb" );
211 return QStringLiteral(
"YCbCr_Cr" );
214 return QStringLiteral(
"Unknown" );
222 return colorName( colorInterpretation( bandNo ) );
229 virtual double bandScale(
int bandNo )
const { Q_UNUSED( bandNo )
return 1.0; }
235 virtual double bandOffset(
int bandNo )
const { Q_UNUSED( bandNo )
return 0.0; }
243 virtual
bool sourceHasNoDataValue(
int bandNo )
const {
return mSrcHasNoDataValue.value( bandNo - 1 ); }
249 virtual void setUseSourceNoDataValue(
int bandNo,
bool use );
252 virtual double sourceNoDataValue(
int bandNo )
const {
return mSrcNoDataValue.value( bandNo - 1 ); }
259 virtual QList<QgsColorRampShader::ColorRampItem>
colorTable(
int bandNo )
const
260 { Q_UNUSED( bandNo )
return QList<QgsColorRampShader::ColorRampItem>(); }
268 return QStringList();
275 virtual
bool supportsLegendGraphic()
const {
return false; }
291 Q_UNUSED( forceRefresh )
292 Q_UNUSED( visibleExtent )
311 Q_UNUSED( mapSettings )
317 const QString &resamplingMethod =
"NEAREST",
319 const QStringList &configOptions = QStringList(),
322 Q_UNUSED( pyramidList )
323 Q_UNUSED( resamplingMethod )
325 Q_UNUSED( configOptions )
327 return QStringLiteral(
"FAILED_NOT_SUPPORTED" );
339 { Q_UNUSED( overviewList )
return QList<QgsRasterPyramid>(); }
348 virtual QString htmlMetadata() = 0;
390 virtual double sample(
const QgsPointXY &point,
int band,
402 virtual QString lastErrorTitle() = 0;
413 virtual QString lastError() = 0;
416 virtual QString lastErrorFormat();
419 int dpi()
const {
return mDpi; }
448 virtual bool setEditable(
bool enabled ) { Q_UNUSED( enabled )
return false; }
452 virtual bool write(
void *data,
int band,
int width,
int height,
int xOffset,
int yOffset )
479 bool writeBlock(
QgsRasterBlock *block,
int band,
int xOffset = 0,
int yOffset = 0 );
484 const QString &format,
int nBands,
486 int width,
int height,
double *geoTransform,
488 const QStringList &createOptions = QStringList() );
495 virtual bool setNoDataValue(
int bandNo,
double noDataValue ) { Q_UNUSED( bandNo ) Q_UNUSED( noDataValue );
return false; }
504 static QList<QPair<QString, QString> > pyramidResamplingMethods(
const QString &providerKey );
512 { Q_UNUSED( createOptions ) Q_UNUSED( format );
return QString(); }
519 const QStringList &configOptions,
const QString &fileFormat )
520 { Q_UNUSED( pyramidsFormat ) Q_UNUSED( configOptions ); Q_UNUSED( fileFormat );
return QString(); }
549 virtual QList< double > nativeResolutions()
const;
557 virtual bool ignoreExtents()
const;
581 virtual QgsPoint transformCoordinates(
const QgsPoint &point, TransformType type );
589 void statusChanged(
const QString & )
const;
599 { Q_UNUSED( bandNo ) Q_UNUSED( xBlock ); Q_UNUSED( yBlock ); Q_UNUSED( data );
return false; }
607 { Q_UNUSED( bandNo ) Q_UNUSED( viewExtent ); Q_UNUSED( width ); Q_UNUSED( height ); Q_UNUSED( data ); Q_UNUSED( feedback );
return false; }
610 bool userNoDataValuesContains(
int bandNo,
double value )
const;
653 std::unique_ptr< QgsRasterDataProviderTemporalCapabilities > mTemporalCapabilities;
657 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsRasterDataProvider::ProviderCapabilities )
@ YCbCr_YBand
Y Luminance.
@ MagentaBand
Magenta band of CMYK image.
DataType
Raster data types.
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 Qgis::DataType sourceDataType(int bandNo) const
Returns source data type for the band specified by number, source data type may be shorter than dataT...
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.
QList< bool > mSrcHasNoDataValue
Source no data value exists.
@ LightnessBand
Lightness band of HLS image.
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.
@ BlueBand
Blue band of RGBA image.
QList< QgsRasterRangeList > mUserNoDataValue
List of lists of user defined additional no data values for each band, indexed from 0.
bool setInput(QgsRasterInterface *input) override
Set input.
@ UndefinedColorInterpretation
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.
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.
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
virtual QString buildPyramids(const QList< QgsRasterPyramid > &pyramidList, const QString &resamplingMethod="NEAREST", QgsRaster::RasterPyramidsFormat format=QgsRaster::PyramidsGTiff, const QStringList &configOptions=QStringList(), QgsRasterBlockFeedback *feedback=nullptr)
Create 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 QgsFields fields() const
Returns the fields of the raster layer for data providers that expose them, the default implementatio...
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.
QDateTime timestamp() const override
Time stamp of data source in the moment when data/metadata were loaded by provider.
virtual int colorInterpretation(int bandNo) const
Returns data type for the band specified by number.
virtual bool setNoDataValue(int bandNo, double noDataValue)
Set no data value on created dataset.
virtual QList< QgsRasterPyramid > buildPyramidList(QList< int > overviewList=QList< int >())
Returns the raster layers pyramid list.
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.
static const int DEFAULT_MAXIMUM_TILE_WIDTH
Default maximum tile width.
@ RedBand
Red band of RGBA image.
virtual bool isEditable() const
Checks whether the provider is in editing mode, i.e.
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.
@ HueBand
Hue band of HLS image.
@ PaletteIndex
Paletted (see associated color table)
virtual QString colorInterpretationName(int bandNo) const
QString colorName(int colorInterpretation) const