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,
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" );
221 QString colorInterpretationName(
int bandNo )
const override;
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>(); }
421 virtual double sample(
const QgsPointXY &point,
int band,
447 virtual QString lastErrorFormat();
450 int dpi()
const {
return mDpi; }
456 QDateTime
timestamp()
const override {
return mTimestamp; }
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 );
544 { Q_UNUSED( createOptions ) Q_UNUSED( format );
return QString(); }
551 const QStringList &configOptions,
const QString &fileFormat )
552 { Q_UNUSED( pyramidsFormat ) Q_UNUSED( configOptions ); Q_UNUSED( fileFormat );
return QString(); }
581 virtual QList< double > nativeResolutions()
const;
589 virtual bool ignoreExtents()
const;
613 virtual QgsPoint transformCoordinates(
const QgsPoint &point, TransformType type );
696 void readXml(
const QDomElement &filterElem )
override;
698 void writeXml( QDomDocument &doc, QDomElement &parentElem )
const override;
716 { Q_UNUSED( bandNo ) Q_UNUSED( xBlock ); Q_UNUSED( yBlock ); Q_UNUSED( data );
return false; }
724 { Q_UNUSED( bandNo ) Q_UNUSED( viewExtent ); Q_UNUSED( width ); Q_UNUSED( height ); Q_UNUSED( data ); Q_UNUSED( feedback );
return false; }
727 bool userNoDataValuesContains(
int bandNo,
double value )
const;
766 bool mProviderResamplingEnabled =
false;
775 double mMaxOversampling = 2.0;
782 std::unique_ptr< QgsRasterDataProviderTemporalCapabilities > mTemporalCapabilities;
DataType
Raster data types.
This class represents a coordinate reference system (CRS).
Abstract base class for spatial data provider implementations.
Container of fields for a vector layer.
Handles asynchronous download of images.
QgsImageFetcher(QObject *parent=nullptr)
Constructor.
void progress(qint64 received, qint64 total)
Emitted to report progress.
void error(const QString &msg)
Emitted when an error occurs.
void finish(const QImage &legend)
Emitted when the download completes.
virtual void start()=0
Starts the image download.
The QgsMapSettings class contains configuration for rendering of the map.
A class to represent a 2D point.
Point geometry type, with support for z-dimension and m-values.
Feedback object tailored for raster block reading.
Implementation of data provider temporal properties for QgsRasterDataProviders.
Base class for raster data providers.
virtual QgsFields fields() const
Returns the fields of the raster layer for data providers that expose them, the default implementatio...
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.
QList< bool > mUseSrcNoDataValue
Use source nodata value.
TransformType
Types of transformation in transformCoordinates() function.
@ TransformLayerToImage
Transforms layer (georeferenced) coordinates to image coordinates.
@ TransformImageToLayer
Transforms image coordinates to layer (georeferenced) coordinates.
virtual QList< QgsColorRampShader::ColorRampItem > colorTable(int bandNo) const
virtual bool setNoDataValue(int bandNo, double noDataValue)
Set no data value on created dataset.
virtual double bandOffset(int bandNo) const
Read band offset for raster value.
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.
virtual bool useSourceNoDataValue(int bandNo) const
Returns the source nodata value usage.
virtual QString validateCreationOptions(const QStringList &createOptions, const QString &format)
Validates creation options for a specific dataset and destination format.
virtual QString lastError()=0
Returns the verbose error text for the last error in this provider.
virtual QList< QgsRasterPyramid > buildPyramidList(const QList< int > &overviewList=QList< int >())
Returns the raster layers pyramid list.
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...
bool isProviderResamplingEnabled() const
Returns whether provider-level resampling is enabled.
virtual bool remove()
Remove dataset.
virtual double sourceNoDataValue(int bandNo) const
Value representing no data value.
QString colorName(int colorInterpretation) const
virtual QImage getLegendGraphic(double scale=0, bool forceRefresh=false, const QgsRectangle *visibleExtent=nullptr)
Returns the legend rendered as pixmap.
virtual bool reload()
Reload data (data could change)
QList< QgsRasterRangeList > mUserNoDataValue
List of lists of user defined additional no data values for each band, indexed from 0.
ResamplingMethod zoomedOutResamplingMethod() const
Returns resampling method for zoomed-out operations.
virtual bool isEditable() const
Checks whether the provider is in editing mode, i.e.
QgsRasterDataProvider * clone() const override=0
Clone itself, create deep copy.
virtual bool enableProviderResampling(bool enable)
Enable or disable provider-level resampling.
void setDpi(int dpi)
Sets the output device resolution.
QDateTime timestamp() const override
Time stamp of data source in the moment when data/metadata were loaded by provider.
QgsRectangle extent() const override=0
Returns the extent of the layer.
virtual bool setMaxOversampling(double factor)
Sets maximum oversampling factor for zoomed-out operations.
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
double maxOversampling() const
Returns maximum oversampling factor for zoomed-out operations.
QStringList subLayers() const override
Returns the sublayers of this layer - useful for providers that manage their own layers,...
virtual double bandScale(int bandNo) const
Read band scale for raster value.
ProviderCapability
Enumeration with capabilities that raster providers might implement.
int dpi() const
Returns the dpi of the output device.
virtual QString validatePyramidsConfigOptions(QgsRaster::RasterPyramidsFormat pyramidsFormat, const QStringList &configOptions, const QString &fileFormat)
Validates pyramid creation options for a specific dataset and destination format.
QDateTime dataTimestamp() const override
Current time stamp of data source.
virtual QString htmlMetadata()=0
Returns metadata in a format suitable for feeding directly into a subset of the GUI raster properties...
QList< double > mSrcNoDataValue
Source no data value is available and is set to be used or internal no data is available.
virtual bool readBlock(int bandNo, int xBlock, int yBlock, void *data)
Reads a block of raster data into data.
bool setInput(QgsRasterInterface *input) override
Set input.
QList< bool > mSrcHasNoDataValue
Source no data value exists.
void statusChanged(const QString &) const
Emit a message to be displayed on status bar, usually used by network providers (WMS,...
virtual QgsRasterRangeList userNoDataValues(int bandNo) const
Returns a list of user no data value ranges.
virtual bool setZoomedInResamplingMethod(ResamplingMethod method)
Set resampling method to apply for zoomed-in operations.
virtual int stepHeight() const
Step height for raster iterations.
virtual bool setEditable(bool enabled)
Turns on/off editing mode of the provider.
virtual int stepWidth() const
Step width for raster iterations.
ResamplingMethod zoomedInResamplingMethod() const
Returns resampling method for zoomed-in operations.
ResamplingMethod
Resampling method for provider-level resampling.
virtual QString lastErrorTitle()=0
Returns the caption error text for the last error in this provider.
virtual bool write(void *data, int band, int width, int height, int xOffset, int yOffset)
Writes into the provider datasource.
virtual bool setZoomedOutResamplingMethod(ResamplingMethod method)
Set resampling method to apply for zoomed-out operations.
virtual QgsImageFetcher * getLegendGraphicFetcher(const QgsMapSettings *mapSettings)
Returns a new image downloader for the raster legend.
Raster identify results container.
Base class for processing filters like renderers, reprojector, resampler etc.
static const int DEFAULT_MAXIMUM_TILE_WIDTH
Default maximum tile width.
static const int DEFAULT_MAXIMUM_TILE_HEIGHT
Default maximum tile height.
@ RedBand
Red band of RGBA image.
@ UndefinedColorInterpretation
@ YCbCr_YBand
Y Luminance.
@ YellowBand
Yellow band of CMYK image.
@ BlueBand
Blue band of RGBA image.
@ PaletteIndex
Paletted (see associated color table)
@ HueBand
Hue band of HLS image.
@ LightnessBand
Lightness band of HLS image.
@ AlphaBand
Alpha (0=transparent, 255=opaque)
@ BlackBand
Black band of CMLY image.
@ GreenBand
Green band of RGBA image.
@ CyanBand
Cyan band of CMYK image.
@ SaturationBand
Saturation band of HLS image.
@ MagentaBand
Magenta band of CMYK image.
A rectangle specified with double values.
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.
QList< QgsRasterRange > QgsRasterRangeList
const QgsCoordinateReferenceSystem & crs
Setting options for creating vector data providers.