35#include "moc_qgsrasterdataprovider.cpp"
37using namespace Qt::StringLiterals;
39#define ERR( message ) QgsError( message, "Raster provider" )
59 QgsDebugMsgLevel( u
"bandNo = %1 width = %2 height = %3"_s.arg( bandNo ).arg( width ).arg( height ), 4 );
62 auto block = std::make_unique< QgsRasterBlock >(
dataType( bandNo ), width, height );
68 if (
block->isEmpty() )
71 block->setError( { tr(
"Couldn't create raster block." ), u
"Raster"_s } );
72 block->setValid(
false );
73 return block.release();
82 block->setError( { tr(
"Extent outside provider extent." ), u
"Raster"_s } );
83 block->setValid(
false );
85 return block.release();
88 const double xRes = boundingBox.
width() / width;
89 const double yRes = boundingBox.
height() / height;
90 double tmpXRes, tmpYRes;
91 double providerXRes = 0;
92 double providerYRes = 0;
97 tmpXRes = std::max( providerXRes, xRes );
98 tmpYRes = std::max( providerYRes, yRes );
110 if ( tmpExtent != boundingBox || tmpXRes > xRes || tmpYRes > yRes )
114 if ( !
extent().contains( boundingBox ) )
117 block->setIsNoDataExcept( subRect );
121 const int fromRow = std::round( ( boundingBox.
yMaximum() - tmpExtent.
yMaximum() ) / yRes );
122 const int toRow = std::round( ( boundingBox.
yMaximum() - tmpExtent.
yMinimum() ) / yRes ) - 1;
123 const int fromCol = std::round( ( tmpExtent.
xMinimum() - boundingBox.
xMinimum() ) / xRes );
124 const int toCol = std::round( ( tmpExtent.
xMaximum() - boundingBox.
xMinimum() ) / xRes ) - 1;
126 QgsDebugMsgLevel( u
"fromRow = %1 toRow = %2 fromCol = %3 toCol = %4"_s.arg( fromRow ).arg( toRow ).arg( fromCol ).arg( toCol ), 4 );
128 if ( fromRow < 0 || fromRow >= height || toRow < 0 || toRow >= height || fromCol < 0 || fromCol >= width || toCol < 0 || toCol >= width )
132 block->setError( { tr(
"Row or column limits out of range" ), u
"Raster"_s } );
133 block->setValid(
false );
134 return block.release();
139 if ( tmpXRes > xRes )
141 int col = std::floor( ( tmpExtent.
xMinimum() -
extent().xMinimum() ) / providerXRes );
143 col = std::ceil( ( tmpExtent.
xMaximum() -
extent().xMinimum() ) / providerXRes );
146 if ( tmpYRes > yRes )
148 int row = std::floor( (
extent().yMaximum() - tmpExtent.
yMaximum() ) / providerYRes );
150 row = std::ceil( (
extent().yMaximum() - tmpExtent.
yMinimum() ) / providerYRes );
153 const int tmpWidth = std::round( tmpExtent.
width() / tmpXRes );
154 const int tmpHeight = std::round( tmpExtent.
height() / tmpYRes );
155 tmpXRes = tmpExtent.
width() / tmpWidth;
156 tmpYRes = tmpExtent.
height() / tmpHeight;
158 QgsDebugMsgLevel( u
"Reading smaller block tmpWidth = %1 height = %2"_s.arg( tmpWidth ).arg( tmpHeight ), 4 );
161 auto tmpBlock = std::make_unique< QgsRasterBlock >(
dataType( bandNo ), tmpWidth, tmpHeight );
167 if ( !
readBlock( bandNo, tmpExtent, tmpWidth, tmpHeight, tmpBlock->bits(), feedback ) )
170 block->setError( { tr(
"Error occurred while reading block." ), u
"Raster"_s } );
171 block->setValid(
false );
172 block->setIsNoData();
173 return block.release();
178 const double xMin = boundingBox.
xMinimum();
179 const double yMax = boundingBox.
yMaximum();
180 const double tmpXMin = tmpExtent.
xMinimum();
181 const double tmpYMax = tmpExtent.
yMaximum();
183 for (
int row = fromRow; row <= toRow; row++ )
185 const double y = yMax - ( row + 0.5 ) * yRes;
186 const int tmpRow = std::floor( ( tmpYMax - y ) / tmpYRes );
188 for (
int col = fromCol; col <= toCol; col++ )
190 const double x = xMin + ( col + 0.5 ) * xRes;
191 const int tmpCol = std::floor( ( x - tmpXMin ) / tmpXRes );
193 if ( tmpRow < 0 || tmpRow >= tmpHeight || tmpCol < 0 || tmpCol >= tmpWidth )
195 QgsDebugError( u
"Source row or column limits out of range"_s );
196 block->setIsNoData();
197 block->setError( { tr(
"Source row or column limits out of range." ), u
"Raster"_s } );
198 block->setValid(
false );
199 return block.release();
202 const qgssize tmpIndex =
static_cast< qgssize >( tmpRow ) *
static_cast< qgssize >( tmpWidth ) + tmpCol;
203 const qgssize index = row *
static_cast< qgssize >( width ) + col;
205 const char *tmpBits = tmpBlock->constBits( tmpIndex );
206 char *bits =
block->bits( index );
209 QgsDebugError( u
"Cannot get input block data tmpRow = %1 tmpCol = %2 tmpIndex = %3."_s.arg( tmpRow ).arg( tmpCol ).arg( tmpIndex ) );
217 memcpy( bits, tmpBits, pixelSize );
223 if ( !
readBlock( bandNo, boundingBox, width, height,
block->bits(), feedback ) )
226 block->setIsNoData();
227 block->setError( { tr(
"Error occurred while reading block." ), u
"Raster"_s } );
228 block->setValid(
false );
229 return block.release();
237 return block.release();
277 QMap<int, QVariant> results;
285 if ( !
extent().contains( point ) )
288 for (
int bandNo = 1; bandNo <=
bandCount(); bandNo++ )
290 results.insert( bandNo, QVariant() );
309 const double xres = ( finalExtent.
width() ) / width;
310 const double yres = ( finalExtent.
height() ) / height;
312 const int col =
static_cast< int >( std::floor( ( point.
x() - finalExtent.
xMinimum() ) / xres ) );
313 const int row =
static_cast< int >( std::floor( ( finalExtent.
yMaximum() - point.
y() ) / yres ) );
315 const double xMin = finalExtent.
xMinimum() + col * xres;
316 const double xMax = xMin + xres;
317 const double yMax = finalExtent.
yMaximum() - row * yres;
318 const double yMin = yMax - yres;
319 const QgsRectangle pixelExtent( xMin, yMin, xMax, yMax );
321 for (
int bandNumber = 1; bandNumber <=
bandCount(); bandNumber++ )
323 std::unique_ptr< QgsRasterBlock > bandBlock(
block( bandNumber, pixelExtent, 1, 1 ) );
327 const double value = bandBlock->value( 0 );
331 results.insert( bandNumber, QVariant() );
335 results.insert( bandNumber, value );
340 results.insert( bandNumber, QVariant() );
354 const QVariant value = res.results().value( band );
356 if ( !value.isValid() )
357 return std::numeric_limits<double>::quiet_NaN();
362 return value.toDouble( ok );
369 return u
"text/plain"_s;
380 setError(
QgsError( u
"writeBlock() called on read-only provider."_s, u
"writeBlock"_s ) );
381 QgsDebugError( u
"writeBlock() called on read-only provider."_s );
391 if ( methods.isEmpty() )
393 QgsDebugMsgLevel( u
"provider pyramidResamplingMethods returned no methods"_s, 2 );
403 return std::any_of( pyramidList.constBegin(), pyramidList.constEnd(), [](
QgsRasterPyramid pyramid ) { return pyramid.getExists(); } );
417 QgsDebugMsgLevel( u
"set %1 band %1 no data ranges"_s.arg( noData.size() ), 4 );
432 return mTemporalCapabilities.get();
439 return mTemporalCapabilities.get();
446 return mElevationProperties.get();
453 return mElevationProperties.get();
457 const QString &providerKey,
459 const QString &format,
464 double *geoTransform,
466 const QStringList &creationOptions
472 QgsDebugError(
"Cannot resolve 'createRasterDataProviderFunction' function in " + providerKey +
" provider" );
496 return u
"Undefined"_s;
504 return tr(
"Value" );
510 return tr(
"Feature" );
514 return u
"Undefined"_s;
519 if ( formatName ==
"Value"_L1 )
521 if ( formatName ==
"Text"_L1 )
523 if ( formatName ==
"Html"_L1 )
525 if ( formatName ==
"Feature"_L1 )
552 return QList< double >();
594 if ( mTemporalCapabilities && other.mTemporalCapabilities )
596 *mTemporalCapabilities = *other.mTemporalCapabilities;
598 if ( mElevationProperties && other.mElevationProperties )
600 *mElevationProperties = *other.mElevationProperties;
606 if ( str ==
"bilinear"_L1 )
610 else if ( str ==
"cubic"_L1 )
614 else if ( str ==
"cubicSpline"_L1 )
618 else if ( str ==
"lanczos"_L1 )
622 else if ( str ==
"average"_L1 )
626 else if ( str ==
"mode"_L1 )
630 else if ( str ==
"gauss"_L1 )
641 if ( filterElem.isNull() )
646 const QDomElement resamplingElement = filterElem.firstChildElement( u
"resampling"_s );
647 if ( !resamplingElement.isNull() )
649 setMaxOversampling( resamplingElement.attribute( u
"maxOversampling"_s, u
"2.0"_s ).toDouble() );
661 return u
"nearestNeighbour"_s;
663 return u
"bilinear"_s;
667 return u
"cubicSpline"_s;
678 return u
"nearestNeighbour"_s;
685 QDomElement providerElement = doc.createElement( u
"provider"_s );
686 parentElem.appendChild( providerElement );
688 QDomElement resamplingElement = doc.createElement( u
"resampling"_s );
689 providerElement.appendChild( resamplingElement );
697 resamplingElement.setAttribute( u
"maxOversampling"_s, QString::number(
mMaxOversampling ) );
706 return mAttributeTables.at( bandNumber ).get();
708 catch ( std::out_of_range
const & )
720 mAttributeTables[bandNumber] = std::unique_ptr<QgsRasterAttributeTable>(
attributeTable );
732 if ( mAttributeTables.find( bandNumber ) != std::end( mAttributeTables ) )
734 mAttributeTables.erase( bandNumber );
747 *errorMessage = QObject::tr(
"Raster has no Raster Attribute Table for band %1" ).arg( bandNumber );
761 *errorMessage = QObject::tr(
"Raster data provider has no native Raster Attribute Table support." );
768 Q_UNUSED( bandNumber )
776 auto rat = std::make_unique<QgsRasterAttributeTable>();
777 if ( rat->readFromFile( path, errorMessage ) )
792 Q_UNUSED( errorMessage );
809 return tr(
"Undefined" );
815 return tr(
"Palette" );
821 return tr(
"Green" );
827 return tr(
"Alpha" );
833 return tr(
"Saturation" );
836 return tr(
"Lightness" );
842 return tr(
"Magenta" );
845 return tr(
"Yellow" );
848 return tr(
"Black" );
851 return tr(
"YCbCr_Y" );
854 return tr(
"YCbCr_Cb" );
857 return tr(
"YCbCr_Cr" );
860 return tr(
"Continuous Palette" );
863 return tr(
"Panchromatic" );
866 return tr(
"Coastal" );
869 return tr(
"Red Edge" );
872 return tr(
"Near-InfraRed (NIR)" );
875 return tr(
"Short-Wavelength InfraRed (SWIR)" );
878 return tr(
"Mid-Wavelength InfraRed (MWIR)" );
881 return tr(
"Long-Wavelength InfraRed (LWIR)" );
884 return tr(
"Thermal InfraRed (TIR)" );
887 return tr(
"Other InfraRed" );
890 return tr(
"Synthetic Aperture Radar (SAR) Ka band" );
893 return tr(
"Synthetic Aperture Radar (SAR) K band" );
896 return tr(
"Synthetic Aperture Radar (SAR) Ku band" );
899 return tr(
"Synthetic Aperture Radar (SAR) X band" );
902 return tr(
"Synthetic Aperture Radar (SAR) C band" );
905 return tr(
"Synthetic Aperture Radar (SAR) S band" );
908 return tr(
"Synthetic Aperture Radar (SAR) L band" );
911 return tr(
"Synthetic Aperture Radar (SAR) P band" );
918 QUrl url = QUrl::fromPercentEncoding(
uri.toUtf8() );
919 const QUrlQuery query( url.query() );
922 if ( !query.hasQueryItem( u
"crs"_s ) )
938 if ( !query.hasQueryItem( u
"extent"_s ) )
945 QStringList pointValuesList = query.queryItemValue( u
"extent"_s ).split(
',' );
946 if ( pointValuesList.size() != 4 )
953 components.
extent =
QgsRectangle( pointValuesList.at( 0 ).toDouble(), pointValuesList.at( 1 ).toDouble(), pointValuesList.at( 2 ).toDouble(), pointValuesList.at( 3 ).toDouble() );
955 if ( !query.hasQueryItem( u
"width"_s ) )
963 components.
width = query.queryItemValue( u
"width"_s ).toInt( &flagW );
964 if ( !flagW || components.
width < 0 )
972 if ( !query.hasQueryItem( u
"height"_s ) )
980 components.
height = query.queryItemValue( u
"height"_s ).toInt( &flagH );
981 if ( !flagH || components.
height < 0 )
989 if ( !query.hasQueryItem( u
"formula"_s ) )
996 components.
formula = query.queryItemValue( u
"formula"_s );
998 const QList<std::pair<QString, QString> > &queryItems { query.queryItems() };
999 for (
const auto &item : std::as_const( queryItems ) )
1001 if ( !( item.first.mid( item.first.indexOf(
':' ), -1 ) ==
":uri"_L1 ) )
1007 rLayer.
name = item.first.mid( 0, item.first.indexOf(
':' ) );
1008 rLayer.
uri = query.queryItemValue( item.first );
1009 rLayer.
provider = query.queryItemValue( item.first.mid( 0, item.first.indexOf(
':' ) ) + u
":provider"_s );
1011 if ( rLayer.
uri.isNull() || rLayer.
provider.isNull() )
1013 QgsDebugError(
"One or more raster information are missing" );
1034 query.addQueryItem( u
"crs"_s, parts.
crs.
authid() );
1040 = QString(
"%1,%2,%3,%4" )
1043 query.addQueryItem( u
"extent"_s, rect );
1046 query.addQueryItem( u
"width"_s, QString::number( parts.
width ) );
1048 query.addQueryItem( u
"height"_s, QString::number( parts.
height ) );
1050 query.addQueryItem( u
"formula"_s, parts.
formula );
1056 query.addQueryItem( it.name + u
":uri"_s, it.uri );
1057 query.addQueryItem( it.name + u
":provider"_s, it.provider );
1060 uri.setQuery( query );
1061 return QString( QUrl::toPercentEncoding(
uri.toEncoded() ) );
Provides global constants and enumerations for use throughout the application.
QFlags< RasterProviderCapability > RasterProviderCapabilities
Raster data provider capabilities.
@ NoProviderCapabilities
Provider has no capabilities.
RasterResamplingMethod
Resampling method for raster provider-level resampling.
@ Lanczos
Lanczos windowed sinc interpolation (6x6 kernel).
@ Nearest
Nearest-neighbour resampling.
@ Mode
Mode (selects the value which appears most often of all the sampled points).
@ Bilinear
Bilinear (2x2 kernel) resampling.
@ Average
Average resampling.
@ CubicSpline
Cubic B-Spline Approximation (4x4 kernel).
@ Cubic
Cubic Convolution Approximation (4x4 kernel) resampling.
RasterInterfaceCapability
Raster interface capabilities.
@ NoCapabilities
No capabilities.
@ Size
Original data source size (and thus resolution) is known, it is not always available,...
@ IdentifyValue
Numerical values.
@ IdentifyFeature
WMS GML -> feature.
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
DataType
Raster data types.
RasterColorInterpretation
Raster color interpretation.
@ NIRBand
Near-InfraRed (NIR) band [0.75 - 1.40 um].
@ GreenBand
Green band of RGBA image, or green spectral band [0.51 - 0.60 um].
@ SAR_K_Band
Synthetic Aperture Radar (SAR) K band [1.1 - 1.7 cm / 18 - 27 GHz].
@ SAR_L_Band
Synthetic Aperture Radar (SAR) L band [15 - 30 cm / 1 - 2 GHz].
@ SaturationBand
Saturation band of HLS image.
@ MagentaBand
Magenta band of CMYK image.
@ BlackBand
Black band of CMLY image.
@ AlphaBand
Alpha (0=transparent, 255=opaque).
@ SWIRBand
Short-Wavelength InfraRed (SWIR) band [1.40 - 3.00 um].
@ SAR_X_Band
Synthetic Aperture Radar (SAR) X band [2.4 - 3.8 cm / 8 - 12 GHz].
@ BlueBand
Blue band of RGBA image, or blue spectral band [0.45 - 0.53 um].
@ LWIRBand
Long-Wavelength InfraRed (LWIR) band [8.00 - 15 um].
@ RedEdgeBand
Red-edge band [0.69 - 0.79 um].
@ SAR_Ku_Band
Synthetic Aperture Radar (SAR) Ku band [1.7 - 2.4 cm / 12 - 18 GHz].
@ YellowBand
Yellow band of CMYK image, or yellow spectral band [0.58 - 0.62 um].
@ CyanBand
Cyan band of CMYK image.
@ SAR_C_Band
Synthetic Aperture Radar (SAR) C band [3.8 - 7.5 cm / 4 - 8 GHz].
@ LightnessBand
Lightness band of HLS image.
@ CoastalBand
Coastal band [0.40 - 0.45 um].
@ YCbCr_YBand
Y Luminance.
@ HueBand
Hue band of HLS image.
@ MWIRBand
Mid-Wavelength InfraRed (MWIR) band [3.00 - 8.00 um].
@ PaletteIndex
Paletted (see associated color table).
@ TIRBand
Thermal InfraRed (TIR) band (MWIR or LWIR) [3 - 15 um].
@ SAR_Ka_Band
Synthetic Aperture Radar (SAR) Ka band [0.8 - 1.1 cm / 27 - 40 GHz].
@ SAR_S_Band
Synthetic Aperture Radar (SAR) S band [7.5 - 15 cm / 2 - 4 GHz].
@ SAR_P_Band
Synthetic Aperture Radar (SAR) P band [30 - 100 cm / 0.3 - 1 GHz].
@ RedBand
Red band of RGBA image, or red spectral band [0.62 - 0.69 um].
@ PanBand
Panchromatic band [0.40 - 1.00 um].
@ ContinuousPalette
Continuous palette, QGIS addition, GRASS.
@ OtherIRBand
Other infrared band [0.75 - 1000 um].
RasterIdentifyFormat
Raster identify formats.
@ Feature
WMS GML/JSON -> feature.
@ Value
Numerical pixel value.
Represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
bool createFromString(const QString &definition)
Set up this CRS from a string definition.
void setError(const QgsError &error)
Sets error message.
virtual Qgis::DataProviderFlags flags() const
Returns the generic data provider flags.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
QgsDataProvider(const QString &uri=QString(), const QgsDataProvider::ProviderOptions &providerOptions=QgsDataProvider::ProviderOptions(), Qgis::DataProviderReadFlags flags=Qgis::DataProviderReadFlags())
Create a new dataprovider with the specified in the uri.
QgsDataSourceUri uri() const
Gets the data source specification.
A container for error messages.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Point geometry type, with support for z-dimension and m-values.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QgsRasterDataProvider * createRasterDataProvider(const QString &providerKey, const QString &uri, const QString &format, int nBands, Qgis::DataType type, int width, int height, double *geoTransform, const QgsCoordinateReferenceSystem &crs, const QStringList &createOptions=QStringList())
Creates new instance of raster data provider.
QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns list of raster pyramid resampling methods.
Represents a Raster Attribute Table (RAT).
bool writeToFile(const QString &path, QString *errorMessage=nullptr)
Writes the Raster Attribute Table to a DBF file specified by path, optionally reporting any error in ...
The RasterBandStats struct is a container for statistics about a single raster band.
Feedback object tailored for raster block reading.
static QRect subRect(const QgsRectangle &extent, int width, int height, const QgsRectangle &subExtent)
For extent and width, height find rectangle covered by subextent.
Handles elevation related properties for a raster data provider.
Implementation of data provider temporal properties for QgsRasterDataProviders.
double mMaxOversampling
Maximum boundary for oversampling (to avoid too much data traffic). Default: 2.0.
virtual bool write(const void *data, int band, int width, int height, int xOffset, int yOffset)
Writes into the provider datasource.
QList< bool > mUseSrcNoDataValue
Use source nodata value.
TransformType
Types of transformation in transformCoordinates() function.
bool writeFileBasedAttributeTable(int bandNumber, const QString &path, QString *errorMessage=nullptr) const
Writes the filesystem-based attribute table for the specified bandNumber to path, optionally reportin...
static Qgis::RasterInterfaceCapability identifyFormatToCapability(Qgis::RasterIdentifyFormat format)
Converts a raster identify format to a capability.
virtual bool sourceHasNoDataValue(int bandNo) const
Returns true if source band has no data value.
static QString encodeVirtualRasterProviderUri(const VirtualRasterParameters &parts)
Encodes the URI starting from the struct .
virtual double bandOffset(int bandNo) const
Read band offset for raster value.
virtual QString lastErrorFormat()
Returns the format of the error text for the last error in this provider.
bool mProviderResamplingEnabled
Whether provider resampling is enabled.
virtual bool writeNativeAttributeTable(QString *errorMessage=nullptr)
Writes the native attribute table, optionally reporting any error in errorMessage,...
virtual bool useSourceNoDataValue(int bandNo) const
Returns the source nodata value usage.
bool readFileBasedAttributeTable(int bandNumber, const QString &path, QString *errorMessage=nullptr)
Loads the filesystem-based attribute table for the specified bandNumber from path,...
static QgsRasterDataProvider::VirtualRasterParameters decodeVirtualRasterProviderUri(const QString &uri, bool *ok=nullptr)
Decodes the URI returning a struct with all the parameters for QgsVirtualRasterProvider class.
virtual void setUseSourceNoDataValue(int bandNo, bool use)
Sets the source nodata value usage.
QgsRasterAttributeTable * attributeTable(int bandNumber) const
Returns the (possibly nullptr) attribute table for the specified bandNumber.
virtual bool setZoomedInResamplingMethod(Qgis::RasterResamplingMethod method)
Set resampling method to apply for zoomed-in operations.
void setAttributeTable(int bandNumber, QgsRasterAttributeTable *attributeTable)
Set the attribute table to attributeTable for the specified bandNumber, if the attributeTable is null...
virtual double sourceNoDataValue(int bandNo) const
Value representing no data value.
void readXml(const QDomElement &filterElem) override
Sets base class members from xml. Usually called from create() methods of subclasses.
QList< QgsRasterRangeList > mUserNoDataValue
List of lists of user defined additional no data values for each band, indexed from 0.
virtual bool isEditable() const
Checks whether the provider is in editing mode, i.e.
QString colorName(Qgis::RasterColorInterpretation colorInterpretation) const
Returns a string color name representation of a color interpretation.
virtual bool readNativeAttributeTable(QString *errorMessage=nullptr)
Reads the native attribute table, optionally reporting any error in errorMessage, returns true on suc...
void copyBaseSettings(const QgsRasterDataProvider &other)
Copy member variables from other raster data provider. Useful for implementation of clone() method in...
bool userNoDataValuesContains(int bandNo, double value) const
Returns true if user no data contains value.
virtual bool setZoomedOutResamplingMethod(Qgis::RasterResamplingMethod method)
Set resampling method to apply for zoomed-out operations.
Qgis::RasterResamplingMethod mZoomedInResamplingMethod
Resampling method for zoomed in pixel extraction.
bool writeBlock(QgsRasterBlock *block, int band, int xOffset=0, int yOffset=0)
Writes pixel data from a raster block into the provider data source.
virtual bool enableProviderResampling(bool enable)
Enable or disable provider-level resampling.
virtual bool closeWithProgress(QgsFeedback *feedback)
Close the provider with feedback.
virtual bool hasReportsDuringClose() const
Returns whether closeWithProgress() will actually report closing progress.
QgsRectangle extent() const override=0
Returns the extent of the layer.
virtual bool ignoreExtents() const
Returns true if the extents reported by the data provider are not reliable and it's possible that the...
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.
QgsRasterDataProviderElevationProperties * elevationProperties() override
Returns the provider's elevation properties.
bool hasPyramids()
Returns true if raster has at least one existing pyramid.
virtual QgsRasterIdentifyResult identify(const QgsPointXY &point, Qgis::RasterIdentifyFormat format, const QgsRectangle &boundingBox=QgsRectangle(), int width=0, int height=0, int dpi=96)
Identify raster value(s) found on the point position.
virtual double bandScale(int bandNo) const
Read band scale for raster value.
int dpi() const
Returns the dpi of the output device.
virtual Qgis::RasterColorInterpretation colorInterpretation(int bandNo) const
Returns data type for the band specified by number.
virtual double sample(const QgsPointXY &point, int band, bool *ok=nullptr, const QgsRectangle &boundingBox=QgsRectangle(), int width=0, int height=0, int dpi=96)
Samples a raster value from the specified band found at the point position.
QgsRasterBlock * block(int bandNo, const QgsRectangle &boundingBox, int width, int height, QgsRasterBlockFeedback *feedback=nullptr) override
Read block of data using given extent and size.
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.
virtual Qgis::RasterProviderCapabilities providerCapabilities() const
Returns flags containing the supported capabilities of the data provider.
QList< bool > mSrcHasNoDataValue
Source no data value exists.
void removeAttributeTable(int bandNumber)
Remove the attribute table for the specified bandNumber.
Qgis::RasterResamplingMethod mZoomedOutResamplingMethod
Resampling method for zoomed out pixel extraction.
static QgsRasterDataProvider * create(const QString &providerKey, const QString &uri, const QString &format, int nBands, Qgis::DataType type, int width, int height, double *geoTransform, const QgsCoordinateReferenceSystem &crs, const QStringList &createOptions=QStringList())
Creates a new dataset with mDataSourceURI.
virtual QgsRasterRangeList userNoDataValues(int bandNo) const
Returns a list of user no data value ranges.
static QList< QPair< QString, QString > > pyramidResamplingMethods(const QString &providerKey)
Returns a list of pyramid resampling method name and label pairs for given provider.
void writeXml(QDomDocument &doc, QDomElement &parentElem) const override
Write base class members to xml.
virtual QList< double > nativeResolutions() const
Returns a list of native resolutions if available, i.e.
virtual QgsPoint transformCoordinates(const QgsPoint &point, TransformType type)
Transforms coordinates between source image coordinate space [0..width]x[0..height] and layer coordin...
static QString identifyFormatName(Qgis::RasterIdentifyFormat format)
Converts a raster identify format to a string name.
QgsRasterDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
QString colorInterpretationName(int bandNo) const override
Returns the name of the color interpretation for the specified bandNumber.
virtual QString bandDescription(int bandNumber)
Returns the description for band bandNumber, or an empty string if the band is not valid or has not d...
static Qgis::RasterIdentifyFormat identifyFormatFromName(const QString &formatName)
Converts a string formatName to a raster identify format.
static QString identifyFormatLabel(Qgis::RasterIdentifyFormat format)
Converts a raster identify format to a translated string label.
virtual void setUserNoDataValue(int bandNo, const QgsRasterRangeList &noData)
virtual QList< QgsRasterPyramid > buildPyramidList(const QList< int > &overviewList=QList< int >())
Returns the raster layers pyramid list.
A container for a histogram of a single raster band.
Raster identify results container.
virtual Qgis::RasterInterfaceCapabilities capabilities() const
Returns the capabilities supported by the interface.
QList< QgsRasterBandStats > mStatistics
List of cached statistics, all bands mixed.
virtual int xSize() const
Gets raster size.
QgsRasterInterface(QgsRasterInterface *input=nullptr)
virtual int bandCount() const =0
Gets number of bands.
int dataTypeSize(int bandNo) const
Returns the size (in bytes) for the data type for the specified band.
virtual int ySize() const
QList< QgsRasterHistogram > mHistograms
List of cached histograms, all bands mixed.
virtual QgsRasterHistogram histogram(int bandNo, int binCount=0, double minimum=std::numeric_limits< double >::quiet_NaN(), double maximum=std::numeric_limits< double >::quiet_NaN(), const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, bool includeOutOfRange=false, QgsRasterBlockFeedback *feedback=nullptr)
Returns a band histogram.
This struct is used to store pyramid info for the raster layer.
bool contains(double value) const
Returns true if this range contains the specified value.
A rectangle specified with double values.
Q_INVOKABLE QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be rounded to the spec...
void setYMinimum(double y)
Set the minimum y value.
void setXMinimum(double x)
Set the minimum x value.
void setYMaximum(double y)
Set the maximum y value.
void setXMaximum(double x)
Set the maximum x value.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
unsigned long long qgssize
Qgssize is used instead of size_t, because size_t is stdlib type, unknown by SIP, and it would be har...
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
QList< QgsRasterRange > QgsRasterRangeList
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS
Setting options for creating vector data providers.
Struct that stores the information about the parameters that should be given to the QgsVirtualRasterP...
QList< QgsRasterDataProvider::VirtualRasterInputLayers > rInputLayers
QgsCoordinateReferenceSystem crs