23 #ifndef QGSRASTERDATAPROVIDER_H 24 #define QGSRASTERDATAPROVIDER_H 26 #include "qgis_core.h" 66 virtual void start() = 0;
73 void finish(
const QImage &legend );
75 void progress( qint64 received, qint64 total );
77 void error(
const QString &msg );
97 NoProviderCapabilities = 0,
98 ReadLayerMetadata = 1 << 1,
99 WriteLayerMetadata = 1 << 2,
115 virtual QgsRasterDataProvider::ProviderCapabilities providerCapabilities()
const;
141 switch ( colorInterpretation )
144 return QStringLiteral(
"Undefined" );
147 return QStringLiteral(
"Gray" );
150 return QStringLiteral(
"Palette" );
153 return QStringLiteral(
"Red" );
156 return QStringLiteral(
"Green" );
159 return QStringLiteral(
"Blue" );
162 return QStringLiteral(
"Alpha" );
165 return QStringLiteral(
"Hue" );
168 return QStringLiteral(
"Saturation" );
171 return QStringLiteral(
"Lightness" );
174 return QStringLiteral(
"Cyan" );
177 return QStringLiteral(
"Magenta" );
180 return QStringLiteral(
"Yellow" );
183 return QStringLiteral(
"Black" );
186 return QStringLiteral(
"YCbCr_Y" );
189 return QStringLiteral(
"YCbCr_Cb" );
192 return QStringLiteral(
"YCbCr_Cr" );
195 return QStringLiteral(
"Unknown" );
203 return colorName( colorInterpretation( bandNo ) );
210 virtual double bandScale(
int bandNo )
const { Q_UNUSED( bandNo );
return 1.0; }
216 virtual double bandOffset(
int bandNo )
const { Q_UNUSED( bandNo );
return 0.0; }
230 virtual void setUseSourceNoDataValue(
int bandNo,
bool use );
233 virtual double sourceNoDataValue(
int bandNo )
const {
return mSrcNoDataValue.value( bandNo - 1 ); }
240 virtual QList<QgsColorRampShader::ColorRampItem>
colorTable(
int bandNo )
const 241 { Q_UNUSED( bandNo );
return QList<QgsColorRampShader::ColorRampItem>(); }
248 return QStringList();
267 Q_UNUSED( forceRefresh );
268 Q_UNUSED( visibleExtent );
287 Q_UNUSED( mapSettings );
293 const QString &resamplingMethod =
"NEAREST",
295 const QStringList &configOptions = QStringList(),
298 Q_UNUSED( pyramidList );
299 Q_UNUSED( resamplingMethod );
301 Q_UNUSED( configOptions );
302 Q_UNUSED( feedback );
303 return QStringLiteral(
"FAILED_NOT_SUPPORTED" );
315 { Q_UNUSED( overviewList );
return QList<QgsRasterPyramid>(); }
324 virtual QString htmlMetadata() = 0;
361 virtual QString lastErrorTitle() = 0;
372 virtual QString lastError() = 0;
375 virtual QString lastErrorFormat();
378 int dpi()
const {
return mDpi; }
407 virtual bool setEditable(
bool enabled ) { Q_UNUSED( enabled );
return false; }
411 virtual bool write(
void *data,
int band,
int width,
int height,
int xOffset,
int yOffset )
438 bool writeBlock(
QgsRasterBlock *block,
int band,
int xOffset = 0,
int yOffset = 0 );
443 const QString &format,
int nBands,
445 int width,
int height,
double *geoTransform,
447 const QStringList &createOptions = QStringList() );
454 virtual bool setNoDataValue(
int bandNo,
double noDataValue ) { Q_UNUSED( bandNo ); Q_UNUSED( noDataValue );
return false; }
457 virtual bool remove() {
return false; }
463 static QList<QPair<QString, QString> > pyramidResamplingMethods(
const QString &providerKey );
471 { Q_UNUSED( createOptions ); Q_UNUSED( format );
return QString(); }
478 const QStringList &configOptions,
const QString &fileFormat )
479 { Q_UNUSED( pyramidsFormat ); Q_UNUSED( configOptions ); Q_UNUSED( fileFormat );
return QString(); }
506 void statusChanged(
const QString & )
const;
515 { Q_UNUSED( bandNo ); Q_UNUSED( xBlock ); Q_UNUSED( yBlock ); Q_UNUSED( data ); }
522 { Q_UNUSED( bandNo ); Q_UNUSED( viewExtent ); Q_UNUSED( width ); Q_UNUSED( height ); Q_UNUSED( data ); Q_UNUSED( feedback ); }
525 bool userNoDataValuesContains(
int bandNo,
double value )
const;
531 static QStringList cStringList2Q_(
char **stringList )
SIP_SKIP;
564 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsRasterDataProvider::ProviderCapabilities )
virtual void readBlock(int bandNo, int xBlock, int yBlock, void *data)
Read block of data.
A rectangle specified with double values.
bool setInput(QgsRasterInterface *input) override
Set input.
Black band of CMLY image.
Handles asynchronous download of images.
virtual QList< QgsColorRampShader::ColorRampItem > colorTable(int bandNo) const
virtual double bandOffset(int bandNo) const
Read band offset for raster value.
A class to represent a 2D point.
QDateTime mTimestamp
Timestamp of data in the moment when the data were loaded by provider.
DataType
Raster data types.
virtual QgsImageFetcher * getLegendGraphicFetcher(const QgsMapSettings *mapSettings)
Get an image downloader for the raster legend.
Capability
If you add to this, please also add to capabilitiesString()
virtual QImage getLegendGraphic(double scale=0, bool forceRefresh=false, const QgsRectangle *visibleExtent=nullptr)
Returns the legend rendered as pixmap.
virtual bool supportsLegendGraphic() const
Returns whether the provider supplies a legend graphic.
virtual bool setNoDataValue(int bandNo, double noDataValue)
Set no data value on created dataset.
Abstract base class for spatial data provider implementations.
virtual Qgis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
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 sourceNoDataValue(int bandNo) const
Value representing no data value.
virtual QString validatePyramidsConfigOptions(QgsRaster::RasterPyramidsFormat pyramidsFormat, const QStringList &configOptions, const QString &fileFormat)
Validates pyramid creation options for a specific dataset and destination format. ...
The QgsMapSettings class contains configuration for rendering of the map.
QDateTime timestamp() const override
Time stamp of data source in the moment when data/metadata were loaded by provider.
Raster identify results container.
ProviderCapability
Enumeration with capabilities that raster providers might implement.
Lightness band of HLS image.
int dpi() const
Returns the dpi of the output device.
virtual bool setEditable(bool enabled)
Turns on/off editing mode of the provider.
Paletted (see associated color table)
Alpha (0=transparent, 255=opaque)
Green band of RGBA image.
virtual QList< QgsRasterPyramid > buildPyramidList(QList< int > overviewList=QList< int >())
Accessor for the raster layers pyramid list.
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.
static const int DEFAULT_MAXIMUM_TILE_HEIGHT
virtual bool reload()
Reload data (data could change)
QList< bool > mSrcHasNoDataValue
Source no data value exists.
virtual QString colorInterpretationName(int bandNo) const
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 void readBlock(int bandNo, QgsRectangle const &viewExtent, int width, int height, void *data, QgsRasterBlockFeedback *feedback=nullptr)
Read block of data using give extent and size.
Base class for processing filters like renderers, reprojector, resampler etc.
virtual bool isEditable() const
Checks whether the provider is in editing mode, i.e.
virtual bool sourceHasNoDataValue(int bandNo) const
Return true if source band has no data value.
Saturation band of HLS image.
QList< double > mSrcNoDataValue
Source no data value is available and is set to be used or internal no data is available.
virtual int stepHeight() const
Step height for raster iterations.
QString colorName(int colorInterpretation) const
QList< QgsRasterRange > QgsRasterRangeList
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
This class represents a coordinate reference system (CRS).
QStringList subLayers() const override
Returns the sublayers of this layer - useful for providers that manage their own layers, such as WMS.
virtual QgsRasterRangeList userNoDataValues(int bandNo) const
Get list of user no data value ranges.
virtual int stepWidth() const
Step width for raster iterations.
Magenta band of CMYK image.
virtual QString validateCreationOptions(const QStringList &createOptions, const QString &format)
Validates creation options for a specific dataset and destination format.
virtual QgsRectangle extent() const =0
Returns the extent of the layer.
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.
virtual bool useSourceNoDataValue(int bandNo) const
Get source nodata value usage.
Feedback object tailored for raster block reading.
static const int DEFAULT_MAXIMUM_TILE_WIDTH
void setDpi(int dpi)
Sets the output device resolution.
QgsImageFetcher(QObject *parent=nullptr)
Constructor.
virtual int colorInterpretation(int bandNo) const
Returns data type for the band specified by number.
Base class for raster data providers.
QList< QgsRasterRangeList > mUserNoDataValue
List of lists of user defined additional no data values for each band, indexed from 0...
QList< bool > mUseSrcNoDataValue
Use source nodata value.
Yellow band of CMYK image.
virtual double bandScale(int bandNo) const
Read band scale for raster value.