58 #include <QApplication> 60 #include <QDomElement> 65 #include <QFontMetrics> 72 #include <QMessageBox> 82 #define ERR(message) QGS_ERROR_MESSAGE(message,"Raster layer") 102 , QSTRING_NOT_SET( QStringLiteral(
"Not Set" ) )
103 , TRSTRING_NOT_SET( tr(
"Not Set" ) )
111 const QString &baseName,
112 const QString &providerKey,
116 , QSTRING_NOT_SET( QStringLiteral(
"Not Set" ) )
117 , TRSTRING_NOT_SET( tr(
"Not Set" ) )
118 , mProviderKey( providerKey )
128 bool defaultLoadedFlag =
false;
133 if ( !defaultLoadedFlag )
157 for (
int i = 1; i < mPipe.
size(); i++ )
177 QgsDebugMsg(
"Could not resolve isValidRasterFileName in gdal provider library" );
181 bool myIsValid = pValid( fileNameQString, retErrMsg );
196 QFileInfo fi( name );
202 t = fi.lastModified();
225 if ( !mDataProvider )
return 0;
241 return mDataProvider;
246 return mDataProvider;
289 drawer.draw( theQPainter, rasterViewPort, qgsMapToPixel );
291 QgsDebugMsgLevel( QString(
"total raster draw time (ms): %1" ).arg( time.elapsed(), 5 ), 4 );
296 QList< QPair< QString, QColor > > symbolList;
308 QString myMetadata = QStringLiteral(
"<html>\n<body>\n" );
311 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Information from provider" ) + QStringLiteral(
"</h1>\n<hr>\n" );
312 myMetadata += QLatin1String(
"<table class=\"list-view\">\n" );
315 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Original" ) + QStringLiteral(
"</td><td>" ) +
name() + QStringLiteral(
"</td></tr>\n" );
318 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Name" ) + QStringLiteral(
"</td><td>" ) +
name() + QStringLiteral(
"</td></tr>\n" );
321 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Source" ) + QStringLiteral(
"</td><td>" ) +
publicSource() + QStringLiteral(
"</td></tr>\n" );
324 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Provider" ) + QStringLiteral(
"</td><td>" ) +
providerType() + QStringLiteral(
"</td></tr>\n" );
327 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"CRS" ) + QStringLiteral(
"</td><td>" );
330 myMetadata +=
crs().
authid() + QStringLiteral(
" - " );
332 if (
crs().isGeographic() )
333 myMetadata += tr(
"Geographic" );
335 myMetadata += tr(
"Projected" );
337 myMetadata += QLatin1String(
"</td></tr>\n" );
340 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Extent" ) + QStringLiteral(
"</td><td>" ) +
extent().
toString() + QStringLiteral(
"</td></tr>\n" );
343 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Unit" ) + QStringLiteral(
"</td><td>" ) +
QgsUnitTypes::toString(
crs().mapUnits() ) + QStringLiteral(
"</td></tr>\n" );
346 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Width" ) + QStringLiteral(
"</td><td>" );
348 myMetadata += QString::number(
width() );
350 myMetadata += tr(
"n/a" );
351 myMetadata += QLatin1String(
"</td></tr>\n" );
354 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Height" ) + QStringLiteral(
"</td><td>" );
356 myMetadata += QString::number(
height() );
358 myMetadata += tr(
"n/a" );
359 myMetadata += QLatin1String(
"</td></tr>\n" );
362 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Data type" ) + QStringLiteral(
"</td><td>" );
367 myMetadata += tr(
"Byte - Eight bit unsigned integer" );
370 myMetadata += tr(
"UInt16 - Sixteen bit unsigned integer " );
373 myMetadata += tr(
"Int16 - Sixteen bit signed integer " );
376 myMetadata += tr(
"UInt32 - Thirty two bit unsigned integer " );
379 myMetadata += tr(
"Int32 - Thirty two bit signed integer " );
382 myMetadata += tr(
"Float32 - Thirty two bit floating point " );
385 myMetadata += tr(
"Float64 - Sixty four bit floating point " );
388 myMetadata += tr(
"CInt16 - Complex Int16 " );
391 myMetadata += tr(
"CInt32 - Complex Int32 " );
394 myMetadata += tr(
"CFloat32 - Complex Float32 " );
397 myMetadata += tr(
"CFloat64 - Complex Float64 " );
400 myMetadata += tr(
"Could not determine raster data type." );
402 myMetadata += QLatin1String(
"</td></tr>\n" );
408 myMetadata += QLatin1String(
"</table>\n<br><br>" );
411 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Identification" ) + QStringLiteral(
"</h1>\n<hr>\n" );
413 myMetadata += QLatin1String(
"<br><br>\n" );
416 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Extent" ) + QStringLiteral(
"</h1>\n<hr>\n" );
418 myMetadata += QLatin1String(
"<br><br>\n" );
421 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Access" ) + QStringLiteral(
"</h1>\n<hr>\n" );
423 myMetadata += QLatin1String(
"<br><br>\n" );
426 myMetadata += QStringLiteral(
"</table>\n<br><br><h1>" ) + tr(
"Bands" ) + QStringLiteral(
"</h1>\n<hr>\n<table class=\"list-view\">\n" );
429 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Band count" ) + QStringLiteral(
"</td><td>" ) + QString::number(
bandCount() ) + QStringLiteral(
"</td></tr>\n" );
432 myMetadata += QLatin1String(
"</table>\n<br><table width=\"100%\" class=\"tabular-view\">\n" );
433 myMetadata +=
"<tr><th>" + tr(
"Number" ) +
"</th><th>" + tr(
"Band" ) +
"</th><th>" + tr(
"No-Data" ) +
"</th><th>" + tr(
"Min" ) +
"</th><th>" + tr(
"Max" ) +
"</th></tr>\n";
440 rowClass = QStringLiteral(
"class=\"odd-row\"" );
441 myMetadata +=
"<tr " + rowClass +
"><td>" + QString::number( i ) +
"</td><td>" +
bandName( i ) +
"</td><td>";
444 myMetadata += QString::number(
dataProvider()->sourceNoDataValue( i ) );
446 myMetadata += tr(
"n/a" );
447 myMetadata += QLatin1String(
"</td>" );
452 myMetadata +=
"<td>" + QString::number( myRasterBandStats.
minimumValue,
'f', 10 ) +
"</td>";
453 myMetadata +=
"<td>" + QString::number( myRasterBandStats.
maximumValue,
'f', 10 ) +
"</td>";
457 myMetadata +=
"<td>" + tr(
"n/a" ) +
"</td><td>" + tr(
"n/a" ) +
"</td>";
460 myMetadata += QLatin1String(
"</tr>\n" );
464 myMetadata += QLatin1String(
"</table>\n<br><br>" );
467 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Contacts" ) + QStringLiteral(
"</h1>\n<hr>\n" );
469 myMetadata += QLatin1String(
"<br><br>\n" );
472 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"References" ) + QStringLiteral(
"</h1>\n<hr>\n" );
474 myMetadata += QLatin1String(
"<br><br>\n" );
477 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"History" ) + QStringLiteral(
"</h1>\n<hr>\n" );
479 myMetadata += QLatin1String(
"<br><br>\n" );
481 myMetadata += QStringLiteral(
"\n</body>\n</html>\n" );
496 QList<QgsColorRampShader::ColorRampItem> myColorRampItemList = mDataProvider->
colorTable( bandNumber );
497 if ( !myColorRampItemList.isEmpty() )
504 QPixmap myPalettePixmap( mySize, mySize );
505 QPainter myQPainter( &myPalettePixmap );
507 QImage myQImage = QImage( mySize, mySize, QImage::Format_RGB32 );
509 myPalettePixmap.fill();
511 double myStep = (
static_cast< double >( myColorRampItemList.size() ) - 1 ) /
static_cast< double >( mySize * mySize );
512 double myValue = 0.0;
513 for (
int myRow = 0; myRow < mySize; myRow++ )
515 QRgb *myLineBuffer =
reinterpret_cast< QRgb *
>( myQImage.scanLine( myRow ) );
516 for (
int myCol = 0; myCol < mySize; myCol++ )
518 myValue = myStep *
static_cast< double >( myCol + myRow * mySize );
520 myShader.
shade( myValue, &c1, &c2, &c3, &c4 );
521 myLineBuffer[ myCol ] = qRgba( c1, c2, c3, c4 );
525 myQPainter.drawImage( 0, 0, myQImage );
526 return myPalettePixmap;
528 QPixmap myNullPixmap;
534 QPixmap myNullPixmap;
568 void QgsRasterLayer::init()
586 mPipe.
remove( mDataProvider );
587 mDataProvider =
nullptr;
592 mProviderKey = provider;
602 if ( !mDataProvider )
605 appendError(
ERR( tr(
"Cannot instantiate the '%1' data provider" ).arg( mProviderKey ) ) );
609 mDataProvider->setParent(
this );
612 mPipe.
set( mDataProvider );
613 if ( !mDataProvider->
isValid() )
623 QgsDebugMsgLevel( QString(
"Set Data provider QgsLayerMetadata identifier[%1]" ).arg(
metadata().identifier() ), 4 );
626 if ( provider == QLatin1String(
"gdal" ) )
658 if ( ( mDataProvider->
bandCount() > 1 ) )
706 QList<QgsColorRampShader::ColorRampItem> colorTable = mDataProvider->
colorTable( 1 );
729 for (
int bandNo = 1; bandNo <= mDataProvider->
bandCount(); bandNo++ )
743 mPipe.
set( brightnessFilter );
747 mPipe.
set( hueSaturationFilter );
751 mPipe.
set( resampleFilter );
755 mPipe.
set( projector );
792 void QgsRasterLayer::closeDataProvider()
795 mPipe.
remove( mDataProvider );
796 mDataProvider =
nullptr;
799 void QgsRasterLayer::computeMinMax(
int band,
804 double &min,
double &max )
807 min = std::numeric_limits<double>::quiet_NaN();
808 max = std::numeric_limits<double>::quiet_NaN();
826 QgsDebugMsgLevel( QString(
"myLower = %1 myUpper = %2" ).arg( myLower ).arg( myUpper ), 4 );
827 mDataProvider->
cumulativeCut( band, myLower, myUpper, min, max, extent, sampleSize );
829 QgsDebugMsgLevel( QString(
"band = %1 min = %2 max = %3" ).arg( band ).arg( min ).arg( max ), 4 );
840 generateLookupTableFlag,
848 bool generateLookupTableFlag,
852 if ( !rasterRenderer || !mDataProvider )
858 QList<QgsContrastEnhancement *> myEnhancements;
864 QString rendererType = rasterRenderer->
type();
865 if ( rendererType == QLatin1String(
"singlebandgray" ) )
868 if ( !myGrayRenderer )
872 myBands << myGrayRenderer->
grayBand();
873 myRasterRenderer = myGrayRenderer;
876 else if ( rendererType == QLatin1String(
"multibandcolor" ) )
879 if ( !myMultiBandRenderer )
884 myRasterRenderer = myMultiBandRenderer;
887 else if ( rendererType == QLatin1String(
"singlebandpseudocolor" ) )
890 if ( !myPseudoColorRenderer )
894 myBands << myPseudoColorRenderer->
band();
895 myRasterRenderer = myPseudoColorRenderer;
903 Q_FOREACH (
int myBand, myBands )
908 std::unique_ptr<QgsContrastEnhancement> myEnhancement(
new QgsContrastEnhancement( static_cast< Qgis::DataType >( myType ) ) );
909 myEnhancement->setContrastEnhancementAlgorithm(
algorithm, generateLookupTableFlag );
913 computeMinMax( myBand, myMinMaxOrigin, limits, extent, sampleSize, min, max );
915 if ( rendererType == QLatin1String(
"singlebandpseudocolor" ) )
919 if ( myPseudoColorRenderer->
shader() )
922 if ( colorRampShader )
930 myEnhancement->setMinimumValue( min );
931 myEnhancement->setMaximumValue( max );
932 myEnhancements.append( myEnhancement.release() );
937 myEnhancements.append(
nullptr );
941 if ( rendererType == QLatin1String(
"singlebandgray" ) )
945 else if ( rendererType == QLatin1String(
"multibandcolor" ) )
953 qDeleteAll( myEnhancements );
961 if ( myRasterRenderer )
979 if ( ( singleBandRenderer = dynamic_cast<QgsSingleBandGrayRenderer *>(
renderer() ) ) )
983 else if ( ( multiBandRenderer = dynamic_cast<QgsMultiBandColorRenderer *>(
renderer() ) ) )
1018 if ( !( mDataProvider &&
1019 mLastRectangleUsedByRefreshContrastEnhancementIfNeeded != extent &&
1028 if ( ( singleBandRenderer = dynamic_cast<QgsSingleBandGrayRenderer *>( rasterRenderer ) ) )
1032 else if ( ( multiBandRenderer = dynamic_cast<QgsMultiBandColorRenderer *>( rasterRenderer ) ) )
1036 else if ( ( sbpcr = dynamic_cast<QgsSingleBandPseudoColorRenderer *>( rasterRenderer ) ) )
1038 mLastRectangleUsedByRefreshContrastEnhancementIfNeeded =
extent;
1041 computeMinMax( sbpcr->
band(),
1051 if ( colorRampShader )
1064 if ( colorRampShader )
1079 mLastRectangleUsedByRefreshContrastEnhancementIfNeeded =
extent;
1089 if ( singleBandRenderer )
1091 else if ( multiBandRenderer )
1120 QString defaultLimits;
1123 if ( dynamic_cast<QgsSingleBandGrayRenderer *>(
renderer() ) )
1125 key = QStringLiteral(
"singleBand" );
1131 else if ( dynamic_cast<QgsMultiBandColorRenderer *>(
renderer() ) )
1135 key = QStringLiteral(
"multiBandSingleByte" );
1143 key = QStringLiteral(
"multiBandMultiByte" );
1151 if ( key.isEmpty() )
1153 QgsDebugMsg(
"No default contrast enhancement for this drawing style" );
1160 QString myAlgorithmString = mySettings.
value(
"/Raster/defaultContrastEnhancementAlgorithm/" + key, defaultAlg ).toString();
1165 QString myLimitsString = mySettings.
value(
"/Raster/defaultContrastEnhancementLimits/" + key, defaultLimits ).toString();
1187 if ( mDataProvider )
1198 if ( mDataProvider )
1200 QgsDebugMsgLevel(
"About to mDataProvider->setSubLayerVisibility(name, vis).", 4 );
1219 mPipe.
set( renderer );
1242 QImage myQImage( size, format );
1244 myQImage.setColor( 0, bgColor.rgba() );
1249 double myMapUnitsPerPixel;
1253 if ( myExtent.
width() / myExtent.
height() >=
static_cast< double >( myQImage.width() ) / myQImage.height() )
1255 myMapUnitsPerPixel = myExtent.
width() / myQImage.width();
1256 myY = ( myQImage.height() - myExtent.
height() / myMapUnitsPerPixel ) / 2;
1260 myMapUnitsPerPixel = myExtent.
height() / myQImage.height();
1261 myX = ( myQImage.width() - myExtent.
width() / myMapUnitsPerPixel ) / 2;
1264 double myPixelWidth = myExtent.
width() / myMapUnitsPerPixel;
1265 double myPixelHeight = myExtent.
height() / myMapUnitsPerPixel;
1269 myRasterViewPort->
mWidth = myQImage.width();
1270 myRasterViewPort->
mHeight = myQImage.height();
1280 QPainter *myQPainter =
new QPainter( &myQImage );
1281 draw( myQPainter, myRasterViewPort, myMapToPixel );
1282 delete myRasterViewPort;
1283 delete myMapToPixel;
1302 Q_UNUSED( errorMessage );
1303 QDomElement rasterRendererElem;
1305 QDomElement layerElement = layer_node.toElement();
1312 QDomNode pipeNode = layer_node.firstChildElement( QStringLiteral(
"pipe" ) );
1313 if ( pipeNode.isNull() )
1315 pipeNode = layer_node;
1319 if ( !layer_node.firstChildElement( QStringLiteral(
"rasterproperties" ) ).isNull() )
1322 QDomNode layerNodeCopy = layer_node.cloneNode();
1323 QDomDocument doc = layerNodeCopy.ownerDocument();
1324 QDomElement rasterPropertiesElem = layerNodeCopy.firstChildElement( QStringLiteral(
"rasterproperties" ) );
1327 rasterRendererElem = layerNodeCopy.firstChildElement( QStringLiteral(
"rasterrenderer" ) );
1332 rasterRendererElem = pipeNode.firstChildElement( QStringLiteral(
"rasterrenderer" ) );
1335 if ( !rasterRendererElem.isNull() )
1337 QString rendererType = rasterRendererElem.attribute( QStringLiteral(
"type" ) );
1342 mPipe.
set( renderer );
1348 mPipe.
set( brightnessFilter );
1351 QDomElement brightnessElem = pipeNode.firstChildElement( QStringLiteral(
"brightnesscontrast" ) );
1352 if ( !brightnessElem.isNull() )
1354 brightnessFilter->
readXml( brightnessElem );
1359 mPipe.
set( hueSaturationFilter );
1362 QDomElement hueSaturationElem = pipeNode.firstChildElement( QStringLiteral(
"huesaturation" ) );
1363 if ( !hueSaturationElem.isNull() )
1365 hueSaturationFilter->
readXml( hueSaturationElem );
1370 mPipe.
set( resampleFilter );
1373 QDomElement resampleElem = pipeNode.firstChildElement( QStringLiteral(
"rasterresampler" ) );
1374 if ( !resampleElem.isNull() )
1376 resampleFilter->
readXml( resampleElem );
1380 QDomNode blendModeNode = layer_node.namedItem( QStringLiteral(
"blendMode" ) );
1381 if ( !blendModeNode.isNull() )
1383 QDomElement e = blendModeNode.toElement();
1403 QDomNode pkeyNode = layer_node.namedItem( QStringLiteral(
"provider" ) );
1405 if ( pkeyNode.isNull() )
1407 mProviderKey = QStringLiteral(
"gdal" );
1411 QDomElement pkeyElt = pkeyNode.toElement();
1412 mProviderKey = pkeyElt.text();
1413 if ( mProviderKey.isEmpty() )
1415 mProviderKey = QStringLiteral(
"gdal" );
1425 QDomNode rpNode = layer_node.namedItem( QStringLiteral(
"rasterproperties" ) );
1427 if ( mProviderKey == QLatin1String(
"wms" ) )
1431 if ( !
mDataSource.contains( QLatin1String(
"crs=" ) ) && !
mDataSource.contains( QLatin1String(
"format=" ) ) )
1436 QDomElement layerElement = rpNode.firstChildElement( QStringLiteral(
"wmsSublayer" ) );
1437 while ( !layerElement.isNull() )
1442 uri.
setParam( QStringLiteral(
"layers" ), layerElement.namedItem( QStringLiteral(
"name" ) ).toElement().text() );
1445 uri.
setParam( QStringLiteral(
"styles" ), layerElement.namedItem( QStringLiteral(
"style" ) ).toElement().text() );
1447 layerElement = layerElement.nextSiblingElement( QStringLiteral(
"wmsSublayer" ) );
1451 QDomNode formatNode = rpNode.namedItem( QStringLiteral(
"wmsFormat" ) );
1452 uri.
setParam( QStringLiteral(
"format" ), rpNode.namedItem( QStringLiteral(
"wmsFormat" ) ).toElement().text() );
1456 uri.
setParam( QStringLiteral(
"crs" ),
crs().authid() );
1464 if ( !
mValid )
return false;
1470 if ( res && mProviderKey == QLatin1String(
"wms" ) && ( !
renderer() ||
renderer()->
type() != QLatin1String(
"singlebandcolordata" ) ) )
1481 QDomNode stampNode = layer_node.namedItem(
"timestamp" );
1482 if ( !stampNode.isNull() )
1484 QDateTime stamp = QDateTime::fromString( stampNode.toElement().text(), Qt::ISODate );
1486 if ( stamp < mDataProvider->dataTimestamp() )
1489 closeDataProvider();
1492 if ( !
mValid )
return false;
1498 QDomElement noDataElement = layer_node.firstChildElement( QStringLiteral(
"noData" ) );
1500 QDomNodeList noDataBandList = noDataElement.elementsByTagName( QStringLiteral(
"noDataList" ) );
1502 for (
int i = 0; i < noDataBandList.size(); ++i )
1504 QDomElement bandElement = noDataBandList.at( i ).toElement();
1506 int bandNo = bandElement.attribute( QStringLiteral(
"bandNo" ) ).toInt( &ok );
1508 if ( ok && ( bandNo > 0 ) && ( bandNo <= mDataProvider->
bandCount() ) )
1510 mDataProvider->
setUseSourceNoDataValue( bandNo, bandElement.attribute( QStringLiteral(
"useSrcNoData" ) ).toInt() );
1513 QDomNodeList rangeList = bandElement.elementsByTagName( QStringLiteral(
"noDataRange" ) );
1515 myNoDataRangeList.reserve( rangeList.size() );
1516 for (
int j = 0; j < rangeList.size(); ++j )
1518 QDomElement rangeElement = rangeList.at( j ).toElement();
1519 QgsRasterRange myNoDataRange( rangeElement.attribute( QStringLiteral(
"min" ) ).toDouble(),
1520 rangeElement.attribute( QStringLiteral(
"max" ) ).toDouble() );
1521 QgsDebugMsgLevel( QString(
"min = %1 %2" ).arg( rangeElement.attribute(
"min" ) ).arg( myNoDataRange.min() ), 4 );
1522 myNoDataRangeList << myNoDataRange;
1541 Q_UNUSED( errorMessage );
1543 QDomElement layerElement = layer_node.toElement();
1548 QDomElement pipeElement = document.createElement( QStringLiteral(
"pipe" ) );
1550 for (
int i = 1; i < mPipe.
size(); i++ )
1553 if ( !interface )
continue;
1554 interface->writeXml( document, pipeElement );
1557 layer_node.appendChild( pipeElement );
1560 QDomElement blendModeElement = document.createElement( QStringLiteral(
"blendMode" ) );
1562 blendModeElement.appendChild( blendModeText );
1563 layer_node.appendChild( blendModeElement );
1579 QDomDocument &document,
1584 QDomElement mapLayerNode = layer_node.toElement();
1586 if ( mapLayerNode.isNull() ||
"maplayer" != mapLayerNode.nodeName() )
1592 mapLayerNode.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"raster" ) );
1596 QDomElement provider = document.createElement( QStringLiteral(
"provider" ) );
1597 QDomText providerText = document.createTextNode( mProviderKey );
1598 provider.appendChild( providerText );
1599 layer_node.appendChild( provider );
1602 QDomElement noData = document.createElement( QStringLiteral(
"noData" ) );
1604 for (
int bandNo = 1; bandNo <= mDataProvider->
bandCount(); bandNo++ )
1606 QDomElement noDataRangeList = document.createElement( QStringLiteral(
"noDataList" ) );
1607 noDataRangeList.setAttribute( QStringLiteral(
"bandNo" ), bandNo );
1608 noDataRangeList.setAttribute( QStringLiteral(
"useSrcNoData" ), mDataProvider->
useSourceNoDataValue( bandNo ) );
1612 QDomElement noDataRange = document.createElement( QStringLiteral(
"noDataRange" ) );
1616 noDataRangeList.appendChild( noDataRange );
1619 noData.appendChild( noDataRangeList );
1622 if ( noData.hasChildNodes() )
1624 layer_node.appendChild( noData );
1631 return writeSymbology( layer_node, document, errorMsg, context );
1636 QString src( source );
1637 bool handled =
false;
1642 if ( src.startsWith( QLatin1String(
"NETCDF:" ) ) )
1646 QRegExp r(
"NETCDF:(.+):([^:]+)" );
1647 if ( r.exactMatch( src ) )
1649 QString filename = r.cap( 1 );
1650 if ( filename.startsWith(
'"' ) && filename.endsWith(
'"' ) )
1651 filename = filename.mid( 1, filename.length() - 2 );
1656 else if ( src.startsWith( QLatin1String(
"HDF4_SDS:" ) ) )
1660 QRegExp r(
"HDF4_SDS:([^:]+):(.+):([^:]+)" );
1661 if ( r.exactMatch( src ) )
1663 QString filename = r.cap( 2 );
1664 if ( filename.startsWith(
'"' ) && filename.endsWith(
'"' ) )
1665 filename = filename.mid( 1, filename.length() - 2 );
1666 src =
"HDF4_SDS:" + r.cap( 1 ) +
":\"" + context.
pathResolver().
writePath( filename ) +
"\":" + r.cap( 3 );
1670 else if ( src.startsWith( QLatin1String(
"HDF5:" ) ) )
1674 QRegExp r(
"HDF5:(.+):([^:]+)" );
1675 if ( r.exactMatch( src ) )
1677 QString filename = r.cap( 1 );
1678 if ( filename.startsWith(
'"' ) && filename.endsWith(
'"' ) )
1679 filename = filename.mid( 1, filename.length() - 2 );
1684 else if ( src.contains( QRegExp(
"^(NITF_IM|RADARSAT_2_CALIB):" ) ) )
1688 QRegExp r(
"([^:]+):([^:]+):(.+)" );
1689 if ( r.exactMatch( src ) )
1705 QString src( source );
1707 if ( provider == QLatin1String(
"wms" ) )
1721 if ( !src.contains( QLatin1String(
"type=" ) ) &&
1722 !src.contains( QLatin1String(
"crs=" ) ) && !src.contains( QLatin1String(
"format=" ) ) )
1724 QgsDebugMsg(
"Old WMS URI format detected -> converting to new format" );
1726 if ( !src.startsWith( QLatin1String(
"http:" ) ) )
1728 QStringList parts = src.split(
',' );
1729 QStringListIterator iter( parts );
1730 while ( iter.hasNext() )
1732 QString item = iter.next();
1733 if ( item.startsWith( QLatin1String(
"username=" ) ) )
1735 uri.
setParam( QStringLiteral(
"username" ), item.mid( 9 ) );
1737 else if ( item.startsWith( QLatin1String(
"password=" ) ) )
1739 uri.
setParam( QStringLiteral(
"password" ), item.mid( 9 ) );
1741 else if ( item.startsWith( QLatin1String(
"tiled=" ) ) )
1747 QStringList params = item.mid( 6 ).split(
';' );
1749 if ( params.size() == 2 )
1751 uri.
setParam( QStringLiteral(
"maxWidth" ), params.takeFirst() );
1752 uri.
setParam( QStringLiteral(
"maxHeight" ), params.takeFirst() );
1754 else if ( params.size() > 2 )
1758 uri.
setParam( QStringLiteral(
"tileMatrixSet" ), QLatin1String(
"" ) );
1761 else if ( item.startsWith( QLatin1String(
"featureCount=" ) ) )
1763 uri.
setParam( QStringLiteral(
"featureCount" ), item.mid( 13 ) );
1765 else if ( item.startsWith( QLatin1String(
"url=" ) ) )
1767 uri.
setParam( QStringLiteral(
"url" ), item.mid( 4 ) );
1769 else if ( item.startsWith( QLatin1String(
"ignoreUrl=" ) ) )
1771 uri.
setParam( QStringLiteral(
"ignoreUrl" ), item.mid( 10 ).split(
';' ) );
1777 uri.
setParam( QStringLiteral(
"url" ), src );
1787 bool handled =
false;
1789 if ( provider == QLatin1String(
"gdal" ) )
1791 if ( src.startsWith( QLatin1String(
"NETCDF:" ) ) )
1795 QRegExp r(
"NETCDF:(.+):([^:]+)" );
1796 if ( r.exactMatch( src ) )
1798 QString filename = r.cap( 1 );
1799 if ( filename.startsWith(
'"' ) && filename.endsWith(
'"' ) )
1800 filename = filename.mid( 1, filename.length() - 2 );
1805 else if ( src.startsWith( QLatin1String(
"HDF4_SDS:" ) ) )
1809 QRegExp r(
"HDF4_SDS:([^:]+):(.+):([^:]+)" );
1810 if ( r.exactMatch( src ) )
1812 QString filename = r.cap( 2 );
1813 if ( filename.startsWith(
'"' ) && filename.endsWith(
'"' ) )
1814 filename = filename.mid( 1, filename.length() - 2 );
1815 src =
"HDF4_SDS:" + r.cap( 1 ) +
":\"" + context.
pathResolver().
readPath( filename ) +
"\":" + r.cap( 3 );
1819 else if ( src.startsWith( QLatin1String(
"HDF5:" ) ) )
1823 QRegExp r(
"HDF5:(.+):([^:]+)" );
1824 if ( r.exactMatch( src ) )
1826 QString filename = r.cap( 1 );
1827 if ( filename.startsWith(
'"' ) && filename.endsWith(
'"' ) )
1828 filename = filename.mid( 1, filename.length() - 2 );
1833 else if ( src.contains( QRegExp(
"^(NITF_IM|RADARSAT_2_CALIB):" ) ) )
1837 QRegExp r(
"([^:]+):([^:]+):(.+)" );
1838 if ( r.exactMatch( src ) )
1855 if ( !mDataProvider )
return 0;
1856 return mDataProvider->
xSize();
1861 if ( !mDataProvider )
return 0;
1862 return mDataProvider->
ySize();
1870 bool QgsRasterLayer::update()
1877 closeDataProvider();
QgsDataProvider * classFactoryFunction_t(const QString *, const QgsDataProvider::ProviderOptions &options)
int width() const
Returns the width of the (unclipped) raster.
QgsRasterMinMaxOrigin::Limits limits() const
Returns the raster limits.
void writeCommonStyle(QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context) const
Write style data common to all layer types.
virtual int bandCount() const =0
Gets number of bands.
QgsRasterMinMaxOrigin::Extent extent() const
Returns the raster extent.
virtual void setSubLayerVisibility(const QString &name, bool vis)
Set the visibility of the given sublayer name.
The class is used as a container of context for various read/write operations on other objects...
A rectangle specified with double values.
Base class for all map layer types.
Thirty two bit signed integer (qint32)
Interface for all raster shaders.
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &list)
Sets a custom colormap.
QgsRasterLayer * clone() const override
Returns a new instance equivalent to this one.
QStringList subLayers() const override
Returns the sublayers of this layer.
static QString printValue(double value)
Print double value with all necessary significant digits.
void refreshContrastEnhancement(const QgsRectangle &extent)
Refresh contrast enhancement with new extent.
virtual void setUseSourceNoDataValue(int bandNo, bool use)
Sets the source nodata value usage.
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
const QgsContrastEnhancement * blueContrastEnhancement() const
static Q_INVOKABLE QString toString(QgsUnitTypes::DistanceUnit unit)
Returns a translated string representing a distance unit.
Iterator for sequentially processing raster cells.
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
static const QgsContrastEnhancement::ContrastEnhancementAlgorithm MULTIPLE_BAND_MULTI_BYTE_ENHANCEMENT_ALGORITHM
Default enhancement algorithm for multiple band raster of type different from Byte.
int bandCount() const
Returns the number of bands in this layer.
This class is a composition of two QSettings instances:
QgsHueSaturationFilter * hueSaturationFilter() const
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
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
Gets current status error.
QgsRasterRenderer * renderer() const
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setRenderer(QgsRasterRenderer *renderer)
Sets raster renderer. Takes ownership of the renderer object.
virtual QgsError error() const
Gets current status error.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
void setLayerOrder(const QStringList &layers) override
Reorders the previously selected sublayers of this layer from bottom to top.
double rasterUnitsPerPixelX() const
Returns the number of raster units per each raster pixel in X axis.
void readCommonStyle(const QDomElement &layerElement, const QgsReadWriteContext &context)
Read style data common to all layer types.
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
QgsRasterPipe * pipe()
Returns the raster pipe.
bool writeXml(QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context) const override
Called by writeLayerXML(), used by children to write state specific to them to project files...
A class to represent a 2D point.
void setDefaultContrastEnhancement()
Sets the default contrast enhancement.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
void showStatusMessage(const QString &message)
virtual QgsRasterInterface * input() const
Current input.
QgsRasterProjector * projector() const
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
virtual QString type() const
Thirty two bit unsigned integer (quint32)
void readCustomProperties(const QDomNode &layerNode, const QString &keyStartsWith=QString())
Read custom properties from project file.
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
DataType
Raster data types.
QgsRasterInterface * last() const
double maximumValue
The maximum cell value in the raster band.
static Limits limitsFromString(const QString &limits)
Deserialize Limits.
const QgsContrastEnhancement * contrastEnhancement() const
virtual int ySize() const
int mWidth
Width, number of columns to be rendered.
bool readXml(const QDomNode &layer_node, QgsReadWriteContext &context) override
Called by readLayerXML(), used by children to read state specific to them from project files...
virtual const QgsLayerMetadata & metadata() const
Returns a reference to the layer's metadata store.
double rasterUnitsPerPixelY() const
Returns the number of raster units per each raster pixel in Y axis.
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...
static QDateTime lastModified(const QString &name)
Returns time stamp for given file name.
double max() const
Returns the maximum value for the range.
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
Raster values range container.
Resample filter pipe for rasters.
Abstract base class for spatial data provider implementations.
bool writeSymbology(QDomNode &, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context) const override
Write the symbology for the layer into the docment provided.
const QgsRasterMinMaxOrigin & minMaxOrigin() const
Returns const reference to origin of min/max values.
QgsRasterRenderer * renderer() const
int height() const
Returns the height of the (unclipped) raster.
static const double SAMPLE_SIZE
Default sample size (number of pixels) for estimated statistics/histogram calculation.
Thirty two bit floating point (float)
bool isValid() const
Returns the status of the layer.
Implementation of threaded rendering for raster layers.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
QgsRasterShader * shader()
Returns the raster shader.
virtual void cumulativeCut(int bandNo, double lowerCount, double upperCount, double &lowerValue, double &upperValue, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0)
Find values for cumulative pixel count cut.
QgsMapLayer::LayerType type() const
Returns the type of the layer.
QPixmap paletteAsPixmap(int bandNumber=1)
Returns a 100x100 pixmap of the color palette.
void readXml(const QDomElement &filterElem) override
Sets base class members from xml. Usually called from create() methods of subclasses.
Sixteen bit signed integer (qint16)
void setClassificationMax(double max)
QDateTime timestamp() const override
Time stamp of data source in the moment when data/metadata were loaded by provider.
QString mLayerName
Name of the layer - used for display.
void setShader(QgsRasterShader *shader)
Takes ownership of the shader.
void styleChanged()
Signal emitted whenever a change affects the layer's style.
void setGreenContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
void statusChanged(const QString &) const
Emit a message to be displayed on status bar, usually used by network providers (WMS,WCS)
Sixty four bit floating point (double)
Current extent of the canvas (at the time of computation) is used to compute statistics.
static QString identifyFormatName(QgsRaster::IdentifyFormat format)
virtual QgsRectangle extent() const
Returns the extent of the layer.
void setExtent(QgsRasterMinMaxOrigin::Extent extent)
Sets the extent.
QgsCoordinateReferenceSystem mDestCRS
Target coordinate system.
virtual QgsLayerMetadata layerMetadata() const
Returns layer metadata collected from the provider's source.
QgsDataProvider * createProvider(const QString &providerKey, const QString &dataSource, const QgsDataProvider::ProviderOptions &options=QgsDataProvider::ProviderOptions())
Creates a new instance of a provider.
QgsBrightnessContrastFilter * brightnessFilter() const
void setCrs(const QgsCoordinateReferenceSystem &srcCRS, const QgsCoordinateReferenceSystem &destCRS, int srcDatumTransform=-1, int destDatumTransform=-1)
Sets the source and destination CRS.
QDateTime timestamp() const override
Time stamp of data source in the moment when data/metadata were loaded by provider.
void statusChanged(const QString &status)
Emit a signal with status (e.g. to be caught by QgisApp and display a msg on status bar) ...
double cumulativeCutLower() const
Returns the lower bound of cumulative cut method (between 0 and 1).
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
Perform transforms between map coordinates and device coordinates.
static const QgsRasterMinMaxOrigin::Limits MULTIPLE_BAND_SINGLE_BYTE_MIN_MAX_LIMITS
Default enhancement limits for multiple band raster of type Byte.
The drawing pipe for raster layers.
double stdDev
The standard deviation of the cell values.
Paletted (see associated color table)
void setContrastEnhancement(QgsContrastEnhancement::ContrastEnhancementAlgorithm algorithm, QgsRasterMinMaxOrigin::Limits limits=QgsRasterMinMaxOrigin::MinMax, const QgsRectangle &extent=QgsRectangle(), int sampleSize=QgsRasterLayer::SAMPLE_SIZE, bool generateLookupTableFlag=true)
Set contrast enhancement algorithm.
void setColorRampType(QgsColorRampShader::Type colorRampType)
Sets the color ramp type.
Alpha (0=transparent, 255=opaque)
QgsRasterDataProvider * dataProvider() override
Returns the layer's data provider.
This class describes the origin of min/max values.
The RasterBandStats struct is a container for statistics about a single raster band.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
static bool isValidRasterFileName(const QString &fileNameQString, QString &retError)
This helper checks to see whether the file name appears to be a valid raster file name...
double mean
The mean cell value for the band. NO_DATA values are excluded.
Continuous palette, QGIS addition, GRASS.
void readStyleManager(const QDomNode &layerNode)
Read style manager's configuration (if any). To be called by subclasses.
void setRedContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
#define QgsDebugMsgLevel(str, level)
bool isEmpty() const
Returns true if the rectangle is empty.
virtual void setMetadata(const QgsLayerMetadata &metadata)
Sets the layer's metadata store.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
QgsPointXY mBottomRightPoint
Coordinate (in output device coordinate system) of bottom right corner of the part of the raster that...
virtual int capabilities() const
Returns a bitmask containing the supported capabilities.
QgsRectangle extent() const override=0
Returns the extent of the layer.
virtual bool isValid() const =0
Returns true if this is a valid layer.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
static const QgsContrastEnhancement::ContrastEnhancementAlgorithm SINGLE_BAND_ENHANCEMENT_ALGORITHM
Default enhancement algorithm for single band raster.
bool loadDefaultStyle
Sets to true if the default layer style should be loaded.
QgsRasterInterface * at(int idx) const
QString providerType() const
[ data provider interface ] Which provider is being used for this Raster Layer?
double width() const
Returns the width of the rectangle.
QgsRasterShaderFunction * rasterShaderFunction()
virtual void setExtent(const QgsRectangle &rect)
Sets the extent.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
double cumulativeCutUpper() const
Returns the upper bound of cumulative cut method (between 0 and 1).
QString bandName(int bandNoInt) const
Returns the name of a band given its number.
Constantly updated extent of the canvas is used to compute statistics.
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
virtual bool hasStatistics(int bandNo, int stats=QgsRasterBandStats::All, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0)
Returns true if histogram is available (cached, already calculated).
void setEncodedUri(const QByteArray &uri)
set complete encoded uri (generic mode)
Raster renderer pipe for single band pseudocolor.
QString description() const
Returns the descriptive name of the CRS, e.g., "WGS 84" or "GDA 94 / Vicgrid94".
void setRasterShaderFunction(QgsRasterShaderFunction *function)
A public method that allows the user to set their own shader function.
Range is [ mean - stdDevFactor() * stddev, mean + stdDevFactor() * stddev ].
static QString contrastEnhancementAlgorithmString(ContrastEnhancementAlgorithm algorithm)
Returns a string to serialize ContrastEnhancementAlgorithm.
QgsCoordinateReferenceSystem crs() const
Returns the layer's spatial reference system.
bool defaultContrastEnhancementSettings(QgsContrastEnhancement::ContrastEnhancementAlgorithm &myAlgorithm, QgsRasterMinMaxOrigin::Limits &myLimits) const
Returns default contrast enhancement settings for that type of raster.
void draw(QPainter *theQPainter, QgsRasterViewPort *myRasterViewPort, const QgsMapToPixel *qgsMapToPixel=nullptr)
This is an overloaded version of the draw() function that is called by both draw() and thumbnailAsPix...
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example...
Raster renderer pipe for single band gray.
static int typeSize(int dataType)
void setParam(const QString &key, const QString &value)
Set generic param (generic mode)
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context...
Sixteen bit unsigned integer (quint16)
virtual void setLayerOrder(const QStringList &layers)
Reorder the list of layer names to be rendered by this provider (in order from bottom to top) ...
bool readStyle(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context) override
Read the style for the current layer from the Dom node supplied.
QString decodedSource(const QString &source, const QString &provider, const QgsReadWriteContext &context) const override
Called by readLayerXML(), used by derived classes to decode provider's specific data source from proj...
void rendererChanged()
Signal emitted when renderer is changed.
void setAlphaBand(int band)
bool mValid
Indicates if the layer is valid and can be drawn.
void setName(const QString &name)
Set the display name of the layer.
Q_DECL_DEPRECATED void setDataProvider(const QString &provider)
Set the data provider.
Range is [ min + cumulativeCutLower() * (max - min), min + cumulativeCutUpper() * (max - min) ]...
Base class for processing filters like renderers, reprojector, resampler etc.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
static const QgsRasterMinMaxOrigin::Limits SINGLE_BAND_MIN_MAX_LIMITS
Default enhancement limits for single band raster.
static QString limitsString(Limits limits)
Returns a string to serialize Limits.
void setSubLayerVisibility(const QString &name, bool vis) override
Set the visibility of the given sublayer name.
bool shade(double value, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlphaValue) override
Generates and new RGB value based on one input value.
virtual QString htmlMetadata()=0
Returns metadata in a format suitable for feeding directly into a subset of the GUI raster properties...
static ContrastEnhancementAlgorithm contrastEnhancementAlgorithmFromString(const QString &contrastEnhancementString)
Deserialize ContrastEnhancementAlgorithm.
void classifyColorRamp(int classes=0, int band=-1, const QgsRectangle &extent=QgsRectangle(), QgsRasterInterface *input=nullptr)
Classify color ramp shader.
void repaintRequested(bool deferredUpdate=false)
By emitting this signal the layer tells that either appearance or content have been changed and any v...
void setMinMaxOrigin(const QgsRasterMinMaxOrigin &origin)
Sets origin of min/max values.
Limits
This enumerator describes the limits used to compute min/max values.
QgsCoordinateReferenceSystem mSrcCRS
Source coordinate system.
void setLimits(QgsRasterMinMaxOrigin::Limits limits)
Sets the limits.
void writeStyleManager(QDomNode &layerNode, QDomDocument &doc) const
Write style manager's configuration (if exists). To be called by subclasses.
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
bool set(QgsRasterInterface *interface)
Insert a new known interface in default place or replace interface of the same role if it already exi...
Registry for raster renderer entries.
virtual QgsRasterBandStats bandStatistics(int bandNo, int stats=QgsRasterBandStats::All, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, QgsRasterBlockFeedback *feedback=nullptr)
Returns the band statistics.
bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context) override
Read the symbology for the current layer from the Dom node supplied.
QList< QPair< QString, QColor > > QgsLegendColorList
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.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used...
virtual QString loadDefaultStyle(bool &resultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
Contains information about the context of a rendering operation.
Setting options for creating vector data providers.
QString name() const
Returns the display name of the layer.
void setClassificationMin(double min)
bool writeStyle(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context) const override
Write just the style information for the layer into the document.
static QgsMapLayerLegend * defaultRasterLegend(QgsRasterLayer *rl)
Create new legend implementation for raster layer.
const QgsContrastEnhancement * redContrastEnhancement() const
const QgsContrastEnhancement * greenContrastEnhancement() const
QgsRasterResampleFilter * resampleFilter() const
Sets raster resample filter. Takes ownership of the resample filter object.
bool remove(int idx)
Remove and delete interface at given index if possible.
QList< QgsRasterRange > QgsRasterRangeList
QString mDataSource
Data source description string, varies by layer type.
QString source() const
Returns the source for the layer.
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
Whole raster is used to compute statistics.
virtual void reloadData()
Reloads the data from the source.
QByteArray encodedUri() const
Returns complete encoded uri (generic mode)
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.
This class represents a coordinate reference system (CRS).
Color and saturation filter pipe for rasters.
void setBlueContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
Provider can read layer metadata from data store. Since QGIS 3.0. See QgsDataProvider::layerMetadata(...
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const
bool isvalidrasterfilename_t(QString const &fileNameQString, QString &retErrMsg)
QStringList subLayers() const override
Returns the sublayers of this layer - useful for providers that manage their own layers, such as WMS.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
double minimumValue
The minimum cell value in the raster band.
Renderer for multiband images with the color components.
void dataChanged()
Data of layer changed.
void appendError(const QgsErrorMessage &error)
Add error message.
virtual QgsRasterRangeList userNoDataValues(int bandNo) const
Returns a list of user no data value ranges.
Base class for utility classes that encapsulate information necessary for rendering of map layers...
Interpolates the color between two class breaks linearly.
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range...
QString encodedSource(const QString &source, const QgsReadWriteContext &context) const override
Called by writeLayerXML(), used by derived classes to encode provider's specific data source to proje...
void readXml(const QDomElement &filterElem) override
Sets base class members from xml. Usually called from create() methods of subclasses.
void refreshRendererIfNeeded(QgsRasterRenderer *rasterRenderer, const QgsRectangle &extent)
Refresh renderer with new extent, if needed.
~QgsRasterLayer() override
This class provides details of the viewable area that a raster will be rendered into.
QDateTime dataTimestamp() const override
Current time stamp of data source.
virtual bool useSourceNoDataValue(int bandNo) const
Returns the source nodata value usage.
Assigns the color of the higher class for every pixel between two class breaks.
virtual void legendSymbologyItems(QList< QPair< QString, QColor > > &symbolItems) const
Gets symbology items if provided by renderer.
double min() const
Returns the minimum value for the range.
virtual QString generateBandName(int bandNumber) const
helper function to create zero padded band names
void reload() override
Synchronises with changes in the datasource.
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
virtual void setUserNoDataValue(int bandNo, const QgsRasterRangeList &noData)
QgsLegendColorList legendSymbologyItems() const
Returns a list with classification items (Text and color)
virtual QgsRasterDataProvider::ProviderCapabilities providerCapabilities() const
Returns flags containing the supported capabilities of the data provider.
void readXml(const QDomElement &filterElem) override
Sets base class members from xml. Usually called from create() methods of subclasses.
double stdDevFactor() const
Returns the factor f so that the min/max range is [ mean - f * stddev , mean + f * stddev ]...
virtual int xSize() const
Gets raster size.
static QgsRasterRendererRegistry * rasterRendererRegistry()
Returns the application's raster renderer registry, used for managing raster layer renderers...
Raster renderer pipe that applies colors to a raster.
QgsRasterRendererCreateFunc rendererCreateFunction
static const QgsContrastEnhancement::ContrastEnhancementAlgorithm MULTIPLE_BAND_SINGLE_BYTE_ENHANCEMENT_ALGORITHM
Default enhancement algorithm for multiple band raster of type Byte.
void setError(const QgsError &error)
Sets error message.
QString authid() const
Returns the authority identifier for the CRS.
Eight bit unsigned integer (quint8)
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
Setting options for loading raster layers.
static const QgsRasterMinMaxOrigin::Limits MULTIPLE_BAND_MULTI_BYTE_MIN_MAX_LIMITS
Default enhancement limits for multiple band raster of type different from Byte.
int band() const
Returns the band used by the renderer.
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
double height() const
Returns the height of the rectangle.
virtual int colorInterpretation(int bandNo) const
Returns data type for the band specified by number.
QgsRectangle mDrawnExtent
Intersection of current map extent and layer extent.
Base class for raster data providers.
QgsPointXY mTopLeftPoint
Coordinate (in output device coordinate system) of top left corner of the part of the raster that is ...
QgsRasterLayer()
Constructor. Provider is not set.