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,
123 QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
131 virtual QgsRasterDataProvider::ProviderCapabilities providerCapabilities()
const;
155 virtual int colorInterpretation(
int bandNo )
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" );
226 virtual double bandScale(
int bandNo )
const { Q_UNUSED( bandNo )
return 1.0; }
232 virtual double bandOffset(
int bandNo )
const { Q_UNUSED( bandNo )
return 0.0; }
246 virtual void setUseSourceNoDataValue(
int bandNo,
bool use );
249 virtual double sourceNoDataValue(
int bandNo )
const {
return mSrcNoDataValue.value( bandNo - 1 ); }
256 virtual QList<QgsColorRampShader::ColorRampItem>
colorTable(
int bandNo )
const 257 { Q_UNUSED( bandNo )
return QList<QgsColorRampShader::ColorRampItem>(); }
265 return QStringList();
288 Q_UNUSED( forceRefresh )
289 Q_UNUSED( visibleExtent )
308 Q_UNUSED( mapSettings )
314 const QString &resamplingMethod =
"NEAREST",
316 const QStringList &configOptions = QStringList(),
319 Q_UNUSED( pyramidList )
320 Q_UNUSED( resamplingMethod )
322 Q_UNUSED( configOptions )
324 return QStringLiteral(
"FAILED_NOT_SUPPORTED" );
336 { Q_UNUSED( overviewList )
return QList<QgsRasterPyramid>(); }
345 virtual QString htmlMetadata() = 0;
387 virtual double sample(
const QgsPointXY &point,
int band,
399 virtual QString lastErrorTitle() = 0;
410 virtual QString lastError() = 0;
413 virtual QString lastErrorFormat();
416 int dpi()
const {
return mDpi; }
445 virtual bool setEditable(
bool enabled ) { Q_UNUSED( enabled )
return false; }
450 virtual bool write(
void *data,
int band,
int width,
int height,
int xOffset,
int yOffset )
477 bool writeBlock(
QgsRasterBlock *block,
int band,
int xOffset = 0,
int yOffset = 0 );
482 const QString &format,
int nBands,
484 int width,
int height,
double *geoTransform,
486 const QStringList &createOptions = QStringList() );
493 virtual bool setNoDataValue(
int bandNo,
double noDataValue ) { Q_UNUSED( bandNo ) Q_UNUSED( noDataValue );
return false; }
496 virtual bool remove() {
return false; }
502 static QList<QPair<QString, QString> > pyramidResamplingMethods(
const QString &providerKey );
510 { Q_UNUSED( createOptions ) Q_UNUSED( format );
return QString(); }
517 const QStringList &configOptions,
const QString &fileFormat )
518 { Q_UNUSED( pyramidsFormat ) Q_UNUSED( configOptions ); Q_UNUSED( fileFormat );
return QString(); }
547 virtual QList< double > nativeResolutions()
const;
555 virtual bool ignoreExtents()
const;
657 void readXml(
const QDomElement &filterElem )
override;
659 void writeXml( QDomDocument &doc, QDomElement &parentElem )
const override;
667 void statusChanged(
const QString & )
const;
676 virtual bool readBlock(
int bandNo,
int xBlock,
int yBlock,
void *data ) SIP_SKIP
677 { Q_UNUSED( bandNo ) Q_UNUSED( xBlock ); Q_UNUSED( yBlock ); Q_UNUSED( data );
return false; }
685 { Q_UNUSED( bandNo ) Q_UNUSED( viewExtent ); Q_UNUSED( width ); Q_UNUSED( height ); Q_UNUSED( data ); Q_UNUSED( feedback );
return false; }
688 bool userNoDataValuesContains(
int bandNo,
double value )
const;
727 bool mProviderResamplingEnabled =
false;
736 double mMaxOversampling = 2.0;
743 std::unique_ptr< QgsRasterDataProviderTemporalCapabilities > mTemporalCapabilities;
A rectangle specified with double values.
bool setInput(QgsRasterInterface *input) override
Set input.
virtual bool setZoomedInResamplingMethod(ResamplingMethod method)
Set resampling method to apply for zoomed-in operations.
bool isProviderResamplingEnabled() const
Returns whether provider-level resampling is enabled.
Black band of CMLY image.
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.
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.
virtual QgsFields fields() const
Returns the fields of the raster layer for data providers that expose them, the default implementatio...
A class to represent a 2D point.
ResamplingMethod zoomedOutResamplingMethod() const
Returns resampling method for zoomed-out operations.
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)
Returns a new image downloader for the raster legend.
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.
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.
Container of fields for a vector layer.
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.
Transforms layer (georeferenced) coordinates to image coordinates.
const QgsCoordinateReferenceSystem & crs
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)
virtual bool setZoomedOutResamplingMethod(ResamplingMethod method)
Set resampling method to apply for zoomed-out operations.
virtual bool enableProviderResampling(bool enable)
Enable or disable provider-level resampling.
Green band of RGBA image.
virtual QList< QgsRasterPyramid > buildPyramidList(QList< int > overviewList=QList< int >())
Returns 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
Default maximum tile height.
virtual bool reload()
Reload data (data could change)
QList< bool > mSrcHasNoDataValue
Source no data value exists.
TransformType
Types of transformation in transformCoordinates() function.
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...
double maxOversampling() const
Returns maximum oversampling factor for zoomed-out operations.
virtual QString colorInterpretationName(int bandNumber) const
Returns the name of the color interpretation for the specified bandNumber.
Base class for processing filters like renderers, reprojector, resampler etc.
virtual bool isEditable() const
Checks whether the provider is in editing mode, i.e.
Point geometry type, with support for z-dimension and m-values.
virtual bool sourceHasNoDataValue(int bandNo) const
Returns 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 bool readBlock(int bandNo, int xBlock, int yBlock, void *data)
Reads a block of raster data into data.
ResamplingMethod
Resampling method for provider-level resampling.
Implementation of data provider temporal properties for QgsRasterDataProviders.
virtual int stepHeight() const
Step height for raster iterations.
Setting options for creating vector data providers.
virtual QgsDataProviderTemporalCapabilities * temporalCapabilities()
Returns the provider's temporal capabilities.
QString colorName(int colorInterpretation) const
QList< QgsRasterRange > QgsRasterRangeList
ResamplingMethod zoomedInResamplingMethod() const
Returns resampling method for zoomed-in operations.
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
virtual bool setMaxOversampling(double factor)
Sets maximum oversampling factor for zoomed-out operations.
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.
Transforms image coordinates to layer (georeferenced) coordinates.
virtual QgsRasterRangeList userNoDataValues(int bandNo) const
Returns a 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
Returns the source nodata value usage.
Feedback object tailored for raster block reading.
static const int DEFAULT_MAXIMUM_TILE_WIDTH
Default maximum tile width.
void setDpi(int dpi)
Sets the output device resolution.
QgsImageFetcher(QObject *parent=nullptr)
Constructor.
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.