37#include "moc_qgsrasterlayer.cpp"
52#include "qgsgdalprovider.h"
71#include <QApplication>
79#include <QFontMetrics>
86#include <QRegularExpression>
93#define ERR(message) QGS_ERROR_MESSAGE(message,"Raster layer")
113 , QSTRING_NOT_SET( QStringLiteral(
"Not Set" ) )
114 , TRSTRING_NOT_SET( tr(
"Not Set" ) )
124 const QString &baseName,
125 const QString &providerKey,
129 , QSTRING_NOT_SET( QStringLiteral(
"Not Set" ) )
130 , TRSTRING_NOT_SET( tr(
"Not Set" ) )
147 setDataSource( uri, baseName, providerKey, providerOptions, providerFlags );
175 std::unique_ptr< QgsRasterLayer > layer = std::make_unique< QgsRasterLayer >(
source(),
name(),
mProviderKey, options );
177 layer->mElevationProperties = mElevationProperties->
clone();
178 layer->mElevationProperties->setParent( layer.get() );
183 for (
int i = 1; i < mPipe->size(); i++ )
185 if ( mPipe->at( i ) )
186 layer->pipe()->set( mPipe->at( i )->clone() );
189 layer->setResamplingStage( mPipe->resamplingStage() );
190 if ( mDataProvider && layer->dataProvider() )
196 layer->setLabelsEnabled( mLabelsEnabled );
198 layer->setLabeling( mLabeling->clone() );
200 return layer.release();
207 if ( !mElevationProperties->
isEnabled() )
221 const bool myIsValid = QgsGdalProvider::isValidRasterFileName( fileNameQString, retErrMsg );
236 const QFileInfo fi(
name );
242 t = fi.lastModified();
269 if ( !mDataProvider )
return 0;
277 if ( !mDataProvider )
return QString();
285 if ( !mDataProvider )
294 if ( !mDataProvider )
298 for (
int bandNo = 1; bandNo <=
bandCount(); ++bandNo )
326 return mDataProvider;
333 return mDataProvider;
371 bool restoreOldResamplingStage =
false;
379 if ( mDataProvider &&
384 restoreOldResamplingStage =
true;
393 drawer.
draw( theQPainter, rasterViewPort, qgsMapToPixel );
395 if ( restoreOldResamplingStage )
400 QgsDebugMsgLevel( QStringLiteral(
"total raster draw time (ms): %1" ).arg( time.elapsed(), 5 ), 4 );
415 if ( !mDataProvider )
419 QString myMetadata = QStringLiteral(
"<html><head></head>\n<body>\n" );
424 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Information from provider" ) + QStringLiteral(
"</h1>\n<hr>\n" ) + QStringLiteral(
"<table class=\"list-view\">\n" );
426 myMetadata += QStringLiteral(
"\n" ) %
428 QStringLiteral(
"<tr><td class=\"highlight\">" ) % tr(
"Extent" ) % QStringLiteral(
"</td><td>" ) %
extent().
toString() % QStringLiteral(
"</td></tr>\n" ) %
431 QStringLiteral(
"<tr><td class=\"highlight\">" ) % tr(
"Width" ) % QStringLiteral(
"</td><td>" );
433 myMetadata += QString::number(
width() );
435 myMetadata += tr(
"n/a" );
436 myMetadata += QStringLiteral(
"</td></tr>\n" ) %
439 QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Height" ) + QStringLiteral(
"</td><td>" );
441 myMetadata += QString::number(
height() );
443 myMetadata += tr(
"n/a" );
444 myMetadata += QStringLiteral(
"</td></tr>\n" ) %
447 QStringLiteral(
"<tr><td class=\"highlight\">" ) % tr(
"Data type" ) % QStringLiteral(
"</td><td>" );
452 myMetadata += tr(
"Byte - Eight bit unsigned integer" );
455 myMetadata += tr(
"Int8 - Eight bit signed integer" );
458 myMetadata += tr(
"UInt16 - Sixteen bit unsigned integer " );
461 myMetadata += tr(
"Int16 - Sixteen bit signed integer " );
464 myMetadata += tr(
"UInt32 - Thirty two bit unsigned integer " );
467 myMetadata += tr(
"Int32 - Thirty two bit signed integer " );
470 myMetadata += tr(
"Float32 - Thirty two bit floating point " );
473 myMetadata += tr(
"Float64 - Sixty four bit floating point " );
476 myMetadata += tr(
"CInt16 - Complex Int16 " );
479 myMetadata += tr(
"CInt32 - Complex Int32 " );
482 myMetadata += tr(
"CFloat32 - Complex Float32 " );
485 myMetadata += tr(
"CFloat64 - Complex Float64 " );
488 myMetadata += tr(
"Could not determine raster data type." );
490 myMetadata += QStringLiteral(
"</td></tr>\n" ) %
496 QStringLiteral(
"</table>\n<br><br>" );
502 myMetadata += QStringLiteral(
"<h1>" ) % tr(
"Identification" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
504 QStringLiteral(
"<br><br>\n" ) %
507 QStringLiteral(
"<h1>" ) % tr(
"Extent" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
509 QStringLiteral(
"<br><br>\n" ) %
512 QStringLiteral(
"<h1>" ) % tr(
"Access" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
514 QStringLiteral(
"<br><br>\n" ) %
517 QStringLiteral(
"</table>\n<br><br><h1>" ) % tr(
"Bands" ) % QStringLiteral(
"</h1>\n<hr>\n<table class=\"list-view\">\n" ) %
520 QStringLiteral(
"<tr><td class=\"highlight\">" ) % tr(
"Band count" ) % QStringLiteral(
"</td><td>" ) % QString::number(
bandCount() ) % QStringLiteral(
"</td></tr>\n" );
523 myMetadata += QStringLiteral(
"</table>\n<br><table width=\"100%\" class=\"tabular-view\">\n" ) %
524 QStringLiteral(
"<tr><th>" ) % tr(
"Number" ) % QStringLiteral(
"</th><th>" ) % tr(
"Band" ) % QStringLiteral(
"</th><th>" ) % tr(
"NoData" ) % QStringLiteral(
"</th><th>" ) %
525 tr(
"Min" ) % QStringLiteral(
"</th><th>" ) % tr(
"Max" ) % QStringLiteral(
"</th></tr>\n" );
532 rowClass = QStringLiteral(
"class=\"odd-row\"" );
534 myMetadata += QStringLiteral(
"<tr " ) % rowClass % QStringLiteral(
"><td>" ) % QString::number( i ) % QStringLiteral(
"</td><td>" ) %
bandName( i ) % QStringLiteral(
"</td><td>" );
537 myMetadata += QString::number(
dataProvider()->sourceNoDataValue( i ) );
539 myMetadata += tr(
"n/a" );
540 myMetadata += QLatin1String(
"</td>" );
545 myMetadata += QStringLiteral(
"<td>" ) % QString::number( myRasterBandStats.
minimumValue,
'f', 10 ) % QStringLiteral(
"</td>" ) %
546 QStringLiteral(
"<td>" ) % QString::number( myRasterBandStats.
maximumValue,
'f', 10 ) % QStringLiteral(
"</td>" );
550 myMetadata += QStringLiteral(
"<td>" ) % tr(
"n/a" ) % QStringLiteral(
"</td><td>" ) % tr(
"n/a" ) % QStringLiteral(
"</td>" );
553 myMetadata += QLatin1String(
"</tr>\n" );
557 myMetadata += QStringLiteral(
"</table>\n<br><br>" ) %
560 QStringLiteral(
"<h1>" ) % tr(
"Contacts" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
562 QStringLiteral(
"<br><br>\n" ) %
565 QStringLiteral(
"<h1>" ) % tr(
"References" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
567 QStringLiteral(
"<br><br>\n" ) %
570 QStringLiteral(
"<h1>" ) % tr(
"History" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
572 QStringLiteral(
"<br><br>\n" ) %
574 QStringLiteral(
"\n</body>\n</html>\n" );
599 if ( mDataProvider &&
604 const QList<QgsColorRampShader::ColorRampItem> myColorRampItemList = mDataProvider->
colorTable( bandNumber );
605 if ( !myColorRampItemList.isEmpty() )
611 const int mySize = 100;
612 QPixmap myPalettePixmap( mySize, mySize );
613 QPainter myQPainter( &myPalettePixmap );
615 QImage myQImage = QImage( mySize, mySize, QImage::Format_RGB32 );
617 myPalettePixmap.fill();
619 const double myStep = (
static_cast< double >( myColorRampItemList.size() ) - 1 ) /
static_cast< double >( mySize * mySize );
620 double myValue = 0.0;
621 for (
int myRow = 0; myRow < mySize; myRow++ )
623 QRgb *myLineBuffer =
reinterpret_cast< QRgb *
>( myQImage.scanLine( myRow ) );
624 for (
int myCol = 0; myCol < mySize; myCol++ )
626 myValue = myStep *
static_cast< double >( myCol + myRow * mySize );
628 myShader.
shade( myValue, &c1, &c2, &c3, &c4 );
629 myLineBuffer[ myCol ] = qRgba( c1, c2, c3, c4 );
633 myQPainter.drawImage( 0, 0, myQImage );
634 return myPalettePixmap;
636 const QPixmap myNullPixmap;
642 const QPixmap myNullPixmap;
664 if ( mDataProvider &&
676 if ( mDataProvider &&
688 if ( !mPipe->renderer() || mPipe->renderer()->opacity() ==
opacity )
691 mPipe->renderer()->setOpacity(
opacity );
700 return mPipe->renderer() ? mPipe->renderer()->opacity() : 1.0;
703void QgsRasterLayer::init()
726 mPipe = std::make_unique< QgsRasterPipe >();
727 mDataProvider =
nullptr;
743 mDataProvider = qobject_cast< QgsRasterDataProvider * >(
mPreloadedProvider.release() );
747 std::unique_ptr< QgsScopedRuntimeProfile > profile;
749 profile = std::make_unique< QgsScopedRuntimeProfile >( tr(
"Create %1 provider" ).arg( provider ), QStringLiteral(
"projectload" ) );
754 if ( !mDataProvider )
761 mDataProvider->setParent(
this );
764 mPipe->set( mDataProvider );
765 if ( !mDataProvider->
isValid() )
775 QgsDebugMsgLevel( QStringLiteral(
"Set Data provider QgsLayerMetadata identifier[%1]" ).arg(
metadata().identifier() ), 4 );
778 if ( provider == QLatin1String(
"gdal" ) )
853 QString errorMessage;
857 errorMessage.clear();
858 QgsDebugMsgLevel(
"Native Raster Raster Attribute Table read failed " + errorMessage, 2 );
859 if ( QFile::exists( mDataProvider->
dataSourceUri( ) +
".vat.dbf" ) )
861 std::unique_ptr<QgsRasterAttributeTable> rat = std::make_unique<QgsRasterAttributeTable>();
862 hasRat = rat->readFromFile( mDataProvider->
dataSourceUri( ) +
".vat.dbf", &errorMessage );
865 if ( rat->isValid( &errorMessage ) )
872 QgsDebugMsgLevel(
"DBF Raster Attribute Table is not valid, skipping: " + errorMessage, 2 );
877 QgsDebugMsgLevel(
"DBF Raster Attribute Table read failed " + errorMessage, 2 );
886 switch ( mRasterType )
904 const QList<QgsColorRampShader::ColorRampItem> colorTable = mDataProvider->
colorTable( 1 );
936 for (
int bandNo = 1; bandNo <= mDataProvider->
bandCount(); bandNo++ )
940 if (
auto *lRenderer = mPipe->renderer() )
942 lRenderer->setAlphaBand( bandNo );
963 QString resampling = settings.
value( QStringLiteral(
"/Raster/defaultZoomedInResampling" ), QStringLiteral(
"nearest neighbour" ) ).toString();
964 if ( resampling == QLatin1String(
"bilinear" ) )
969 else if ( resampling == QLatin1String(
"cubic" ) )
974 resampling = settings.
value( QStringLiteral(
"/Raster/defaultZoomedOutResampling" ), QStringLiteral(
"nearest neighbour" ) ).toString();
975 if ( resampling == QLatin1String(
"bilinear" ) )
998 mPipe->set( projector );
1050void QgsRasterLayer::setDataSourcePrivate(
const QString &dataSource,
const QString &baseName,
const QString &provider,
1055 const bool hadRenderer(
renderer() );
1057 QDomImplementation domImplementation;
1058 QDomDocumentType documentType;
1061 bool loadDefaultStyleFlag =
false;
1064 loadDefaultStyleFlag =
true;
1068 if ( hadRenderer && ! loadDefaultStyleFlag )
1070 documentType = domImplementation.createDocumentType(
1071 QStringLiteral(
"qgis" ), QStringLiteral(
"http://mrcc.com/qgis.dtd" ), QStringLiteral(
"SYSTEM" ) );
1073 QDomDocument doc = QDomDocument( documentType );
1074 QDomElement styleElem = doc.createElement( QStringLiteral(
"qgis" ) );
1075 styleElem.setAttribute( QStringLiteral(
"version" ),
Qgis::version() );
1077 if ( !
writeSymbology( styleElem, doc, errorMsg, writeContext ) )
1079 QgsDebugError( QStringLiteral(
"Could not store symbology for layer %1: %2" )
1085 doc.appendChild( styleElem );
1087 mOriginalStyleDocument = doc;
1088 mOriginalStyleElement = styleElem;
1092 if ( mDataProvider )
1093 closeDataProvider();
1097 for (
int i = mPipe->size() - 1; i >= 0; --i )
1107 if ( mDataProvider )
1113 bool defaultLoadedFlag =
false;
1114 bool restoredStyle =
false;
1115 if ( loadDefaultStyleFlag )
1119 else if ( !mOriginalStyleElement.isNull() )
1122 if ( !
readSymbology( mOriginalStyleElement, errorMsg, readContext ) )
1124 QgsDebugError( QStringLiteral(
"Could not restore symbology for layer %1: %2" )
1131 restoredStyle =
true;
1138 if ( !defaultLoadedFlag && !restoredStyle )
1145void QgsRasterLayer::writeRasterAttributeTableExternalPaths( QDomNode &layerNode, QDomDocument &doc,
const QgsReadWriteContext &context )
const
1151 QDomElement elem = doc.createElement( QStringLiteral(
"FileBasedAttributeTables" ) );
1152 for (
int bandNo = 1; bandNo <=
bandCount(); bandNo++ )
1156 QDomElement ratElem = doc.createElement( QStringLiteral(
"AttributeTable" ) );
1157 ratElem.setAttribute( QStringLiteral(
"band" ), bandNo );
1158 ratElem.setAttribute( QStringLiteral(
"path" ), context.
pathResolver().
writePath( rat->filePath( ) ) );
1159 elem.appendChild( ratElem );
1162 layerNode.appendChild( elem );
1166void QgsRasterLayer::readRasterAttributeTableExternalPaths(
const QDomNode &layerNode,
QgsReadWriteContext &context )
const
1168 const QDomElement ratsElement = layerNode.firstChildElement( QStringLiteral(
"FileBasedAttributeTables" ) );
1169 if ( !ratsElement.isNull() && ratsElement.childNodes().count() > 0 )
1171 const QDomNodeList ratElements { ratsElement.childNodes() };
1172 for (
int idx = 0; idx < ratElements.count(); idx++ )
1174 const QDomNode ratElement { ratElements.at( idx ) };
1175 if ( ratElement.attributes().contains( QStringLiteral(
"band" ) )
1176 && ratElement.attributes().contains( QStringLiteral(
"path" ) ) )
1179 const int band { ratElement.attributes().namedItem( QStringLiteral(
"band" ) ).nodeValue().toInt( &ok ) };
1182 if ( ! ok || band <= 0 || band >
bandCount() )
1184 QgsMessageLog::logMessage( tr(
"Error reading raster attribute table: invalid band %1." ).arg( band ), tr(
"Raster" ) );
1188 const QString path { context.
pathResolver().
readPath( ratElement.attributes().namedItem( QStringLiteral(
"path" ) ).nodeValue() ) };
1189 if ( ! QFile::exists( path ) )
1191 QgsMessageLog::logMessage( tr(
"Error loading raster attribute table, file not found: %1." ).arg( path ), tr(
"Raster" ) );
1195 std::unique_ptr<QgsRasterAttributeTable> rat = std::make_unique<QgsRasterAttributeTable>();
1196 QString errorMessage;
1197 if ( ! rat->readFromFile( path, &errorMessage ) )
1199 QgsMessageLog::logMessage( tr(
"Error loading raster attribute table from path %1: %2" ).arg( path, errorMessage ), tr(
"Raster" ) );
1210void QgsRasterLayer::closeDataProvider()
1215 mPipe->remove( mDataProvider );
1216 mDataProvider =
nullptr;
1224 double &min,
double &max )
1228 min = std::numeric_limits<double>::quiet_NaN();
1229 max = std::numeric_limits<double>::quiet_NaN();
1230 if ( !mDataProvider )
1240 switch ( mDataProvider->
dataType( band ) )
1250 myRasterBandStats.
minimumValue = std::numeric_limits<int8_t>::lowest();
1251 myRasterBandStats.
maximumValue = std::numeric_limits<int8_t>::max();
1257 myRasterBandStats.
maximumValue = std::numeric_limits<uint16_t>::max();
1263 myRasterBandStats.
maximumValue = std::numeric_limits<uint32_t>::max();
1269 myRasterBandStats.
minimumValue = std::numeric_limits<int16_t>::lowest();
1270 myRasterBandStats.
maximumValue = std::numeric_limits<int16_t>::max();
1276 myRasterBandStats.
minimumValue = std::numeric_limits<int32_t>::lowest();
1277 myRasterBandStats.
maximumValue = std::numeric_limits<int32_t>::max();
1283 myRasterBandStats.
minimumValue = std::numeric_limits<float_t>::lowest();
1284 myRasterBandStats.
maximumValue = std::numeric_limits<float_t>::max();
1290 myRasterBandStats.
minimumValue = std::numeric_limits<double_t>::lowest();
1291 myRasterBandStats.
maximumValue = std::numeric_limits<double_t>::max();
1316 QgsDebugMsgLevel( QStringLiteral(
"myLower = %1 myUpper = %2" ).arg( myLower ).arg( myUpper ), 4 );
1319 QgsDebugMsgLevel( QStringLiteral(
"band = %1 min = %2 max = %3" ).arg( band ).arg( min ).arg( max ), 4 );
1327 return mDataProvider ? mDataProvider->
ignoreExtents() :
false;
1334 return mTemporalProperties;
1341 return mElevationProperties;
1352 generateLookupTableFlag,
1353 mPipe->renderer() );
1360 bool generateLookupTableFlag,
1366 if ( !rasterRenderer || !mDataProvider )
1372 QList<QgsContrastEnhancement *> myEnhancements;
1378 const QString rendererType = rasterRenderer->
type();
1379 if ( rendererType == QLatin1String(
"singlebandgray" ) )
1382 if ( !myGrayRenderer )
1387 myRasterRenderer = myGrayRenderer;
1390 else if ( rendererType == QLatin1String(
"multibandcolor" ) )
1393 if ( !myMultiBandRenderer )
1398 myRasterRenderer = myMultiBandRenderer;
1401 else if ( rendererType == QLatin1String(
"singlebandpseudocolor" ) )
1404 if ( !myPseudoColorRenderer )
1408 myBands << myPseudoColorRenderer->
inputBand();
1409 myRasterRenderer = myPseudoColorRenderer;
1410 myMinMaxOrigin = myPseudoColorRenderer->
minMaxOrigin();
1417 for (
const int myBand : std::as_const( myBands ) )
1423 myEnhancement->setContrastEnhancementAlgorithm(
algorithm, generateLookupTableFlag );
1429 if ( rendererType == QLatin1String(
"singlebandpseudocolor" ) )
1432 if ( ! myPseudoColorRenderer )
1440 bool minMaxChanged {
false };
1441 if ( ! std::isnan( min ) )
1444 minMaxChanged =
true;
1447 if ( ! std::isnan( max ) )
1450 minMaxChanged =
true;
1453 if ( minMaxChanged && myPseudoColorRenderer->
shader() )
1456 if ( colorRampShader )
1464 myEnhancement->setMinimumValue( min );
1465 myEnhancement->setMaximumValue( max );
1466 myEnhancements.append( myEnhancement.release() );
1471 myEnhancements.append(
nullptr );
1476 if ( rendererType == QLatin1String(
"singlebandgray" ) && myGrayRenderer )
1480 else if ( rendererType == QLatin1String(
"multibandcolor" ) && myMultiBandRenderer )
1488 qDeleteAll( myEnhancements );
1496 if ( myRasterRenderer )
1501 if ( rasterRenderer ==
renderer() )
1518 ce = singleBandRenderer->contrastEnhancement();
1556 if ( !
isValid() || !mDataProvider )
1558 QgsDebugMsgLevel( QStringLiteral(
"invoked with invalid layer or null mDataProvider" ), 3 );
1559 return customProperty( QStringLiteral(
"storedSubsetString" ) ).toString();
1572 if ( !
isValid() || !mDataProvider )
1574 QgsDebugMsgLevel( QStringLiteral(
"invoked with invalid layer or null mDataProvider or while editing" ), 3 );
1595 QList<double> minValues;
1596 QList<double> maxValues;
1606 minValues.append( min );
1607 maxValues.append( max );
1626 QString defaultLimits;
1631 key = QStringLiteral(
"singleBand" );
1641 key = QStringLiteral(
"multiBandSingleByte" );
1649 key = QStringLiteral(
"multiBandMultiByte" );
1657 if ( key.isEmpty() )
1659 QgsDebugMsgLevel( QStringLiteral(
"No default contrast enhancement for this drawing style" ), 2 );
1666 const QString myAlgorithmString = mySettings.value(
"/Raster/defaultContrastEnhancementAlgorithm/" + key, defaultAlg ).toString();
1671 const QString myLimitsString = mySettings.value(
"/Raster/defaultContrastEnhancementLimits/" + key, defaultLimits ).toString();
1697 if ( mDataProvider )
1699 QgsDebugMsgLevel( QStringLiteral(
"About to mDataProvider->setLayerOrder(layers)." ), 4 );
1709 if ( mDataProvider )
1711 QgsDebugMsgLevel( QStringLiteral(
"About to mDataProvider->setSubLayerVisibility(name, vis)." ), 4 );
1720 if ( !mDataProvider )
1729 if (
auto *lRenderer = mPipe->renderer() )
1731 if ( !lRenderer->accept( visitor ) )
1741 return mLabelsEnabled &&
static_cast< bool >( mLabeling );
1748 mLabelsEnabled = enabled;
1755 return mLabeling.get();
1762 return mLabeling.get();
1780 Q_UNUSED( errorMessage )
1782 QVariantMap localProps = QVariantMap( props );
1792 QDomElement constraintElem = doc.createElement( QStringLiteral(
"sld:LayerFeatureConstraints" ) );
1793 node.appendChild( constraintElem );
1795 const QDomElement featureTypeConstraintElem = doc.createElement( QStringLiteral(
"sld:FeatureTypeConstraint" ) );
1796 constraintElem.appendChild( featureTypeConstraintElem );
1798 QDomElement userStyleElem = doc.createElement( QStringLiteral(
"sld:UserStyle" ) );
1799 node.appendChild( userStyleElem );
1801 if ( !
name().isEmpty() )
1803 QDomElement nameElem = doc.createElement( QStringLiteral(
"sld:Name" ) );
1804 nameElem.appendChild( doc.createTextNode(
name() ) );
1805 userStyleElem.appendChild( nameElem );
1811 QDomElement abstractElem = doc.createElement( QStringLiteral(
"sld:Abstract" ) );
1812 abstractElem.appendChild( doc.createTextNode(
abstract ) );
1813 userStyleElem.appendChild( abstractElem );
1817 if ( !
title.isEmpty() )
1819 QDomElement titleElem = doc.createElement( QStringLiteral(
"sld:Title" ) );
1820 titleElem.appendChild( doc.createTextNode(
title ) );
1821 userStyleElem.appendChild( titleElem );
1824 QDomElement featureTypeStyleElem = doc.createElement( QStringLiteral(
"sld:FeatureTypeStyle" ) );
1825 userStyleElem.appendChild( featureTypeStyleElem );
1835 QDomElement typeStyleNameElem = doc.createElement( QStringLiteral(
"sld:Name" ) );
1836 featureTypeStyleElem.appendChild( typeStyleNameElem );
1839 QDomElement typeStyleRuleElem = doc.createElement( QStringLiteral(
"sld:Rule" ) );
1840 featureTypeStyleElem.appendChild( typeStyleRuleElem );
1848 QDomElement minScaleElem = doc.createElement( QStringLiteral(
"sld:MinScaleDenominator" ) );
1849 minScaleElem.appendChild( doc.createTextNode( QString::number(
maximumScale() ) ) );
1850 typeStyleRuleElem.appendChild( minScaleElem );
1853 QDomElement maxScaleElem = doc.createElement( QStringLiteral(
"sld:MaxScaleDenominator" ) );
1854 maxScaleElem.appendChild( doc.createTextNode( QString::number(
minimumScale() ) ) );
1855 typeStyleRuleElem.appendChild( maxScaleElem );
1859 mPipe->renderer()->toSld( doc, typeStyleRuleElem, localProps );
1864 const QDomNodeList elements = typeStyleRuleElem.elementsByTagName( QStringLiteral(
"sld:RasterSymbolizer" ) );
1865 if ( elements.size() != 0 )
1868 QDomElement rasterSymbolizerElem = elements.at( 0 ).toElement();
1871 auto vendorOptionWriter = [&]( QString
name, QString value )
1873 QDomElement vendorOptionElem = doc.createElement( QStringLiteral(
"sld:VendorOption" ) );
1874 vendorOptionElem.setAttribute( QStringLiteral(
"name" ),
name );
1875 vendorOptionElem.appendChild( doc.createTextNode( value ) );
1876 rasterSymbolizerElem.appendChild( vendorOptionElem );
1881 vendorOptionWriter( QStringLiteral(
"invertColors" ), QString::number( 1 ) );
1891 property = QStringLiteral(
"lightness" );
1894 property = QStringLiteral(
"luminosity" );
1897 property = QStringLiteral(
"average" );
1903 if ( !property.isEmpty() )
1904 vendorOptionWriter( QStringLiteral(
"grayScale" ), property );
1910 vendorOptionWriter( QStringLiteral(
"colorizeOn" ), QString::number(
hueSaturationFilter()->colorizeOn() ) );
1911 vendorOptionWriter( QStringLiteral(
"colorizeRed" ), QString::number(
hueSaturationFilter()->colorizeColor().red() ) );
1912 vendorOptionWriter( QStringLiteral(
"colorizeGreen" ), QString::number(
hueSaturationFilter()->colorizeColor().green() ) );
1913 vendorOptionWriter( QStringLiteral(
"colorizeBlue" ), QString::number(
hueSaturationFilter()->colorizeColor().blue() ) );
1915 vendorOptionWriter( QStringLiteral(
"colorizeStrength" ), QString::number(
hueSaturationFilter()->colorizeStrength() / 100.0 ) );
1916 vendorOptionWriter( QStringLiteral(
"saturation" ), QString::number(
hueSaturationFilter()->colorizeColor().saturationF() ) );
1925 const double sF = ( s - ( -100.0 ) ) / ( 100.0 - ( -100.0 ) );
1926 vendorOptionWriter( QStringLiteral(
"saturation" ), QString::number( sF ) );
1935 const double bF = ( b - ( -255.0 ) ) / ( 255.0 - ( -255.0 ) );
1936 vendorOptionWriter( QStringLiteral(
"brightness" ), QString::number( bF ) );
1944 const double cF = (
c - ( -100.0 ) ) / ( 100.0 - ( -100.0 ) );
1945 vendorOptionWriter( QStringLiteral(
"contrast" ), QString::number( cF ) );
1959 if ( newProps.contains( QStringLiteral(
"contrast" ) ) )
1962 double contrast = newProps[ QStringLiteral(
"contrast" ) ].toDouble();
1963 double percentage = ( contrast - ( -100.0 ) ) / ( 100.0 - ( -100.0 ) );
1964 if ( percentage <= 0.5 )
1967 gamma = percentage / 0.5;
1974 QDomElement globalContrastEnhancementElem = doc.createElement( QStringLiteral(
"sld:ContrastEnhancement" ) );
1975 rasterSymolizerElem.appendChild( globalContrastEnhancementElem );
1977 QDomElement gammaValueElem = doc.createElement( QStringLiteral(
"sld:GammaValue" ) );
1978 gammaValueElem.appendChild( doc.createTextNode( QString::number( gamma ) ) );
1979 globalContrastEnhancementElem.appendChild( gammaValueElem );
2006 return mPipe->renderer();
2013 return mPipe->resampleFilter();
2020 return mPipe->brightnessFilter();
2027 return mPipe->hueSaturationFilter();
2045 if ( mDataProvider )
2054 if ( ! mDataProvider )
2055 return QStringList();
2065 QImage image( size, format );
2070 if ( image.format() == QImage::Format_Indexed8 )
2072 image.setColor( 0, bgColor.rgba() );
2077 image.fill( bgColor );
2082 double mapUnitsPerPixel;
2088 mapUnitsPerPixel =
extent.
width() / image.width();
2089 y = ( image.height() -
extent.
height() / mapUnitsPerPixel ) / 2;
2094 x = ( image.width() -
extent.
width() / mapUnitsPerPixel ) / 2;
2097 const double pixelWidth =
extent.
width() / mapUnitsPerPixel;
2098 const double pixelHeight =
extent.
height() / mapUnitsPerPixel;
2102 rasterViewPort->
mWidth = image.width();
2103 rasterViewPort->
mHeight = image.height();
2111 QPainter *painter =
new QPainter( &image );
2112 draw( painter, rasterViewPort, mapToPixel );
2113 delete rasterViewPort;
2127 Q_UNUSED( errorMessage )
2130 QDomElement rasterRendererElem;
2132 const QDomElement layerElement = layer_node.toElement();
2142 QDomNode pipeNode = layer_node.firstChildElement( QStringLiteral(
"pipe" ) );
2143 if ( pipeNode.isNull() )
2145 pipeNode = layer_node;
2149 if ( !layer_node.firstChildElement( QStringLiteral(
"rasterproperties" ) ).isNull() )
2152 QDomNode layerNodeCopy = layer_node.cloneNode();
2153 QDomDocument doc = layerNodeCopy.ownerDocument();
2154 QDomElement rasterPropertiesElem = layerNodeCopy.firstChildElement( QStringLiteral(
"rasterproperties" ) );
2157 rasterRendererElem = layerNodeCopy.firstChildElement( QStringLiteral(
"rasterrenderer" ) );
2162 rasterRendererElem = pipeNode.firstChildElement( QStringLiteral(
"rasterrenderer" ) );
2165 if ( !rasterRendererElem.isNull() )
2167 const QString rendererType = rasterRendererElem.attribute( QStringLiteral(
"type" ) );
2181 const QDomElement brightnessElem = pipeNode.firstChildElement( QStringLiteral(
"brightnesscontrast" ) );
2182 if ( !brightnessElem.isNull() )
2192 const QDomElement hueSaturationElem = pipeNode.firstChildElement( QStringLiteral(
"huesaturation" ) );
2193 if ( !hueSaturationElem.isNull() )
2203 const QDomElement resampleElem = pipeNode.firstChildElement( QStringLiteral(
"rasterresampler" ) );
2204 if ( !resampleElem.isNull() )
2210 if ( mDataProvider )
2212 const QDomElement providerElem = pipeNode.firstChildElement( QStringLiteral(
"provider" ) );
2213 if ( !providerElem.isNull() )
2215 mDataProvider->
readXml( providerElem );
2220 const QDomNode resamplingStageElement = pipeNode.namedItem( QStringLiteral(
"resamplingStage" ) );
2221 if ( !resamplingStageElement.isNull() )
2223 const QDomElement e = resamplingStageElement.toElement();
2224 if ( e.text() == QLatin1String(
"provider" ) )
2226 else if ( e.text() == QLatin1String(
"resamplingFilter" ) )
2231 const QDomNode blendModeNode = layer_node.namedItem( QStringLiteral(
"blendMode" ) );
2232 if ( !blendModeNode.isNull() )
2234 const QDomElement e = blendModeNode.toElement();
2238 const QDomElement elemDataDefinedProperties = layer_node.firstChildElement( QStringLiteral(
"pipe-data-defined-properties" ) );
2239 if ( !elemDataDefinedProperties.isNull() )
2244 if ( categories.testFlag(
Labeling ) )
2248 QDomElement labelingElement = layer_node.firstChildElement( QStringLiteral(
"labeling" ) );
2249 if ( !labelingElement.isNull() )
2252 mLabelsEnabled = layer_node.toElement().attribute( QStringLiteral(
"labelsEnabled" ), QStringLiteral(
"0" ) ).toInt();
2257 if ( categories.testFlag(
MapTips ) )
2259 QDomElement mapTipElem = layer_node.namedItem( QStringLiteral(
"mapTip" ) ).toElement();
2261 setMapTipsEnabled( mapTipElem.attribute( QStringLiteral(
"enabled" ), QStringLiteral(
"1" ) ).toInt() == 1 );
2267 readRasterAttributeTableExternalPaths( layer_node, context );
2280 return readSymbology( node, errorMessage, context, categories );
2291 const QDomNode pkeyNode = layer_node.namedItem( QStringLiteral(
"provider" ) );
2293 if ( pkeyNode.isNull() )
2299 const QDomElement pkeyElt = pkeyNode.toElement();
2313 const QDomNode rpNode = layer_node.namedItem( QStringLiteral(
"rasterproperties" ) );
2319 if ( !
mDataSource.contains( QLatin1String(
"crs=" ) ) && !
mDataSource.contains( QLatin1String(
"format=" ) ) )
2321 QgsDebugMsgLevel( QStringLiteral(
"Old WMS URI format detected -> adding params" ), 4 );
2324 QDomElement layerElement = rpNode.firstChildElement( QStringLiteral(
"wmsSublayer" ) );
2325 while ( !layerElement.isNull() )
2330 uri.
setParam( QStringLiteral(
"layers" ), layerElement.namedItem( QStringLiteral(
"name" ) ).toElement().text() );
2333 uri.
setParam( QStringLiteral(
"styles" ), layerElement.namedItem( QStringLiteral(
"style" ) ).toElement().text() );
2335 layerElement = layerElement.nextSiblingElement( QStringLiteral(
"wmsSublayer" ) );
2339 uri.
setParam( QStringLiteral(
"format" ), rpNode.namedItem( QStringLiteral(
"wmsFormat" ) ).toElement().text() );
2343 uri.
setParam( QStringLiteral(
"crs" ),
crs().authid() );
2356 const QDomNode extentNode = layer_node.namedItem( QStringLiteral(
"extent" ) );
2357 if ( !extentNode.isNull() )
2369 mOriginalStyleElement = layer_node.namedItem( QStringLiteral(
"originalStyle" ) ).firstChildElement();
2370 if ( mOriginalStyleElement.isNull() )
2371 mOriginalStyleElement = layer_node.toElement();
2372 mOriginalStyleDocument = layer_node.ownerDocument();
2374 if ( ! mDataProvider )
2398 QDomNode stampNode = layer_node.namedItem(
"timestamp" );
2399 if ( !stampNode.isNull() )
2401 QDateTime stamp = QDateTime::fromString( stampNode.toElement().text(), Qt::ISODate );
2403 if ( stamp < mDataProvider->dataTimestamp() )
2406 closeDataProvider();
2409 if ( !
isValid() )
return false;
2415 const QDomElement noDataElement = layer_node.firstChildElement( QStringLiteral(
"noData" ) );
2417 const QDomNodeList noDataBandList = noDataElement.elementsByTagName( QStringLiteral(
"noDataList" ) );
2419 for (
int i = 0; mDataProvider && i < noDataBandList.size(); ++i )
2421 const QDomElement bandElement = noDataBandList.at( i ).toElement();
2423 const int bandNo = bandElement.attribute( QStringLiteral(
"bandNo" ) ).toInt( &ok );
2425 if ( ok && ( bandNo > 0 ) && ( bandNo <= mDataProvider->
bandCount() ) )
2427 mDataProvider->
setUseSourceNoDataValue( bandNo, bandElement.attribute( QStringLiteral(
"useSrcNoData" ) ).toInt() );
2430 const QDomNodeList rangeList = bandElement.elementsByTagName( QStringLiteral(
"noDataRange" ) );
2432 myNoDataRangeList.reserve( rangeList.size() );
2433 for (
int j = 0; j < rangeList.size(); ++j )
2435 const QDomElement rangeElement = rangeList.at( j ).toElement();
2436 const QgsRasterRange myNoDataRange( rangeElement.attribute( QStringLiteral(
"min" ) ).toDouble(),
2437 rangeElement.attribute( QStringLiteral(
"max" ) ).toDouble() );
2438 QgsDebugMsgLevel( QStringLiteral(
"min = %1 %2" ).arg( rangeElement.attribute(
"min" ) ).arg( myNoDataRange.
min() ), 4 );
2439 myNoDataRangeList << myNoDataRange;
2445 readRasterAttributeTableExternalPaths( layer_node, context );
2457 Q_UNUSED( errorMessage )
2460 QDomElement layerElement = layer_node.toElement();
2464 if ( categories.testFlag(
Labeling ) )
2468 QDomElement labelingElement = mLabeling->save( document, context );
2469 layerElement.appendChild( labelingElement );
2471 if ( mLabelsEnabled )
2472 layerElement.setAttribute( QStringLiteral(
"labelsEnabled" ), QStringLiteral(
"1" ) );
2476 if ( categories.testFlag(
MapTips ) )
2478 QDomElement mapTipElem = document.createElement( QStringLiteral(
"mapTip" ) );
2479 mapTipElem.setAttribute( QStringLiteral(
"enabled" ),
mapTipsEnabled() );
2480 QDomText mapTipText = document.createTextNode(
mapTipTemplate() );
2481 mapTipElem.appendChild( mapTipText );
2482 layer_node.toElement().appendChild( mapTipElem );
2488 writeRasterAttributeTableExternalPaths( layer_node, document, context );
2496 QDomElement pipeElement = document.createElement( QStringLiteral(
"pipe" ) );
2498 for (
int i = 0; i < mPipe->size(); i++ )
2501 if ( !interface )
continue;
2502 interface->writeXml( document, pipeElement );
2505 QDomElement elemDataDefinedProperties = document.createElement( QStringLiteral(
"pipe-data-defined-properties" ) );
2507 layer_node.appendChild( elemDataDefinedProperties );
2509 QDomElement resamplingStageElement = document.createElement( QStringLiteral(
"resamplingStage" ) );
2511 resamplingStageElement.appendChild( resamplingStageText );
2512 pipeElement.appendChild( resamplingStageElement );
2514 layer_node.appendChild( pipeElement );
2516 if ( !
isValid() && !mOriginalStyleElement.isNull() )
2518 QDomElement originalStyleElement = document.createElement( QStringLiteral(
"originalStyle" ) );
2519 originalStyleElement.appendChild( mOriginalStyleElement );
2520 layer_node.appendChild( originalStyleElement );
2524 QDomElement blendModeElement = document.createElement( QStringLiteral(
"blendMode" ) );
2526 blendModeElement.appendChild( blendModeText );
2527 layer_node.appendChild( blendModeElement );
2538 return writeSymbology( node, doc, errorMessage, context, categories );
2542 QDomDocument &document,
2547 if ( !mDataProvider )
2552 QDomElement mapLayerNode = layer_node.toElement();
2554 if ( mapLayerNode.isNull() ||
"maplayer" != mapLayerNode.nodeName() )
2564 QDomElement provider = document.createElement( QStringLiteral(
"provider" ) );
2565 const QDomText providerText = document.createTextNode(
mProviderKey );
2566 provider.appendChild( providerText );
2567 layer_node.appendChild( provider );
2570 QDomElement noData = document.createElement( QStringLiteral(
"noData" ) );
2572 for (
int bandNo = 1; bandNo <= mDataProvider->
bandCount(); bandNo++ )
2574 QDomElement noDataRangeList = document.createElement( QStringLiteral(
"noDataList" ) );
2575 noDataRangeList.setAttribute( QStringLiteral(
"bandNo" ), bandNo );
2576 noDataRangeList.setAttribute( QStringLiteral(
"useSrcNoData" ), mDataProvider->
useSourceNoDataValue( bandNo ) );
2578 const auto constUserNoDataValues = mDataProvider->
userNoDataValues( bandNo );
2581 QDomElement noDataRange = document.createElement( QStringLiteral(
"noDataRange" ) );
2585 noDataRangeList.appendChild( noDataRange );
2588 noData.appendChild( noDataRangeList );
2591 if ( noData.hasChildNodes() )
2593 layer_node.appendChild( noData );
2597 writeRasterAttributeTableExternalPaths( layer_node, document, context );
2605 return writeSymbology( layer_node, document, errorMsg, context );
2627 if ( !mDataProvider )
return 0;
2628 return mDataProvider->
xSize();
2635 if ( !mDataProvider )
return 0;
2636 return mDataProvider->
ySize();
2643 mPipe->setResamplingStage( stage );
2650 return mPipe->resamplingStage();
2653bool QgsRasterLayer::update()
2662 closeDataProvider();
The Qgis class provides global constants for use throughout the application.
static QString version()
Version string.
@ IsBasemapLayer
Layer is considered a 'basemap' layer, and certain properties of the layer should be ignored when cal...
RasterResamplingStage
Stage at which raster resampling occurs.
@ Provider
Resampling occurs in Provider.
@ ResampleFilter
Resampling occurs in ResamplingFilter.
@ ProviderHintBenefitsFromResampling
Provider benefits from resampling and should apply user default resampling settings.
@ ProviderHintCanPerformProviderResampling
Provider can perform resampling (to be opposed to post rendering resampling)
@ ReadLayerMetadata
Provider can read layer metadata from data store. Since QGIS 3.0. See QgsDataProvider::layerMetadata(...
@ SingleBandColorData
Single band containing color data.
@ GrayOrUndefined
Gray or undefined.
RasterRangeLimit
Describes the limits used to compute raster ranges (min/max values).
@ CumulativeCut
Range is [ min + cumulativeCutLower() * (max - min), min + cumulativeCutUpper() * (max - min) ].
@ StdDev
Range is [ mean - stdDevFactor() * stddev, mean + stdDevFactor() * stddev ].
@ MinimumMaximum
Real min-max values.
@ Linear
Interpolates the color between two class breaks linearly.
@ Discrete
Assigns the color of the higher class for every pixel between two class breaks.
@ IsBasemapSource
Associated source should be considered a 'basemap' layer. See Qgis::MapLayerProperty::IsBasemapLayer.
@ Bilinear
Bilinear (2x2 kernel) resampling.
@ Cubic
Cubic Convolution Approximation (4x4 kernel) resampling.
RasterDrawingStyle
Raster drawing styles.
@ SingleBandGray
A single band image drawn as a range of gray colors.
@ SingleBandColorData
ARGB values rendered directly.
@ MultiBandColor
A layer containing 2 or more bands, mapped to RGB color space. In the case of a multiband with only t...
@ PalettedColor
A "Palette" image drawn using color table.
@ SingleBandPseudoColor
A single band image drawn using a pseudocolor algorithm.
QFlags< RasterInterfaceCapability > RasterInterfaceCapabilities
Raster interface capabilities.
BlendMode
Blending modes defining the available composition modes that can be used when painting.
@ 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.
@ StdDev
Standard deviation.
@ NoStatistic
No statistic.
DataType
Raster data types.
@ Float32
Thirty two bit floating point (float)
@ CFloat64
Complex Float64.
@ Int16
Sixteen bit signed integer (qint16)
@ ARGB32_Premultiplied
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
@ Int8
Eight bit signed integer (qint8) (added in QGIS 3.30)
@ UInt16
Sixteen bit unsigned integer (quint16)
@ Byte
Eight bit unsigned integer (quint8)
@ UnknownDataType
Unknown or unspecified type.
@ ARGB32
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32.
@ Int32
Thirty two bit signed integer (qint32)
@ Float64
Sixty four bit floating point (double)
@ CFloat32
Complex Float32.
@ UInt32
Thirty two bit unsigned integer (quint32)
@ WholeRaster
Whole raster is used to compute statistics.
@ FixedCanvas
Current extent of the canvas (at the time of computation) is used to compute statistics.
QFlags< MapLayerProperty > MapLayerProperties
Map layer properties.
@ LoadDefaultStyle
Reset the layer's style to the default for the datasource.
@ SkipGetExtent
Skip the extent from provider.
@ TrustDataSource
Trust datasource config (primary key unicity, geometry type and srid, etc). Improves provider load ti...
RasterColorInterpretation
Raster color interpretation.
@ AlphaBand
Alpha (0=transparent, 255=opaque)
@ PaletteIndex
Paletted (see associated color table)
@ ContinuousPalette
Continuous palette, QGIS addition, GRASS.
RasterIdentifyFormat
Raster identify formats.
@ Feature
WMS GML/JSON -> feature.
@ Value
Numerical pixel value.
@ Preferred
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
Abstract base class for objects which generate elevation profiles.
Abstract base class for labeling settings for raster layers.
static QgsAbstractRasterLayerLabeling * createFromElement(const QDomElement &element, const QgsReadWriteContext &context)
Tries to create an instance of an implementation based on the XML data.
static QgsRasterRendererRegistry * rasterRendererRegistry()
Returns the application's raster renderer registry, used for managing raster layer renderers.
static QgsRuntimeProfiler * profiler()
Returns the application runtime profiler.
Bilinear Raster Resampler.
Brightness/contrast and gamma correction filter pipe for rasters.
int contrast() const
Returns current contrast level.
int brightness() const
Returns current brightness level.
void readXml(const QDomElement &filterElem) override
Sets base class members from xml. Usually called from create() methods of subclasses.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
bool shade(double value, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlphaValue) const override
Generates an new RGBA value based on one input value.
void classifyColorRamp(int classes=0, int band=-1, const QgsRectangle &extent=QgsRectangle(), QgsRasterInterface *input=nullptr)
Classify color ramp shader.
void setColorRampType(Qgis::ShaderInterpolationMethod colorRampType)
Sets the color ramp interpolation method.
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &list)
Sets a custom color map.
Manipulates raster or point cloud pixel values so that they enhanceContrast or clip into a specified ...
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used.
@ StretchToMinimumMaximum
Linear histogram.
@ NoEnhancement
Default color scaling algorithm, no scaling is applied.
static QString contrastEnhancementAlgorithmString(ContrastEnhancementAlgorithm algorithm)
Returns a string to serialize ContrastEnhancementAlgorithm.
static ContrastEnhancementAlgorithm contrastEnhancementAlgorithmFromString(const QString &contrastEnhancementString)
Deserialize ContrastEnhancementAlgorithm.
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Abstract base class for spatial data provider implementations.
virtual QString subsetString() const
Returns the subset definition string currently in use by the layer and used by the provider to limit ...
virtual void setLayerOrder(const QStringList &layers)
Reorder the list of layer names to be rendered by this provider (in order from bottom to top)
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
virtual Qgis::DataProviderFlags flags() const
Returns the generic data provider flags.
virtual bool supportsSubsetString() const
Returns true if the provider supports setting of subset strings.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
virtual QgsLayerMetadata layerMetadata() const
Returns layer metadata collected from the provider's source.
virtual bool isValid() const =0
Returns true if this is a valid layer.
virtual void setDataSourceUri(const QString &uri)
Set the data source specification.
virtual QgsError error() const
Gets current status error.
virtual bool setSubsetString(const QString &subset, bool updateFeatureCount=true)
Set the subset string used to create a subset of features in the layer.
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
virtual QString htmlMetadata() const
Obtain a formatted HTML string containing assorted metadata for this data provider.
virtual void reloadData()
Reloads the data from the source for providers with data caches to synchronize, changes in the data s...
virtual void setSubLayerVisibility(const QString &name, bool vis)
Set the visibility of the given sublayer name.
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)
Sets data coordinate transform context to transformContext.
Class for storing the component parts of a RDBMS data source URI (e.g.
QByteArray encodedUri() const
Returns the complete encoded URI as a byte array.
void setEncodedUri(const QByteArray &uri)
Sets the complete encoded uri.
void setParam(const QString &key, const QString &value)
Sets a generic parameter value on the URI.
Color and saturation filter pipe for rasters.
bool invertColors() const
Returns true if the filter inverts colors.
void readXml(const QDomElement &filterElem) override
Sets base class members from xml. Usually called from create() methods of subclasses.
Base class for storage of map layer elevation properties.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the object's property collection, used for data defined overrides.
static QString typeToString(Qgis::LayerType type)
Converts a map layer type to a string value.
static QgsMapLayerLegend * defaultRasterLegend(QgsRasterLayer *rl)
Create new legend implementation for raster layer.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
void writeXml(QDomNode &layer_node, QDomDocument &document) const
Saves server properties to xml under the layer node.
QString abstract() const
Returns the abstract of the layerused by QGIS Server in GetCapabilities request.
Base class for storage of map layer temporal properties.
Base class for all map layer types.
void readStyleManager(const QDomNode &layerNode)
Read style manager's configuration (if any). To be called by subclasses.
void setError(const QgsError &error)
Sets error message.
void writeStyleManager(QDomNode &layerNode, QDomDocument &doc) const
Write style manager's configuration (if exists). To be called by subclasses.
virtual QgsRectangle extent() const
Returns the extent of the layer.
QString source() const
Returns the source for the layer.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
void configChanged()
Emitted whenever the configuration is changed.
static Qgis::DataProviderReadFlags providerReadFlags(const QDomNode &layerNode, QgsMapLayer::ReadFlags layerReadFlags)
Returns provider read flag deduced from layer read flags layerReadFlags and a dom node layerNode that...
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
QgsCoordinateReferenceSystem crs
QgsMapLayerServerProperties * serverProperties()
Returns QGIS Server Properties for the map layer.
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...
void setDataSource(const QString &dataSource, const QString &baseName=QString(), const QString &provider=QString(), bool loadDefaultStyleFlag=false)
Updates the data source of the layer.
QString mLayerName
Name of the layer - used for display.
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
QString crsHtmlMetadata() const
Returns a HTML fragment containing the layer's CRS metadata, for use in the htmlMetadata() method.
QgsLayerMetadata metadata
Q_DECL_DEPRECATED QString abstract() const
Returns the abstract of the layer used by QGIS Server in GetCapabilities request.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
void statusChanged(const QString &status)
Emit a signal with status (e.g. to be caught by QgisApp and display a msg on status bar)
virtual void setMetadata(const QgsLayerMetadata &metadata)
Sets the layer's metadata store.
QFlags< StyleCategory > StyleCategories
Q_INVOKABLE void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
QString mProviderKey
Data provider key (name of the data provider)
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
std::unique_ptr< QgsDataProvider > mPreloadedProvider
Optionally used when loading a project, it is released when the layer is effectively created.
void rendererChanged()
Signal emitted when renderer is changed.
Q_DECL_DEPRECATED QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
virtual QgsError error() const
Gets current status error.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
void opacityChanged(double opacity)
Emitted when the layer's opacity is changed, where opacity is a value between 0 (transparent) and 1 (...
void emitStyleChanged()
Triggers an emission of the styleChanged() signal.
void dataChanged()
Data of layer changed.
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
void setName(const QString &name)
Set the display name of the layer.
virtual void setExtent(const QgsRectangle &rect)
Sets the extent.
void appendError(const QgsErrorMessage &error)
Add error message.
QString mDataSource
Data source description string, varies by layer type.
void setMapTipsEnabled(bool enabled)
Enable or disable map tips for this layer.
@ FlagReadExtentFromXml
Read extent from xml and skip get extent from provider.
@ FlagTrustLayerMetadata
Trust layer metadata. Improves layer load time by skipping expensive checks like primary key unicity,...
@ FlagDontResolveLayers
Don't resolve layer paths or create data providers for layers.
void setValid(bool valid)
Sets whether layer is valid or not.
void readCommonStyle(const QDomElement &layerElement, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)
Read style data common to all layer types.
QgsMapLayer::ReadFlags mReadFlags
Read flags. It's up to the subclass to respect these when restoring state from XML.
double minimumScale() const
Returns the minimum map scale (i.e.
void repaintRequested(bool deferredUpdate=false)
By emitting this signal the layer tells that either appearance or content have been changed and any v...
void setMapTipTemplate(const QString &mapTipTemplate)
The mapTip is a pretty, html representation for feature information.
@ AttributeTable
Attribute table settings: choice and order of columns, conditional styling.
@ Rendering
Rendering: scale visibility, simplify method, opacity.
void setProviderType(const QString &providerType)
Sets the providerType (provider key)
QString customPropertyHtmlMetadata() const
Returns an HTML fragment containing custom property information, for use in the htmlMetadata() method...
QString generalHtmlMetadata() const
Returns an HTML fragment containing general metadata information, for use in the htmlMetadata() metho...
void writeCommonStyle(QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const
Write style data common to all layer types.
double maximumScale() const
Returns the maximum map scale (i.e.
void invalidateWgs84Extent()
Invalidates the WGS84 extent.
bool mShouldValidateCrs
true if the layer's CRS should be validated and invalid CRSes are not permitted.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
Perform transforms between map coordinates and device coordinates.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
Renderer for multiband images with the color components.
void setGreenContrastEnhancement(QgsContrastEnhancement *ce)
Sets the contrast enhancement to use for the green channel.
void setBlueContrastEnhancement(QgsContrastEnhancement *ce)
Sets the contrast enhancement to use for the blue channel.
void setRedContrastEnhancement(QgsContrastEnhancement *ce)
Sets the contrast enhancement to use for the red channel.
const QgsContrastEnhancement * redContrastEnhancement() const
Returns the contrast enhancement to use for the red channel.
static Qgis::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a Qgis::BlendMode corresponding to a QPainter::CompositionMode.
static QPainter::CompositionMode getCompositionMode(Qgis::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a Qgis::BlendMode.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
A class to represent a 2D point.
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
QString absoluteToRelativeUri(const QString &providerKey, const QString &uri, const QgsReadWriteContext &context) const
Converts absolute path(s) to relative path(s) in the given provider-specific URI.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QString relativeToAbsoluteUri(const QString &providerKey, const QString &uri, const QgsReadWriteContext &context) const
Converts relative path(s) to absolute path(s) in the given provider-specific URI.
The QgsRasterAttributeTable class represents a Raster Attribute Table (RAT).
QString filePath() const
Returns the (possibly empty) path of the file-based RAT, the path is set when a RAT is read or writte...
The RasterBandStats struct is a container for statistics about a single raster band.
double mean
The mean cell value for the band. NO_DATA values are excluded.
double stdDev
The standard deviation of the cell values.
double minimumValue
The minimum cell value in the raster band.
Qgis::RasterBandStatistics statsGathered
Collected statistics.
double maximumValue
The maximum cell value in the raster band.
static int typeSize(Qgis::DataType dataType)
Returns the size in bytes for the specified dataType.
static QString printValue(double value, bool localized=false)
Print double value with all necessary significant digits.
Handles elevation related properties for a raster data provider.
Base class for raster data providers.
Qgis::RasterResamplingMethod zoomedInResamplingMethod() const
Returns resampling method for zoomed-in operations.
virtual bool useSourceNoDataValue(int bandNo) const
Returns the source nodata value usage.
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...
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...
void readXml(const QDomElement &filterElem) override
Sets base class members from xml. Usually called from create() methods of subclasses.
virtual bool readNativeAttributeTable(QString *errorMessage=nullptr)
Reads the native attribute table, optionally reporting any error in errorMessage, returns true on suc...
virtual bool setZoomedOutResamplingMethod(Qgis::RasterResamplingMethod method)
Set resampling method to apply for zoomed-out operations.
QDateTime timestamp() const override
Time stamp of data source in the moment when data/metadata were loaded by provider.
QgsRectangle extent() const override=0
Returns the extent of the layer.
virtual bool 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.
QStringList subLayers() const override
Returns the sublayers of this layer - useful for providers that manage their own layers,...
Qgis::RasterResamplingMethod zoomedOutResamplingMethod() const
Returns resampling method for zoomed-out operations.
virtual Qgis::RasterColorInterpretation colorInterpretation(int bandNo) const
Returns data type for the band specified by number.
QDateTime dataTimestamp() const override
Current time stamp of data source.
virtual QList< QgsColorRampShader::ColorRampItem > colorTable(int bandNo) const
virtual Qgis::RasterProviderCapabilities providerCapabilities() const
Returns flags containing the supported capabilities of the data provider.
void statusChanged(const QString &) const
Emit a message to be displayed on status bar, usually used by network providers (WMS,...
virtual QgsRasterRangeList userNoDataValues(int bandNo) const
Returns a list of user no data value ranges.
static QString identifyFormatName(Qgis::RasterIdentifyFormat format)
Converts a raster identify format to a string name.
QgsRasterDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
virtual void setUserNoDataValue(int bandNo, const QgsRasterRangeList &noData)
The drawing pipe for raster layers.
void draw(QPainter *p, QgsRasterViewPort *viewPort, const QgsMapToPixel *qgsMapToPixel, QgsRasterBlockFeedback *feedback=nullptr)
Draws raster data.
Base class for processing filters like renderers, reprojector, resampler etc.
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.
virtual Qgis::RasterInterfaceCapabilities capabilities() const
Returns the capabilities supported by the interface.
virtual int xSize() const
Gets raster size.
virtual QString generateBandName(int bandNumber) const
helper function to create zero padded band names
Q_DECL_DEPRECATED QgsRasterBandStats bandStatistics(int bandNo, int stats, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, QgsRasterBlockFeedback *feedback=nullptr)
Returns the band statistics.
virtual int bandCount() const =0
Gets number of bands.
Q_DECL_DEPRECATED bool hasStatistics(int bandNo, int stats, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0)
Returns true if histogram is available (cached, already calculated).
virtual int ySize() const
virtual QgsRasterInterface * input() const
Current input.
Iterator for sequentially processing raster cells.
Raster layer specific subclass of QgsMapLayerElevationProperties.
bool isEnabled() const
Returns true if the elevation properties are enabled, i.e.
QgsRasterLayerElevationProperties * clone() const override
Creates a clone of the properties.
void setEnabled(bool enabled)
Sets whether the elevation properties are enabled, i.e.
Implementation of QgsAbstractProfileGenerator for raster layers.
Implementation of threaded rendering for raster layers.
Implementation of map layer temporal properties for raster layers.
void setDefaultsFromDataProviderTemporalCapabilities(const QgsDataProviderTemporalCapabilities *capabilities) override
Sets the layers temporal settings to appropriate defaults based on a provider's temporal capabilities...
Represents a raster layer.
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
bool canCreateRasterAttributeTable()
Returns true if the raster renderer is suitable for creation of a raster attribute table.
void subsetStringChanged()
Emitted when the layer's subset string has changed.
Qgis::MapLayerProperties properties() const override
Returns the map layer properties of this layer.
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...
const QgsAbstractRasterLayerLabeling * labeling() const
Access to const labeling configuration.
Q_DECL_DEPRECATED QgsLegendColorList legendSymbologyItems() const
Returns a list with classification items (Text and color).
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
void showStatusMessage(const QString &message)
QgsRasterAttributeTable * attributeTable(int bandNumber) const
Returns the (possibly NULL) raster attribute table for the given band bandNumber.
virtual bool setSubsetString(const QString &subset)
Sets the string (typically sql) used to define a subset of the layer.
QgsRasterResampleFilter * resampleFilter() const
Returns the raster's resample filter.
bool writeSymbology(QDomNode &, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) const override
Write the style for the layer into the document provided.
QgsRasterLayer * clone() const override
Returns a new instance equivalent to this one.
void setResamplingStage(Qgis::RasterResamplingStage stage)
Select which stage of the pipe should apply resampling.
Qgis::RasterResamplingStage resamplingStage() const
Returns which stage of the pipe should apply resampling.
static const QgsSettingsEntryBool * settingsRasterDefaultEarlyResampling
int attributeTableCount() const
Returns the number of attribute tables for the raster by counting the number of bands that have an as...
void refreshContrastEnhancement(const QgsRectangle &extent)
Refresh contrast enhancement with new extent.
int height() const
Returns the height of the (unclipped) raster.
void setOpacity(double opacity) FINAL
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
static const Qgis::RasterRangeLimit SINGLE_BAND_MIN_MAX_LIMITS
Default enhancement limits for single band raster.
Q_DECL_DEPRECATED void setDataProvider(const QString &provider)
Set the data provider.
static const QgsContrastEnhancement::ContrastEnhancementAlgorithm MULTIPLE_BAND_SINGLE_BYTE_ENHANCEMENT_ALGORITHM
Default enhancement algorithm for multiple band raster of type Byte.
int bandCount() const
Returns the number of bands in this layer.
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
bool ignoreExtents() const
If the ignoreExtent flag is set, the layer will also render outside the bounding box reported by the ...
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 computeMinMax(int band, const QgsRasterMinMaxOrigin &mmo, Qgis::RasterRangeLimit limits, const QgsRectangle &extent, int sampleSize, double &min, double &max)
Compute the min max values along band according to MinMaxOrigin parameters mmo and extent.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
void setSubLayerVisibility(const QString &name, bool vis) override
Set the visibility of the given sublayer name.
static const QgsSettingsEntryDouble * settingsRasterDefaultOversampling
void setLabeling(QgsAbstractRasterLayerLabeling *labeling)
Sets labeling configuration.
virtual QString subsetString() const
Returns the string (typically sql) used to define a subset of the layer.
QgsAbstractProfileGenerator * createProfileGenerator(const QgsProfileRequest &request) override
Given a profile request, returns a new profile generator ready for generating elevation profiles.
QgsBrightnessContrastFilter * brightnessFilter() const
Returns the raster's brightness/contrast filter.
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.
bool writeStyle(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) const override
Write just the symbology information for the layer into the document.
double opacity() const FINAL
Returns the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
double rasterUnitsPerPixelX() const
Returns the number of raster units per each raster pixel in X axis.
void reload() override
Synchronises with changes in the datasource.
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the layer.
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.
QStringList subLayers() const override
Returns the sublayers of this layer.
static const Qgis::RasterRangeLimit MULTIPLE_BAND_MULTI_BYTE_MIN_MAX_LIMITS
Default enhancement limits for multiple band raster of type different from Byte.
void setContrastEnhancement(QgsContrastEnhancement::ContrastEnhancementAlgorithm algorithm, Qgis::RasterRangeLimit limits=Qgis::RasterRangeLimit::MinimumMaximum, const QgsRectangle &extent=QgsRectangle(), int sampleSize=QgsRasterLayer::SAMPLE_SIZE, bool generateLookupTableFlag=true)
Set contrast enhancement algorithm.
void setDefaultContrastEnhancement()
Sets the default contrast enhancement.
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
static const double SAMPLE_SIZE
Default sample size (number of pixels) for estimated statistics/histogram calculation.
static const QgsContrastEnhancement::ContrastEnhancementAlgorithm MULTIPLE_BAND_MULTI_BYTE_ENHANCEMENT_ALGORITHM
Default enhancement algorithm for multiple band raster of type different from Byte.
static const Qgis::RasterRangeLimit MULTIPLE_BAND_SINGLE_BYTE_MIN_MAX_LIMITS
Default enhancement limits for multiple band raster of type Byte.
bool readXml(const QDomNode &layer_node, QgsReadWriteContext &context) override
Called by readLayerXML(), used by children to read state specific to them from project files.
void setLabelsEnabled(bool enabled)
Sets whether labels should be enabled for the layer.
QString bandName(int bandNoInt) const
Returns the name of a band given its number.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
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.
bool isSpatial() const override
Returns true if the layer is considered a spatial layer, ie it has some form of geometry associated w...
double rasterUnitsPerPixelY() const
Returns the number of raster units per each raster pixel in Y axis.
QString providerType() const
[ data provider interface ] Which provider is being used for this Raster Layer?
int width() const
Returns the width of the (unclipped) raster.
QgsMapLayerElevationProperties * elevationProperties() override
Returns the layer's elevation properties.
bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) override
Read the symbology for the current layer from the DOM node supplied.
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...
bool writeSld(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QVariantMap &props=QVariantMap()) const
Writes the symbology of the layer into the document provided in SLD 1.0.0 format.
static QDateTime lastModified(const QString &name)
Returns time stamp for given file name.
static const QgsContrastEnhancement::ContrastEnhancementAlgorithm SINGLE_BAND_ENHANCEMENT_ALGORITHM
Default enhancement algorithm for single band raster.
~QgsRasterLayer() override
QDateTime timestamp() const override
Time stamp of data source in the moment when data/metadata were loaded by provider.
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext) override
Sets the coordinate transform context to transformContext.
void setRenderer(QgsRasterRenderer *renderer)
Sets the raster's renderer.
QgsRasterLayer()
Constructor. Provider is not set.
void setLayerOrder(const QStringList &layers) override
Reorders the previously selected sublayers of this layer from bottom to top.
bool defaultContrastEnhancementSettings(QgsContrastEnhancement::ContrastEnhancementAlgorithm &myAlgorithm, Qgis::RasterRangeLimit &myLimits) const
Returns default contrast enhancement settings for that type of raster.
QgsHueSaturationFilter * hueSaturationFilter() const
Returns the raster's hue/saturation filter.
bool readStyle(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) override
Read the style for the current layer from the DOM node supplied.
QPixmap paletteAsPixmap(int bandNumber=1)
Returns a 100x100 pixmap of the color palette.
This class describes the origin of min/max values.
static QString limitsString(Qgis::RasterRangeLimit limits)
Returns a string to serialize Limits.
void setLimits(Qgis::RasterRangeLimit limits)
Sets the limits.
void setExtent(Qgis::RasterRangeExtent extent)
Sets the extent.
double cumulativeCutLower() const
Returns the lower bound of cumulative cut method (between 0 and 1).
Qgis::RasterRangeExtent extent() const
Returns the raster extent.
double stdDevFactor() const
Returns the factor f so that the min/max range is [ mean - f * stddev , mean + f * stddev ].
double cumulativeCutUpper() const
Returns the upper bound of cumulative cut method (between 0 and 1).
static Qgis::RasterRangeLimit limitsFromString(const QString &limits)
Deserialize Limits.
Qgis::RasterRangeLimit limits() const
Returns the raster limits.
Contains a pipeline of raster interfaces for sequential raster processing.
static QgsPropertiesDefinition propertyDefinitions()
Returns the definitions for data defined properties available for use in raster pipes.
Implements approximate projection support for optimised raster transformation.
Q_DECL_DEPRECATED void setCrs(const QgsCoordinateReferenceSystem &srcCRS, const QgsCoordinateReferenceSystem &destCRS, int srcDatumTransform=-1, int destDatumTransform=-1)
Sets the source and destination CRS.
Raster values range container.
double min() const
Returns the minimum value for the range.
Raster renderer pipe that applies colors to a raster.
virtual QString type() const
Returns a unique string representation of the renderer type.
virtual bool canCreateRasterAttributeTable() const
Returns true if the renderer is suitable for attribute table creation.
void setMinMaxOrigin(const QgsRasterMinMaxOrigin &origin)
Sets origin of min/max values.
const QgsRasterMinMaxOrigin & minMaxOrigin() const
Returns const reference to origin of min/max values.
virtual bool refresh(const QgsRectangle &extent, const QList< double > &min, const QList< double > &max, bool forceRefresh=false)
Refreshes the renderer according to the min and max values associated with the extent.
virtual QList< int > usesBands() const
Returns a list of band numbers used by the renderer.
virtual QList< QPair< QString, QColor > > legendSymbologyItems() const
Returns symbology items if provided by renderer.
Resample filter pipe for rasters.
void setZoomedOutResampler(QgsRasterResampler *r)
Sets resampler for zoomed out scales. Takes ownership of the object.
void setMaxOversampling(double os)
void readXml(const QDomElement &filterElem) override
Sets base class members from xml. Usually called from create() methods of subclasses.
void setZoomedInResampler(QgsRasterResampler *r)
Sets resampler for zoomed in scales. Takes ownership of the object.
Interface for all raster shaders.
void setRasterShaderFunction(QgsRasterShaderFunction *function)
A public method that allows the user to set their own shader function.
QgsRasterShaderFunction * rasterShaderFunction()
Allows entering a context category and takes care of leaving this category on deletion of the class.
The class is used as a container of context for various read/write operations on other objects.
MAYBE_UNUSED NODISCARD QgsReadWriteContextCategoryPopper enterCategory(const QString &category, const QString &details=QString()) const
Push a category to the stack.
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
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 truncated to the sp...
Contains information about the context of a rendering operation.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
A boolean settings entry.
static QgsSettingsTreeNode * sTreeRaster
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Raster renderer pipe for single band gray.
void setContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
int inputBand() const override
Returns the input band for the renderer, or -1 if no input band is available.
Raster renderer pipe for single band pseudocolor.
void setClassificationMin(double min)
void setShader(QgsRasterShader *shader)
Takes ownership of the shader.
void setClassificationMax(double max)
QgsRasterShader * shader()
Returns the raster shader.
int inputBand() const override
Returns the input band for the renderer, or -1 if no input band is available.
An interface for classes which can visit style entity (e.g.
static void mergeScaleDependencies(double mScaleMinDenom, double mScaleMaxDenom, QVariantMap &props)
Merges the local scale limits, if any, with the ones already in the map, if any.
static QgsRectangle readRectangle(const QDomElement &element)
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
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 c
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
QgsDataProvider * classFactoryFunction_t(const QString *, const QgsDataProvider::ProviderOptions &options)
QList< QPair< QString, QColor > > QgsLegendColorList
QList< QgsRasterRange > QgsRasterRangeList
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS
Setting options for creating vector data providers.
Setting options for loading raster layers.
bool skipCrsValidation
Controls whether the layer is allowed to have an invalid/unknown CRS.
bool loadDefaultStyle
Sets to true if the default layer style should be loaded.
QgsCoordinateTransformContext transformContext
Coordinate transform context.
Registry for raster renderer entries.
QgsRasterRendererCreateFunc rendererCreateFunction
This class provides details of the viewable area that a raster will be rendered into.
qgssize mHeight
Height, number of rows to be rendered.
QgsCoordinateReferenceSystem mDestCRS
Target (map) coordinate system.
QgsPointXY mBottomRightPoint
Coordinate (in output device coordinate system) of bottom right corner of the part of the raster that...
QgsPointXY mTopLeftPoint
Coordinate (in output device coordinate system) of top left corner of the part of the raster that is ...
QgsCoordinateReferenceSystem mSrcCRS
Source (layer) coordinate system.
QgsRectangle mDrawnExtent
Intersection of current map extent and layer extent, in map (destination) CRS.
QgsCoordinateTransformContext mTransformContext
Coordinate transform context.
qgssize mWidth
Width, number of columns to be rendered.