50 #include <QApplication> 52 #include <QDomElement> 57 #include <QFontMetrics> 64 #include <QMessageBox> 75 #define ERR(message) QGS_ERROR_MESSAGE(message,"Raster layer") 83 , QSTRING_NOT_SET(
"Not Set" )
84 , TRSTRING_NOT_SET( tr(
"Not Set" ) )
85 , mDataProvider( nullptr )
94 bool loadDefaultStyleFlag )
96 , QSTRING_NOT_SET(
"Not Set" )
97 , TRSTRING_NOT_SET(
tr(
"Not Set" ) )
98 , mDataProvider( nullptr )
107 bool defaultLoadedFlag =
false;
108 if (
mValid && loadDefaultStyleFlag )
112 if ( !defaultLoadedFlag )
126 bool loadDefaultStyleFlag )
129 , QSTRING_NOT_SET(
"Not Set" )
130 , TRSTRING_NOT_SET(
tr(
"Not Set" ) )
131 , mDataProvider( nullptr )
132 , mProviderKey( providerKey )
140 bool defaultLoadedFlag =
false;
141 if (
mValid && loadDefaultStyleFlag )
145 if ( !defaultLoadedFlag )
175 QgsDebugMsg(
"Could not resolve isValidRasterFileName in gdal provider library" );
179 bool myIsValid = pValid( theFileNameQString, retErrMsg );
218 if ( !mDataProvider )
return 0;
237 return mDataProvider;
245 return mDataProvider;
303 drawer.draw( theQPainter, theRasterViewPort, theQgsMapToPixel );
322 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Driver" ) +
"</p>\n";
325 myMetadata +=
"</p>\n";
329 myMetadata += mDataProvider->
metadata();
331 myMetadata +=
"<p class=\"glossy\">";
332 myMetadata +=
tr(
"No Data Value" );
333 myMetadata +=
"</p>\n";
342 myMetadata +=
'*' +
tr(
"NoDataValue not set" ) +
'*';
344 myMetadata +=
"</p>\n";
346 myMetadata +=
"</p>\n";
347 myMetadata +=
"<p class=\"glossy\">";
348 myMetadata +=
tr(
"Data Type" );
349 myMetadata +=
"</p>\n";
355 myMetadata +=
tr(
"Byte - Eight bit unsigned integer" );
358 myMetadata +=
tr(
"UInt16 - Sixteen bit unsigned integer " );
361 myMetadata +=
tr(
"Int16 - Sixteen bit signed integer " );
364 myMetadata +=
tr(
"UInt32 - Thirty two bit unsigned integer " );
367 myMetadata +=
tr(
"Int32 - Thirty two bit signed integer " );
370 myMetadata +=
tr(
"Float32 - Thirty two bit floating point " );
373 myMetadata +=
tr(
"Float64 - Sixty four bit floating point " );
376 myMetadata +=
tr(
"CInt16 - Complex Int16 " );
379 myMetadata +=
tr(
"CInt32 - Complex Int32 " );
382 myMetadata +=
tr(
"CFloat32 - Complex Float32 " );
385 myMetadata +=
tr(
"CFloat64 - Complex Float64 " );
388 myMetadata +=
tr(
"Could not determine raster data type." );
390 myMetadata +=
"</p>\n";
392 myMetadata +=
"<p class=\"glossy\">";
393 myMetadata +=
tr(
"Pyramid overviews" );
394 myMetadata +=
"</p>\n";
397 myMetadata +=
"<p class=\"glossy\">";
398 myMetadata +=
tr(
"Layer Spatial Reference System" );
399 myMetadata +=
"</p>\n";
402 myMetadata +=
"</p>\n";
404 myMetadata +=
"<p class=\"glossy\">";
405 myMetadata +=
tr(
"Layer Extent (layer original source projection)" );
406 myMetadata +=
"</p>\n";
409 myMetadata +=
"</p>\n";
414 myMetadata +=
"<tr><td class=\"glossy\">";
415 myMetadata +=
tr(
"Project Spatial Reference System" );
416 myMetadata +=
"</p>\n";
418 myMetadata += mCoordinateTransform->destCRS().toProj4();
419 myMetadata +=
"</p>\n";
426 for (
int myIteratorInt = 1; myIteratorInt <= myBandCountInt; ++myIteratorInt )
430 myMetadata +=
"<p class=\"glossy\">\n";
431 myMetadata +=
tr(
"Band" );
432 myMetadata +=
"</p>\n";
434 myMetadata +=
bandName( myIteratorInt );
435 myMetadata +=
"</p>\n";
438 myMetadata +=
tr(
"Band No" );
439 myMetadata +=
"</p>\n";
440 myMetadata +=
"<p>\n";
442 myMetadata +=
"</p>\n";
450 myMetadata +=
tr(
"No Stats" );
451 myMetadata +=
"</p>\n";
452 myMetadata +=
"<p>\n";
453 myMetadata +=
tr(
"No stats collected yet" );
454 myMetadata +=
"</p>\n";
463 myMetadata +=
tr(
"Min Val" );
464 myMetadata +=
"</p>\n";
465 myMetadata +=
"<p>\n";
467 myMetadata +=
"</p>\n";
471 myMetadata +=
tr(
"Max Val" );
472 myMetadata +=
"</p>\n";
473 myMetadata +=
"<p>\n";
475 myMetadata +=
"</p>\n";
479 myMetadata +=
tr(
"Range" );
480 myMetadata +=
"</p>\n";
481 myMetadata +=
"<p>\n";
483 myMetadata +=
"</p>\n";
487 myMetadata +=
tr(
"Mean" );
488 myMetadata +=
"</p>\n";
489 myMetadata +=
"<p>\n";
491 myMetadata +=
"</p>\n";
495 myMetadata +=
tr(
"Sum of squares" );
496 myMetadata +=
"</p>\n";
497 myMetadata +=
"<p>\n";
499 myMetadata +=
"</p>\n";
503 myMetadata +=
tr(
"Standard Deviation" );
504 myMetadata +=
"</p>\n";
505 myMetadata +=
"<p>\n";
507 myMetadata +=
"</p>\n";
511 myMetadata +=
tr(
"Sum of all cells" );
512 myMetadata +=
"</p>\n";
513 myMetadata +=
"<p>\n";
515 myMetadata +=
"</p>\n";
519 myMetadata +=
tr(
"Cell Count" );
520 myMetadata +=
"</p>\n";
521 myMetadata +=
"<p>\n";
523 myMetadata +=
"</p>\n";
547 if ( !myColorRampItemList.
isEmpty() )
554 QPixmap myPalettePixmap( mySize, mySize );
555 QPainter myQPainter( &myPalettePixmap );
557 QImage myQImage =
QImage( mySize, mySize, QImage::Format_RGB32 );
559 myPalettePixmap.
fill();
561 double myStep = (
static_cast< double >( myColorRampItemList.
size() ) - 1 ) /
static_cast< double >( mySize * mySize );
562 double myValue = 0.0;
563 for (
int myRow = 0; myRow < mySize; myRow++ )
565 QRgb* myLineBuffer =
reinterpret_cast< QRgb*
>( myQImage.
scanLine( myRow ) );
566 for (
int myCol = 0; myCol < mySize; myCol++ )
568 myValue = myStep *
static_cast< double >( myCol + myRow * mySize );
570 myShader.
shade( myValue, &c1, &c2, &c3, &c4 );
571 myLineBuffer[ myCol ] = qRgba( c1, c2, c3, c4 );
576 return myPalettePixmap;
621 void QgsRasterLayer::init()
639 mPipe.
remove( mDataProvider );
640 mDataProvider =
nullptr;
645 mProviderKey = provider;
655 if ( !mDataProvider )
658 appendError(
ERR(
tr(
"Cannot instantiate the '%1' data provider" ).arg( mProviderKey ) ) );
664 mPipe.
set( mDataProvider );
665 if ( !mDataProvider->
isValid() )
672 if ( provider ==
"gdal" )
775 for (
int bandNo = 1; bandNo <= mDataProvider->
bandCount(); bandNo++ )
789 mPipe.
set( brightnessFilter );
793 mPipe.
set( hueSaturationFilter );
797 mPipe.
set( resampleFilter );
801 mPipe.
set( projector );
831 mDataProvider, SIGNAL( progress(
int,
double,
QString ) ),
847 void QgsRasterLayer::closeDataProvider()
850 mPipe.
remove( mDataProvider );
851 mDataProvider =
nullptr;
856 QgsDebugMsgLevel(
QString(
"theAlgorithm = %1 theLimits = %2 theExtent.isEmpty() = %3" ).arg( theAlgorithm ).arg( theLimits ).arg( theExtent.
isEmpty() ), 4 );
857 if ( !mPipe.
renderer() || !mDataProvider )
867 if ( rendererType ==
"singlebandgray" )
870 if ( !myGrayRenderer )
return;
871 myBands << myGrayRenderer->
grayBand();
873 else if ( rendererType ==
"multibandcolor" )
876 if ( !myMultiBandRenderer )
return;
880 Q_FOREACH (
int myBand, myBands )
888 double myMin = std::numeric_limits<double>::quiet_NaN();
889 double myMax = std::numeric_limits<double>::quiet_NaN();
901 myMin = myRasterBandStats.
mean - ( myStdDev * myRasterBandStats.
stdDev );
902 myMax = myRasterBandStats.
mean + ( myStdDev * myRasterBandStats.
stdDev );
910 mDataProvider->
cumulativeCut( myBand, myLower, myUpper, myMin, myMax, theExtent, theSampleSize );
916 myEnhancements.
append( myEnhancement );
920 myEnhancements.
append(
nullptr );
924 if ( rendererType ==
"singlebandgray" )
928 else if ( rendererType ==
"multibandcolor" )
936 qDeleteAll( myEnhancements );
952 if ( dynamic_cast<QgsSingleBandGrayRenderer*>(
renderer() ) )
954 myKey =
"singleBand";
955 myDefault =
"StretchToMinimumMaximum";
957 else if ( dynamic_cast<QgsMultiBandColorRenderer*>(
renderer() ) )
961 myKey =
"multiBandSingleByte";
962 myDefault =
"NoEnhancement";
966 myKey =
"multiBandMultiByte";
967 myDefault =
"StretchToMinimumMaximum";
973 QgsDebugMsg(
"No default contrast enhancement for this drawing style" );
977 QString myAlgorithmString = mySettings.
value(
"/Raster/defaultContrastEnhancementAlgorithm/" + myKey, myDefault ).
toString();
987 QString myLimitsString = mySettings.
value(
"/Raster/defaultContrastEnhancementLimits",
"CumulativeCut" ).
toString();
1002 if ( theDrawingStyleQString ==
"SingleBandGray" )
1006 else if ( theDrawingStyleQString ==
"SingleBandPseudoColor" )
1010 else if ( theDrawingStyleQString ==
"PalettedColor" )
1014 else if ( theDrawingStyleQString ==
"PalettedSingleBandGray" )
1018 else if ( theDrawingStyleQString ==
"PalettedSingleBandPseudoColor" )
1022 else if ( theDrawingStyleQString ==
"PalettedMultiBandColor" )
1026 else if ( theDrawingStyleQString ==
"MultiBandSingleBandGray" )
1030 else if ( theDrawingStyleQString ==
"MultiBandSingleBandPseudoColor" )
1034 else if ( theDrawingStyleQString ==
"MultiBandColor" )
1038 else if ( theDrawingStyleQString ==
"SingleBandColorDataStyle" )
1048 setRendererForDrawingStyle( drawingStyle );
1055 if ( mDataProvider )
1066 if ( mDataProvider )
1068 QgsDebugMsgLevel(
"About to mDataProvider->setSubLayerVisibility(name, vis).", 4 );
1077 if ( !theRenderer ) {
return; }
1078 mPipe.
set( theRenderer );
1107 myQPixmap.
fill( bgColor );
1111 double myMapUnitsPerPixel;
1115 if ( myExtent.
width() / myExtent.
height() >=
static_cast< double >( myQPixmap.
width() ) / myQPixmap.
height() )
1117 myMapUnitsPerPixel = myExtent.
width() / myQPixmap.
width();
1118 myY = ( myQPixmap.
height() - myExtent.
height() / myMapUnitsPerPixel ) / 2;
1122 myMapUnitsPerPixel = myExtent.
height() / myQPixmap.
height();
1123 myX = ( myQPixmap.
width() - myExtent.
width() / myMapUnitsPerPixel ) / 2;
1126 double myPixelWidth = myExtent.
width() / myMapUnitsPerPixel;
1127 double myPixelHeight = myExtent.
height() / myMapUnitsPerPixel;
1143 draw( myQPainter, myRasterViewPort, myMapToPixel );
1144 delete myRasterViewPort;
1145 delete myMapToPixel;
1156 QImage myQImage( size, format );
1163 double myMapUnitsPerPixel;
1167 if ( myExtent.
width() / myExtent.
height() >=
static_cast< double >( myQImage.
width() ) / myQImage.
height() )
1169 myMapUnitsPerPixel = myExtent.
width() / myQImage.
width();
1170 myY = ( myQImage.
height() - myExtent.
height() / myMapUnitsPerPixel ) / 2;
1174 myMapUnitsPerPixel = myExtent.
height() / myQImage.
height();
1175 myX = ( myQImage.
width() - myExtent.
width() / myMapUnitsPerPixel ) / 2;
1178 double myPixelWidth = myExtent.
width() / myMapUnitsPerPixel;
1179 double myPixelHeight = myExtent.
height() / myMapUnitsPerPixel;
1195 draw( myQPainter, myRasterViewPort, myMapToPixel );
1196 delete myRasterViewPort;
1197 delete myMapToPixel;
1206 Q_UNUSED( theProgress );
1212 Q_UNUSED( theType );
1213 Q_UNUSED( theMessage );
1230 Q_UNUSED( errorMessage );
1240 pipeNode = layer_node;
1260 if ( !rasterRendererElem.
isNull() )
1267 mPipe.
set( renderer );
1273 mPipe.
set( brightnessFilter );
1277 if ( !brightnessElem.
isNull() )
1279 brightnessFilter->
readXML( brightnessElem );
1284 mPipe.
set( hueSaturationFilter );
1288 if ( !hueSaturationElem.
isNull() )
1290 hueSaturationFilter->
readXML( hueSaturationElem );
1295 mPipe.
set( resampleFilter );
1299 if ( !resampleElem.
isNull() )
1301 resampleFilter->
readXML( resampleElem );
1306 if ( !blendModeNode.
isNull() )
1338 mProviderKey =
"gdal";
1343 mProviderKey = pkeyElt.
text();
1346 mProviderKey =
"gdal";
1358 if ( mProviderKey ==
"wms" )
1368 while ( !layerElement.
isNull() )
1394 if ( !
mValid )
return false;
1400 if ( res && mProviderKey ==
"wms" && ( !
renderer() ||
renderer()->
type() !=
"singlebandcolordata" ) )
1412 if ( !stampNode.
isNull() )
1416 if ( stamp < mDataProvider->dataTimestamp() )
1419 closeDataProvider();
1422 if ( !
mValid )
return false;
1432 for (
int i = 0; i < noDataBandList.
size(); ++i )
1438 if ( ok && ( bandNo > 0 ) && ( bandNo <= mDataProvider->
bandCount() ) )
1446 for (
int j = 0; j < rangeList.
size(); ++j )
1452 myNoDataRangeList << myNoDataRange;
1471 Q_UNUSED( errorMessage );
1478 for (
int i = 1; i < mPipe.
size(); i++ )
1481 if ( !interface )
continue;
1482 interface->writeXML( document, pipeElement );
1513 if ( mapLayerNode.
isNull() ||
"maplayer" != mapLayerNode.
nodeName() )
1531 for (
int bandNo = 1; bandNo <= mDataProvider->
bandCount(); bandNo++ )
1563 if ( !mDataProvider )
return 0;
1564 return mDataProvider->
xSize();
1569 if ( !mDataProvider )
return 0;
1570 return mDataProvider->
ySize();
1578 bool QgsRasterLayer::update()
1585 closeDataProvider();
bool writeStyle(QDomNode &node, QDomDocument &doc, QString &errorMessage) const override
Write the style for the layer into the docment provided.
bool draw(QgsRenderContext &rendererContext) override
This is called when the view on the raster layer needs to be redrawn.
QgsDataProvider * classFactoryFunction_t(const QString *)
bool readSymbology(const QDomNode &node, QString &errorMessage) override
Read the symbology for the current layer from the Dom node supplied.
int width() const
Accessor that returns the width of the (unclipped) raster.
virtual int bandCount() const =0
Get number of bands.
virtual void setSubLayerVisibility(const QString &name, bool vis)
Set the visibility of the given sublayer name.
Eight bit unsigned integer (quint8)
void onProgress(int, double, const QString &)
receive progress signal from provider
void setRenderer(QgsRasterRenderer *theRenderer)
Set raster renderer.
QDomNodeList elementsByTagName(const QString &tagname) const
QString toString(Qt::DateFormat format) const
void setContrastEnhancementAlgorithm(ContrastEnhancementAlgorithm, bool generateTable=true)
Set the contrast enhancement algorithm.
static QgsProviderRegistry * instance(const QString &pluginPath=QString::null)
Means of accessing canonical single instance.
A rectangle specified with double values.
Base class for all map layer types.
Interface for all raster shaders.
virtual QDateTime timestamp() const override
Time stamp of data source in the moment when data/metadata were loaded by provider.
virtual QStringList subLayers() const override
Returns the sublayers of this layer - Useful for providers that manage their own layers, such as WMS.
double rasterUnitsPerPixelY()
static QString printValue(double value)
Print double value with all necessary significant digits.
double sum
The sum of all cells in the band.
void setCRS(const QgsCoordinateReferenceSystem &theSrcCRS, const QgsCoordinateReferenceSystem &theDestCRS, int srcDatumTransform=-1, int destDatumTransform=-1)
set source and destination CRS
Iterator for sequentially processing raster cells.
void readCustomProperties(const QDomNode &layerNode, const QString &keyStartsWith="")
Read custom properties from project file.
int bandCount() const
Get the number of bands in this layer.
QDomNode appendChild(const QDomNode &newChild)
void fill(const QColor &color)
QgsHueSaturationFilter * hueSaturationFilter() const
DrawingStyle
This enumerator describes the different kinds of drawing we can do.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
virtual QList< QgsColorRampShader::ColorRampItem > colorTable(int bandNo) const
virtual QgsError error() const
Get current status error.
QString attribute(const QString &name, const QString &defValue) const
QgsRasterRenderer * renderer() const
void setEncodedUri(const QByteArray &uri)
set complete encoded uri (generic mode)
virtual QgsCoordinateReferenceSystem crs()=0
Get the QgsCoordinateReferenceSystem for this layer.
virtual QString generateBandName(int theBandNumber) const
helper function to create zero padded band names
QString toString(int indent) const
virtual void setLayerOrder(const QStringList &layers) override
Reorders the previously selected sublayers of this layer from bottom to top.
void setContrastEnhancement(QgsContrastEnhancement::ContrastEnhancementAlgorithm theAlgorithm, QgsRaster::ContrastEnhancementLimits theLimits=QgsRaster::ContrastEnhancementMinMax, const QgsRectangle &theExtent=QgsRectangle(), int theSampleSize=SAMPLE_SIZE, bool theGenerateLookupTableFlag=true)
Set contrast enhancement algorithm.
bool readStyle(const QDomNode &node, QString &errorMessage) override
Read the style information for the current layer from the Dom node supplied.
void setDefaultContrastEnhancement()
Set default contrast enhancement.
virtual void setUseSrcNoDataValue(int bandNo, bool use)
Set source nodata value usage.
QgsRasterProjector * projector() const
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
virtual QString type() const
static QgsMapRenderer::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
QgsRasterInterface * last() const
QString toProj4() const
Returns a Proj4 string representation of this CRS.
double maximumValue
The maximum cell value in the raster band.
virtual int ySize() const
int mWidth
Width, number of columns to be rendered.
QDomElement nextSiblingElement(const QString &tagName) const
Thirty two bit floating point (float)
static QDateTime lastModified(const QString &name)
Return time stamp for given file name.
Raster values range container.
static bool isValidRasterFileName(const QString &theFileNameQString, QString &retError)
This helper checks to see whether the file name appears to be a valid raster file name...
Resample filter pipe for rasters.
Abstract base class for spatial data provider implementations.
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &theList)
Set custom colormap.
void readXML(const QDomElement &filterElem) override
Sets base class members from xml.
QgsRasterRenderer * renderer() const
int height() const
Accessor that returns the height of the (unclipped) raster.
static const double SAMPLE_SIZE
Default sample size (number of pixels) for estimated statistics/histogram calculation.
Q_DECL_DEPRECATED void updateProgress(int, int)
bool readXml(const QDomNode &layer_node) override
Reads layer specific state from project file Dom node.
Implementation of threaded rendering for raster layers.
double toDouble(bool *ok) const
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
QgsMapLayer::LayerType type() const
Get the type of the layer.
QString tr(const char *sourceText, const char *disambiguation, int n)
QString mLayerName
Name of the layer - used for display.
virtual bool render() override
Do the rendering (based on data stored in the class)
void setShader(QgsRasterShader *shader)
Takes ownership of the shader.
void setColor(int index, QRgb colorValue)
void styleChanged()
Signal emitted whenever a change affects the layer's style.
double rasterUnitsPerPixelX()
Returns the number of raster units per each raster pixel.
void setGreenContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
static QString identifyFormatName(QgsRaster::IdentifyFormat format)
QgsCoordinateReferenceSystem mDestCRS
Target coordinate system.
Q_DECL_DEPRECATED void setDrawingStyle(const QString &theDrawingStyleQString)
Overloaded version of the above function for convenience when restoring from xml. ...
QgsBrightnessContrastFilter * brightnessFilter() const
QDomElement toElement() const
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
Perform transforms between map coordinates and device coordinates.
bool writeSymbology(QDomNode &, QDomDocument &doc, QString &errorMessage) const override
Write the symbology for the layer into the docment provided.
virtual QgsRasterBandStats bandStatistics(int theBandNo, int theStats=QgsRasterBandStats::All, const QgsRectangle &theExtent=QgsRectangle(), int theSampleSize=0)
Get band statistics.
The drawing pipe for raster layers.
double stdDev
The standard deviation of the cell values.
Paletted (see associated color table)
Alpha (0=transparent, 255=opaque)
QString number(int n, int base)
The RasterBandStats struct is a container for statistics about a single raster band.
static QgsRasterRendererRegistry * instance()
static ContrastEnhancementLimits contrastEnhancementLimitsFromString(const QString &theLimits)
void setError(const QgsError &theError)
Set error message.
double mean
The mean cell value for the band.
void append(const T &value)
Sixteen bit unsigned integer (quint16)
Continuous palette, QGIS addition, GRASS.
Sixty four bit floating point (double)
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
void readStyleManager(const QDomNode &layerNode)
Read style manager's configuration (if any).
QDomDocument ownerDocument() const
void setRedContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
void fill(uint pixelValue)
QgsDataProvider * provider(const QString &providerKey, const QString &dataSource)
Create an instance of the provider.
#define QgsDebugMsgLevel(str, level)
virtual QGis::DataType srcDataType(int bandNo) const override=0
Returns source data type for the band specified by number, source data type may be shorter than dataT...
bool isEmpty() const
test if rectangle is empty.
Thirty two bit signed integer (qint32)
void setParam(const QString &key, const QString &value)
Set generic param (generic mode)
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
virtual int capabilities() const
Returns a bitmask containing the supported capabilities.
virtual QStringList subLayers() const override
Returns the sublayers of this layer - useful for providers that manage their own layers, such as WMS.
void setAttribute(const QString &name, const QString &value)
QString providerType() const
[ data provider interface ] Which provider is being used for this Raster Layer?
double width() const
Width of the rectangle.
int toInt(bool *ok, int base) const
virtual void setExtent(const QgsRectangle &rect)
Set the extent.
QString metadata() override
Obtain GDAL Metadata for this layer.
bool shade(double, int *, int *, int *, int *) override
Generates and new RGB value based on one input value.
static const double CUMULATIVE_CUT_UPPER
Default cumulative cut upper limit.
Q_DECL_DEPRECATED QPixmap previewAsPixmap(QSize size, const QColor &bgColor=Qt::white)
Draws a preview of the rasterlayer into a pixmap.
~QgsRasterLayer()
The destructor.
ContrastEnhancementLimits
Contrast enhancement limits.
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Get the data source specification.
qgssize elementCount
The number of not no data cells in the band.
void setMinimumValue(double, bool generateTable=true)
Return the minimum value for the contrast enhancement range.
Thirty two bit unsigned integer (quint32)
static void logMessage(const QString &message, const QString &tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
Raster renderer pipe for single band pseudocolor.
const QString bandName(int theBandNoInt)
Get the name of a band given its number.
bool isvalidrasterfilename_t(QString const &theFileNameQString, QString &retErrMsg)
Raster renderer pipe for single band gray.
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32.
static int typeSize(int dataType)
virtual QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Return new instance of QgsMapLayerRenderer that will be used for rendering of given context...
virtual void setLayerOrder(const QStringList &layers)
Reorder the list of layer names to be rendered by this provider (in order from bottom to top) ...
void statusChanged(const QString &theStatus)
Emit a signal with status (e.g.
QDateTime lastModified() const
void rendererChanged()
Signal emitted when renderer is changed.
void setAlphaBand(int band)
bool mValid
Indicates if the layer is valid and can be drawn.
static QPainter::CompositionMode getCompositionMode(BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
void setName(const QString &name)
Set the display name of the layer.
void setDataProvider(const QString &provider)
[ data provider interface ] Set the data provider
void setRasterShaderFunction(QgsRasterShaderFunction *)
A public method that allows the user to set their own shader function.
Base class for processing filters like renderers, reprojector, resampler etc.
A class to represent a point.
bool hasChildNodes() const
void setColorRampType(QgsColorRampShader::ColorRamp_TYPE theColorRampType)
Set the color ramp type.
virtual bool useSrcNoDataValue(int bandNo) const
Get source nodata value usage.
Sixteen bit signed integer (qint16)
QDomText createTextNode(const QString &value)
virtual void setSubLayerVisibility(const QString &name, bool vis) override
Set the visibility of the given sublayer name.
Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
QPixmap paletteAsPixmap(int theBandNumber=1)
Get an 100x100 pixmap of the color palette.
QDomNode namedItem(const QString &name) const
bool contains(QChar ch, Qt::CaseSensitivity cs) const
static ContrastEnhancementAlgorithm contrastEnhancementAlgorithmFromString(const QString &contrastEnhancementString)
QDateTime fromString(const QString &string, Qt::DateFormat format)
QByteArray encodedUri() const
return complete encoded uri (generic mode)
QgsCoordinateReferenceSystem mSrcCRS
Source coordinate system.
void writeStyleManager(QDomNode &layerNode, QDomDocument &doc) const
Write style manager's configuration (if exists).
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
void progressUpdate(int theValue)
Signal for notifying listeners of long running processes.
void showProgress(int theValue)
[ data provider interface ] A wrapper function to emit a progress update signal
virtual QgsRectangle extent() override=0
Get the extent of the data source.
Registry for raster renderer entries.
virtual QGis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
QgsPoint mBottomRightPoint
Coordinate (in output device coordinate system) of bottom right corner of the part of the raster that...
QImage previewAsImage(QSize size, const QColor &bgColor=Qt::white, QImage::Format format=QImage::Format_ARGB32_Premultiplied)
Draws a preview of the rasterlayer into a QImage.
void setContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used...
QVariant value(const QString &key, const QVariant &defaultValue) const
Contains information about the context of a rendering operation.
QString name() const
Get the display name of the layer.
static QgsMapLayerLegend * defaultRasterLegend(QgsRasterLayer *rl)
Create new legend implementation for raster layer.
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, QFlags< Qt::ImageConversionFlag > flags)
QgsRasterResampleFilter * resampleFilter() const
Set raster resample filter.
bool remove(int idx)
Remove and delete interface at given index if possible.
QString mDataSource
Data source description string, varies by layer type.
virtual QString loadDefaultStyle(bool &theResultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
Interpolates the color between two class breaks linearly.
bool writeXml(QDomNode &layer_node, QDomDocument &doc) override
Write layer specific state to project file Dom node.
QDomNode cloneNode(bool deep) const
virtual QString metadata()=0
Get metadata in a format suitable for feeding directly into a subset of the GUI raster properties "Me...
void readXML(const QDomElement &filterElem) override
Sets base class members from xml.
virtual void reloadData()
Reloads the data from the source.
virtual bool isValid()=0
Returns true if this is a valid layer.
void repaintRequested()
By emitting this signal the layer tells that either appearance or content have been changed and any v...
QDomElement firstChildElement(const QString &tagName) const
int mHeight
Distance in map units from bottom edge to top edge for the part of the raster that is to be rendered...
Brightness/contrast filter pipe for rasters.
Class for storing a coordinate reference system (CRS)
Assigns the color of the higher class for every pixel between two class breaks.
Color and saturation filter pipe for rasters.
static const double CUMULATIVE_CUT_LOWER
Default cumulative cut lower limit.
DataType
Raster data types.
virtual QString description() const =0
Return description.
double range
The range is the distance between min & max.
void setBlueContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
double minimumValue
The minimum cell value in the raster band.
Renderer for multiband images with the color components.
virtual int colorInterpretation(int theBandNo) const
Returns data type for the band specified by number.
void dataChanged()
Data of layer changed.
virtual QgsRasterRangeList userNoDataValues(int bandNo) const
Get list of user no data value ranges.
Base class for utility classes that encapsulate information necessary for rendering of map layers...
void appendError(const QgsErrorMessage &theMessage)
Add error message.
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range...
double toDouble(bool *ok) const
void(*)() cast_to_fptr(void *p)
QgsRasterDataProvider * dataProvider()
Returns the data provider.
QgsPoint mTopLeftPoint
Coordinate (in output device coordinate system) of top left corner of the part of the raster that is ...
This class provides details of the viewable area that a raster will be rendered into.
virtual bool srcHasNoDataValue(int bandNo) const
Return true if source band has no data value.
QDomElement createElement(const QString &tagName)
virtual void legendSymbologyItems(QList< QPair< QString, QColor > > &symbolItems) const
Get symbology items if provided by renderer.
virtual double srcNoDataValue(int bandNo) const
Value representing no data value.
virtual void reload() override
Synchronises with changes in the datasource.
void readXML(const QDomElement &filterElem) override
Sets base class members from xml.
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
virtual void setUserNoDataValue(int bandNo, const QgsRasterRangeList &noData)
virtual void cumulativeCut(int theBandNo, double theLowerCount, double theUpperCount, double &theLowerValue, double &theUpperValue, const QgsRectangle &theExtent=QgsRectangle(), int theSampleSize=0)
Find values for cumulative pixel count cut.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QgsLegendColorList legendSymbologyItems() const
Returns a list with classification items (Text and color)
bool set(QgsRasterInterface *theInterface)
Insert a new known interface in default place or replace interface of the same role if it already exi...
virtual int xSize() const
Get raster size.
Raster renderer pipe that applies colors to a raster.
QgsRasterRendererCreateFunc rendererCreateFunction
void setMaximumValue(double, bool generateTable=true)
Set the maximum value for the contrast enhancement range.
void showStatusMessage(const QString &theMessage)
virtual QDateTime dataTimestamp() const override
Current time stamp of data source.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
double height() const
Height of the rectangle.
QDomNode at(int index) const
QgsRectangle mDrawnExtent
Intersection of current map extent and layer extent.
Base class for raster data providers.
double sumOfSquares
The sum of the squares.
QgsRasterLayer()
Constructor.