QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
23 #ifndef QGSRASTERDATAPROVIDER_H
24 #define QGSRASTERDATAPROVIDER_H
26 #include "qgis_core.h"
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
108 Q_DECLARE_FLAGS( ProviderCapabilities, ProviderCapability )
122 QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
130 virtual QgsRasterDataProvider::ProviderCapabilities providerCapabilities()
const;
163 switch ( colorInterpretation )
166 return QStringLiteral(
"Undefined" );
169 return QStringLiteral(
"Gray" );
172 return QStringLiteral(
"Palette" );
175 return QStringLiteral(
"Red" );
178 return QStringLiteral(
"Green" );
181 return QStringLiteral(
"Blue" );
184 return QStringLiteral(
"Alpha" );
187 return QStringLiteral(
"Hue" );
190 return QStringLiteral(
"Saturation" );
193 return QStringLiteral(
"Lightness" );
196 return QStringLiteral(
"Cyan" );
199 return QStringLiteral(
"Magenta" );
202 return QStringLiteral(
"Yellow" );
205 return QStringLiteral(
"Black" );
208 return QStringLiteral(
"YCbCr_Y" );
211 return QStringLiteral(
"YCbCr_Cb" );
214 return QStringLiteral(
"YCbCr_Cr" );
217 return QStringLiteral(
"Unknown" );
225 return colorName( colorInterpretation( bandNo ) );
232 virtual double bandScale(
int bandNo )
const { Q_UNUSED( bandNo )
return 1.0; }
238 virtual double bandOffset(
int bandNo )
const { Q_UNUSED( bandNo )
return 0.0; }
246 virtual
bool sourceHasNoDataValue(
int bandNo )
const {
return mSrcHasNoDataValue.value( bandNo - 1 ); }
252 virtual void setUseSourceNoDataValue(
int bandNo,
bool use );
255 virtual double sourceNoDataValue(
int bandNo )
const {
return mSrcNoDataValue.value( bandNo - 1 ); }
262 virtual QList<QgsColorRampShader::ColorRampItem>
colorTable(
int bandNo )
const
263 { Q_UNUSED( bandNo )
return QList<QgsColorRampShader::ColorRampItem>(); }
271 return QStringList();
278 virtual
bool supportsLegendGraphic()
const {
return false; }
294 Q_UNUSED( forceRefresh )
295 Q_UNUSED( visibleExtent )
314 Q_UNUSED( mapSettings )
320 const QString &resamplingMethod =
"NEAREST",
322 const QStringList &configOptions = QStringList(),
325 Q_UNUSED( pyramidList )
326 Q_UNUSED( resamplingMethod )
328 Q_UNUSED( configOptions )
330 return QStringLiteral(
"FAILED_NOT_SUPPORTED" );
342 { Q_UNUSED( overviewList )
return QList<QgsRasterPyramid>(); }
351 virtual QString htmlMetadata() = 0;
393 virtual double sample(
const QgsPointXY &point,
int band,
419 virtual QString lastErrorFormat();
422 int dpi()
const {
return mDpi; }
451 virtual bool setEditable(
bool enabled ) { Q_UNUSED( enabled )
return false; }
456 virtual bool write(
void *data,
int band,
int width,
int height,
int xOffset,
int yOffset )
483 bool writeBlock(
QgsRasterBlock *block,
int band,
int xOffset = 0,
int yOffset = 0 );
488 const QString &format,
int nBands,
490 int width,
int height,
double *geoTransform,
492 const QStringList &createOptions = QStringList() );
499 virtual bool setNoDataValue(
int bandNo,
double noDataValue ) { Q_UNUSED( bandNo ) Q_UNUSED( noDataValue );
return false; }
508 static QList<QPair<QString, QString> > pyramidResamplingMethods(
const QString &providerKey );
516 { Q_UNUSED( createOptions ) Q_UNUSED( format );
return QString(); }
523 const QStringList &configOptions,
const QString &fileFormat )
524 { Q_UNUSED( pyramidsFormat ) Q_UNUSED( configOptions ); Q_UNUSED( fileFormat );
return QString(); }
553 virtual QList< double > nativeResolutions()
const;
561 virtual bool ignoreExtents()
const;
585 virtual QgsPoint transformCoordinates(
const QgsPoint &point, TransformType type );
663 void readXml(
const QDomElement &filterElem )
override;
665 void writeXml( QDomDocument &doc, QDomElement &parentElem )
const override;
683 { Q_UNUSED( bandNo ) Q_UNUSED( xBlock ); Q_UNUSED( yBlock ); Q_UNUSED( data );
return false; }
691 { Q_UNUSED( bandNo ) Q_UNUSED( viewExtent ); Q_UNUSED( width ); Q_UNUSED( height ); Q_UNUSED( data ); Q_UNUSED( feedback );
return false; }
694 bool userNoDataValuesContains(
int bandNo,
double value )
const;
733 bool mProviderResamplingEnabled =
false;
742 double mMaxOversampling = 2.0;
749 std::unique_ptr< QgsRasterDataProviderTemporalCapabilities > mTemporalCapabilities;
virtual QString lastError()=0
Returns the verbose error text for the last error in this provider.
@ YCbCr_YBand
Y Luminance.
ResamplingMethod zoomedInResamplingMethod() const
Returns resampling method for zoomed-in operations.
@ 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.
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
Setting options for creating vector data providers.
virtual void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
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 void start()=0
Starts the image download.
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.
QgsRectangle extent() const override=0
Returns the extent of the layer.
@ 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.
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 QString lastErrorTitle()=0
Returns the caption error text for the last error in this provider.
virtual bool setZoomedInResamplingMethod(ResamplingMethod method)
Set resampling method to apply for zoomed-in operations.
QgsRasterDataProvider * clone() const override=0
Clone itself, create deep copy.
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.
void progress(qint64 received, qint64 total)
Emitted to report progress.
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.
@ 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 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 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 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 int colorInterpretation(int bandNo) const
Returns data type for the band specified by number.
Qgis::DataType sourceDataType(int bandNo) const override=0
Returns source data type for the band specified by number, source data type may be shorter than dataT...
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.
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.
virtual QgsDataProviderTemporalCapabilities * temporalCapabilities()
Returns the provider's temporal capabilities.
QList< bool > mUseSrcNoDataValue
Use source nodata value.
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.
void statusChanged(const QString &) const
Emit a message to be displayed on status bar, usually used by network providers (WMS,...
@ RedBand
Red band of RGBA image.
void finish(const QImage &legend)
Emitted when the download completes.
virtual bool isEditable() const
Checks whether the provider is in editing mode, i.e.
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.
@ 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.
virtual QString colorInterpretationName(int bandNo) const
Implementation of data provider temporal properties for QgsRasterDataProviders.
void error(const QString &msg)
Emitted when an error occurs.
QString colorName(int colorInterpretation) const