52 #include "qgssettings.h"
54 #include "qgsgdalprovider.h"
66 #include <QApplication>
69 #include <QDomElement>
74 #include <QFontMetrics>
85 #define ERR(message) QGS_ERROR_MESSAGE(message,"Raster layer")
105 , QSTRING_NOT_SET( QStringLiteral(
"Not Set" ) )
106 , TRSTRING_NOT_SET( tr(
"Not Set" ) )
115 const QString &baseName,
116 const QString &providerKey,
120 , QSTRING_NOT_SET( QStringLiteral(
"Not Set" ) )
121 , TRSTRING_NOT_SET( tr(
"Not Set" ) )
130 QgsDataProvider::ReadFlags providerFlags = QgsDataProvider::ReadFlags();
135 setDataSource( uri, baseName, providerKey, providerOptions, providerFlags );
163 for (
int i = 1; i < mPipe.
size(); i++ )
180 bool myIsValid = QgsGdalProvider::isValidRasterFileName( fileNameQString, retErrMsg );
195 QFileInfo fi(
name );
201 t = fi.lastModified();
224 if ( !mDataProvider )
return 0;
230 if ( !mDataProvider )
return QString();
241 return mDataProvider;
246 return mDataProvider;
278 bool restoreOldResamplingStage =
false;
286 if ( mDataProvider !=
nullptr &&
291 restoreOldResamplingStage =
true;
300 drawer.
draw( theQPainter, rasterViewPort, qgsMapToPixel );
302 if ( restoreOldResamplingStage )
307 QgsDebugMsgLevel( QStringLiteral(
"total raster draw time (ms): %1" ).arg( time.elapsed(), 5 ), 4 );
318 if ( !mDataProvider )
322 QString myMetadata = QStringLiteral(
"<html><head></head>\n<body>\n" );
325 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Information from provider" ) + QStringLiteral(
"</h1>\n<hr>\n" ) %
326 QStringLiteral(
"<table class=\"list-view\">\n" ) %
329 QStringLiteral(
"<tr><td class=\"highlight\">" ) % tr(
"Name" ) % QStringLiteral(
"</td><td>" ) %
name() % QStringLiteral(
"</td></tr>\n" );
334 bool isLocalPath =
false;
335 if ( uriComponents.contains( QStringLiteral(
"path" ) ) )
337 path = uriComponents[QStringLiteral(
"path" )].toString();
338 if ( QFile::exists( path ) )
341 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) % tr(
"Path" ) % QStringLiteral(
"</td><td>%1" ).arg( QStringLiteral(
"<a href=\"%1\">%2</a>" ).arg( QUrl::fromLocalFile( path ).toString(), QDir::toNativeSeparators( path ) ) ) + QStringLiteral(
"</td></tr>\n" );
344 if ( uriComponents.contains( QStringLiteral(
"url" ) ) )
346 const QString url = uriComponents[QStringLiteral(
"url" )].toString();
347 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) % tr(
"URL" ) % QStringLiteral(
"</td><td>%1" ).arg( QStringLiteral(
"<a href=\"%1\">%2</a>" ).arg( QUrl( url ).toString(), url ) ) + QStringLiteral(
"</td></tr>\n" );
352 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Source" ) + QStringLiteral(
"</td><td>%1" ).arg(
publicSource() != path ?
publicSource() : path ) + QStringLiteral(
"</td></tr>\n" );
354 myMetadata += QLatin1String(
"</table>\n<br><br>" );
359 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Properties" ) + QStringLiteral(
"</h1>\n<hr>\n" ) + QStringLiteral(
"<table class=\"list-view\">\n" );
361 myMetadata += QStringLiteral(
"\n" ) %
364 QStringLiteral(
"<tr><td class=\"highlight\">" ) % tr(
"Extent" ) % QStringLiteral(
"</td><td>" ) %
extent().
toString() % QStringLiteral(
"</td></tr>\n" ) %
367 QStringLiteral(
"<tr><td class=\"highlight\">" ) % tr(
"Width" ) % QStringLiteral(
"</td><td>" );
369 myMetadata += QString::number(
width() );
371 myMetadata += tr(
"n/a" );
372 myMetadata += QStringLiteral(
"</td></tr>\n" ) %
375 QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Height" ) + QStringLiteral(
"</td><td>" );
377 myMetadata += QString::number(
height() );
379 myMetadata += tr(
"n/a" );
380 myMetadata += QStringLiteral(
"</td></tr>\n" ) %
383 QStringLiteral(
"<tr><td class=\"highlight\">" ) % tr(
"Data type" ) % QStringLiteral(
"</td><td>" );
388 myMetadata += tr(
"Byte - Eight bit unsigned integer" );
391 myMetadata += tr(
"UInt16 - Sixteen bit unsigned integer " );
394 myMetadata += tr(
"Int16 - Sixteen bit signed integer " );
397 myMetadata += tr(
"UInt32 - Thirty two bit unsigned integer " );
400 myMetadata += tr(
"Int32 - Thirty two bit signed integer " );
403 myMetadata += tr(
"Float32 - Thirty two bit floating point " );
406 myMetadata += tr(
"Float64 - Sixty four bit floating point " );
409 myMetadata += tr(
"CInt16 - Complex Int16 " );
412 myMetadata += tr(
"CInt32 - Complex Int32 " );
415 myMetadata += tr(
"CFloat32 - Complex Float32 " );
418 myMetadata += tr(
"CFloat64 - Complex Float64 " );
421 myMetadata += tr(
"Could not determine raster data type." );
423 myMetadata += QStringLiteral(
"</td></tr>\n" ) %
429 QStringLiteral(
"</table>\n<br><br>" ) %
432 QStringLiteral(
"<h1>" ) % tr(
"Identification" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
434 QStringLiteral(
"<br><br>\n" ) %
437 QStringLiteral(
"<h1>" ) % tr(
"Extent" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
439 QStringLiteral(
"<br><br>\n" ) %
442 QStringLiteral(
"<h1>" ) % tr(
"Access" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
444 QStringLiteral(
"<br><br>\n" ) %
447 QStringLiteral(
"</table>\n<br><br><h1>" ) % tr(
"Bands" ) % QStringLiteral(
"</h1>\n<hr>\n<table class=\"list-view\">\n" ) %
450 QStringLiteral(
"<tr><td class=\"highlight\">" ) % tr(
"Band count" ) % QStringLiteral(
"</td><td>" ) % QString::number(
bandCount() ) % QStringLiteral(
"</td></tr>\n" );
453 myMetadata += QStringLiteral(
"</table>\n<br><table width=\"100%\" class=\"tabular-view\">\n" ) %
454 QStringLiteral(
"<tr><th>" ) % tr(
"Number" ) % QStringLiteral(
"</th><th>" ) % tr(
"Band" ) % QStringLiteral(
"</th><th>" ) % tr(
"No-Data" ) % QStringLiteral(
"</th><th>" ) %
455 tr(
"Min" ) % QStringLiteral(
"</th><th>" ) % tr(
"Max" ) % QStringLiteral(
"</th></tr>\n" );
462 rowClass = QStringLiteral(
"class=\"odd-row\"" );
464 myMetadata += QStringLiteral(
"<tr " ) % rowClass % QStringLiteral(
"><td>" ) % QString::number( i ) % QStringLiteral(
"</td><td>" ) %
bandName( i ) % QStringLiteral(
"</td><td>" );
467 myMetadata += QString::number(
dataProvider()->sourceNoDataValue( i ) );
469 myMetadata += tr(
"n/a" );
470 myMetadata += QLatin1String(
"</td>" );
475 myMetadata += QStringLiteral(
"<td>" ) % QString::number( myRasterBandStats.
minimumValue,
'f', 10 ) % QStringLiteral(
"</td>" ) %
476 QStringLiteral(
"<td>" ) % QString::number( myRasterBandStats.
maximumValue,
'f', 10 ) % QStringLiteral(
"</td>" );
480 myMetadata += QStringLiteral(
"<td>" ) % tr(
"n/a" ) % QStringLiteral(
"</td><td>" ) % tr(
"n/a" ) % QStringLiteral(
"</td>" );
483 myMetadata += QLatin1String(
"</tr>\n" );
487 myMetadata += QStringLiteral(
"</table>\n<br><br>" ) %
490 QStringLiteral(
"<h1>" ) % tr(
"Contacts" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
492 QStringLiteral(
"<br><br>\n" ) %
495 QStringLiteral(
"<h1>" ) % tr(
"References" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
497 QStringLiteral(
"<br><br>\n" ) %
500 QStringLiteral(
"<h1>" ) % tr(
"History" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
502 QStringLiteral(
"<br><br>\n" ) %
504 QStringLiteral(
"\n</body>\n</html>\n" );
515 if ( mDataProvider &&
520 QList<QgsColorRampShader::ColorRampItem> myColorRampItemList = mDataProvider->
colorTable( bandNumber );
521 if ( !myColorRampItemList.isEmpty() )
528 QPixmap myPalettePixmap( mySize, mySize );
529 QPainter myQPainter( &myPalettePixmap );
531 QImage myQImage = QImage( mySize, mySize, QImage::Format_RGB32 );
533 myPalettePixmap.fill();
535 double myStep = (
static_cast< double >( myColorRampItemList.size() ) - 1 ) /
static_cast< double >( mySize * mySize );
536 double myValue = 0.0;
537 for (
int myRow = 0; myRow < mySize; myRow++ )
539 QRgb *myLineBuffer =
reinterpret_cast< QRgb *
>( myQImage.scanLine( myRow ) );
540 for (
int myCol = 0; myCol < mySize; myCol++ )
542 myValue = myStep *
static_cast< double >( myCol + myRow * mySize );
544 myShader.
shade( myValue, &c1, &c2, &c3, &c4 );
545 myLineBuffer[ myCol ] = qRgba( c1, c2, c3, c4 );
549 myQPainter.drawImage( 0, 0, myQImage );
550 return myPalettePixmap;
552 QPixmap myNullPixmap;
558 QPixmap myNullPixmap;
576 if ( mDataProvider &&
586 if ( mDataProvider &&
609 void QgsRasterLayer::init()
627 mPipe.
remove( mDataProvider );
628 mDataProvider =
nullptr;
642 std::unique_ptr< QgsScopedRuntimeProfile > profile;
644 profile = std::make_unique< QgsScopedRuntimeProfile >( tr(
"Create %1 provider" ).arg( provider ), QStringLiteral(
"projectload" ) );
647 if ( !mDataProvider )
654 mDataProvider->setParent(
this );
657 mPipe.
set( mDataProvider );
658 if ( !mDataProvider->
isValid() )
668 QgsDebugMsgLevel( QStringLiteral(
"Set Data provider QgsLayerMetadata identifier[%1]" ).arg(
metadata().identifier() ), 4 );
671 if ( provider == QLatin1String(
"gdal" ) )
704 if ( ( mDataProvider->
bandCount() > 1 ) )
752 QList<QgsColorRampShader::ColorRampItem> colorTable = mDataProvider->
colorTable( 1 );
775 for (
int bandNo = 1; bandNo <= mDataProvider->
bandCount(); bandNo++ )
779 if (
auto *lRenderer = mPipe.
renderer() )
781 lRenderer->setAlphaBand( bandNo );
801 QgsSettings settings;
802 QString resampling = settings.value( QStringLiteral(
"/Raster/defaultZoomedInResampling" ), QStringLiteral(
"nearest neighbour" ) ).toString();
803 if ( resampling == QLatin1String(
"bilinear" ) )
808 else if ( resampling == QLatin1String(
"cubic" ) )
813 resampling = settings.value( QStringLiteral(
"/Raster/defaultZoomedOutResampling" ), QStringLiteral(
"nearest neighbour" ) ).toString();
814 if ( resampling == QLatin1String(
"bilinear" ) )
820 const double maxOversampling = settings.value( QStringLiteral(
"/Raster/defaultOversampling" ), 2.0 ).toDouble();
825 settings.value( QStringLiteral(
"/Raster/defaultEarlyResampling" ),
false ).toBool() )
837 mPipe.
set( projector );
881 void QgsRasterLayer::setDataSourcePrivate(
const QString &dataSource,
const QString &baseName,
const QString &provider,
886 QDomImplementation domImplementation;
887 QDomDocumentType documentType;
890 bool loadDefaultStyleFlag =
false;
893 loadDefaultStyleFlag =
true;
897 if ( hadRenderer && ! loadDefaultStyleFlag )
899 documentType = domImplementation.createDocumentType(
900 QStringLiteral(
"qgis" ), QStringLiteral(
"http://mrcc.com/qgis.dtd" ), QStringLiteral(
"SYSTEM" ) );
902 QDomDocument doc = QDomDocument( documentType );
903 QDomElement styleElem = doc.createElement( QStringLiteral(
"qgis" ) );
904 styleElem.setAttribute( QStringLiteral(
"version" ),
Qgis::version() );
908 QgsDebugMsg( QStringLiteral(
"Could not store symbology for layer %1: %2" )
914 doc.appendChild( styleElem );
916 mOriginalStyleDocument = doc;
917 mOriginalStyleElement = styleElem;
926 for (
int i = mPipe.
size() - 1; i >= 0; --i )
942 bool defaultLoadedFlag =
false;
943 bool restoredStyle =
false;
944 if ( loadDefaultStyleFlag )
948 else if ( !mOriginalStyleElement.isNull() )
951 if ( !
readSymbology( mOriginalStyleElement, errorMsg, readContext ) )
953 QgsDebugMsg( QStringLiteral(
"Could not restore symbology for layer %1: %2" )
960 restoredStyle =
true;
967 if ( !defaultLoadedFlag && !restoredStyle )
974 void QgsRasterLayer::closeDataProvider()
977 mPipe.
remove( mDataProvider );
978 mDataProvider =
nullptr;
981 void QgsRasterLayer::computeMinMax(
int band,
986 double &min,
double &max )
989 min = std::numeric_limits<double>::quiet_NaN();
990 max = std::numeric_limits<double>::quiet_NaN();
991 if ( !mDataProvider )
998 if ( myRasterBandStats.
statsGathered == QgsRasterBandStats::Stats::None )
1001 switch ( mDataProvider->
dataType( band ) )
1012 myRasterBandStats.
maximumValue = std::numeric_limits<uint16_t>::max();
1018 myRasterBandStats.
maximumValue = std::numeric_limits<uint32_t>::max();
1024 myRasterBandStats.
minimumValue = std::numeric_limits<int16_t>::lowest();
1025 myRasterBandStats.
maximumValue = std::numeric_limits<int16_t>::max();
1031 myRasterBandStats.
minimumValue = std::numeric_limits<int32_t>::lowest();
1032 myRasterBandStats.
maximumValue = std::numeric_limits<int32_t>::max();
1038 myRasterBandStats.
minimumValue = std::numeric_limits<float_t>::lowest();
1039 myRasterBandStats.
maximumValue = std::numeric_limits<float_t>::max();
1045 myRasterBandStats.
minimumValue = std::numeric_limits<double_t>::lowest();
1046 myRasterBandStats.
maximumValue = std::numeric_limits<double_t>::max();
1071 QgsDebugMsgLevel( QStringLiteral(
"myLower = %1 myUpper = %2" ).arg( myLower ).arg( myUpper ), 4 );
1074 QgsDebugMsgLevel( QStringLiteral(
"band = %1 min = %2 max = %3" ).arg( band ).arg( min ).arg( max ), 4 );
1080 return mDataProvider ? mDataProvider->
ignoreExtents() :
false;
1085 return mTemporalProperties;
1094 generateLookupTableFlag,
1102 bool generateLookupTableFlag,
1106 if ( !rasterRenderer || !mDataProvider )
1112 QList<QgsContrastEnhancement *> myEnhancements;
1118 QString rendererType = rasterRenderer->
type();
1119 if ( rendererType == QLatin1String(
"singlebandgray" ) )
1122 if ( !myGrayRenderer )
1126 myBands << myGrayRenderer->
grayBand();
1127 myRasterRenderer = myGrayRenderer;
1130 else if ( rendererType == QLatin1String(
"multibandcolor" ) )
1133 if ( !myMultiBandRenderer )
1138 myRasterRenderer = myMultiBandRenderer;
1141 else if ( rendererType == QLatin1String(
"singlebandpseudocolor" ) )
1144 if ( !myPseudoColorRenderer )
1148 myBands << myPseudoColorRenderer->
band();
1149 myRasterRenderer = myPseudoColorRenderer;
1150 myMinMaxOrigin = myPseudoColorRenderer->
minMaxOrigin();
1157 const auto constMyBands = myBands;
1158 for (
int myBand : constMyBands )
1164 myEnhancement->setContrastEnhancementAlgorithm(
algorithm, generateLookupTableFlag );
1168 computeMinMax( myBand, myMinMaxOrigin, limits,
extent, sampleSize, min, max );
1170 if ( rendererType == QLatin1String(
"singlebandpseudocolor" ) )
1174 if ( myPseudoColorRenderer->
shader() )
1177 if ( colorRampShader )
1185 myEnhancement->setMinimumValue( min );
1186 myEnhancement->setMaximumValue( max );
1187 myEnhancements.append( myEnhancement.release() );
1192 myEnhancements.append(
nullptr );
1196 if ( rendererType == QLatin1String(
"singlebandgray" ) )
1200 else if ( rendererType == QLatin1String(
"multibandcolor" ) )
1208 qDeleteAll( myEnhancements );
1216 if ( myRasterRenderer )
1221 if ( rasterRenderer ==
renderer() )
1273 if ( mDataProvider &&
1274 mLastRectangleUsedByRefreshContrastEnhancementIfNeeded !=
extent &&
1278 refreshRenderer( rasterRenderer,
extent );
1284 if ( mDataProvider )
1300 mLastRectangleUsedByRefreshContrastEnhancementIfNeeded =
extent;
1303 computeMinMax( sbpcr->
band(),
1313 if ( colorRampShader )
1326 if ( colorRampShader )
1341 mLastRectangleUsedByRefreshContrastEnhancementIfNeeded =
extent;
1351 if ( singleBandRenderer )
1353 else if ( multiBandRenderer )
1377 if ( !
isValid() || !mDataProvider )
1379 QgsDebugMsgLevel( QStringLiteral(
"invoked with invalid layer or null mDataProvider" ), 3 );
1380 return customProperty( QStringLiteral(
"storedSubsetString" ) ).toString();
1391 if ( !
isValid() || !mDataProvider )
1393 QgsDebugMsgLevel( QStringLiteral(
"invoked with invalid layer or null mDataProvider or while editing" ), 3 );
1425 QgsSettings mySettings;
1429 QString defaultLimits;
1434 key = QStringLiteral(
"singleBand" );
1444 key = QStringLiteral(
"multiBandSingleByte" );
1452 key = QStringLiteral(
"multiBandMultiByte" );
1460 if ( key.isEmpty() )
1462 QgsDebugMsgLevel( QStringLiteral(
"No default contrast enhancement for this drawing style" ), 2 );
1469 QString myAlgorithmString = mySettings.value(
"/Raster/defaultContrastEnhancementAlgorithm/" + key, defaultAlg ).toString();
1474 QString myLimitsString = mySettings.value(
"/Raster/defaultContrastEnhancementLimits/" + key, defaultLimits ).toString();
1496 if ( mDataProvider )
1498 QgsDebugMsgLevel( QStringLiteral(
"About to mDataProvider->setLayerOrder(layers)." ), 4 );
1507 if ( mDataProvider )
1509 QgsDebugMsgLevel( QStringLiteral(
"About to mDataProvider->setSubLayerVisibility(name, vis)." ), 4 );
1517 if ( !mDataProvider )
1524 if (
auto *lRenderer = mPipe.
renderer() )
1526 if ( !lRenderer->accept( visitor ) )
1535 Q_UNUSED( errorMessage )
1537 QVariantMap localProps = QVariantMap( props );
1547 QDomElement constraintElem = doc.createElement( QStringLiteral(
"sld:LayerFeatureConstraints" ) );
1548 node.appendChild( constraintElem );
1550 QDomElement featureTypeConstraintElem = doc.createElement( QStringLiteral(
"sld:FeatureTypeConstraint" ) );
1551 constraintElem.appendChild( featureTypeConstraintElem );
1553 QDomElement userStyleElem = doc.createElement( QStringLiteral(
"sld:UserStyle" ) );
1554 node.appendChild( userStyleElem );
1556 if ( !
name().isEmpty() )
1558 QDomElement nameElem = doc.createElement( QStringLiteral(
"sld:Name" ) );
1559 nameElem.appendChild( doc.createTextNode(
name() ) );
1560 userStyleElem.appendChild( nameElem );
1563 if ( !
abstract().isEmpty() )
1565 QDomElement abstractElem = doc.createElement( QStringLiteral(
"sld:Abstract" ) );
1566 abstractElem.appendChild( doc.createTextNode(
abstract() ) );
1567 userStyleElem.appendChild( abstractElem );
1570 if ( !
title().isEmpty() )
1572 QDomElement titleElem = doc.createElement( QStringLiteral(
"sld:Title" ) );
1573 titleElem.appendChild( doc.createTextNode(
title() ) );
1574 userStyleElem.appendChild( titleElem );
1577 QDomElement featureTypeStyleElem = doc.createElement( QStringLiteral(
"sld:FeatureTypeStyle" ) );
1578 userStyleElem.appendChild( featureTypeStyleElem );
1588 QDomElement typeStyleNameElem = doc.createElement( QStringLiteral(
"sld:Name" ) );
1589 featureTypeStyleElem.appendChild( typeStyleNameElem );
1592 QDomElement typeStyleRuleElem = doc.createElement( QStringLiteral(
"sld:Rule" ) );
1593 featureTypeStyleElem.appendChild( typeStyleRuleElem );
1601 QDomElement minScaleElem = doc.createElement( QStringLiteral(
"sld:MinScaleDenominator" ) );
1602 minScaleElem.appendChild( doc.createTextNode( QString::number(
maximumScale() ) ) );
1603 typeStyleRuleElem.appendChild( minScaleElem );
1606 QDomElement maxScaleElem = doc.createElement( QStringLiteral(
"sld:MaxScaleDenominator" ) );
1607 maxScaleElem.appendChild( doc.createTextNode( QString::number(
minimumScale() ) ) );
1608 typeStyleRuleElem.appendChild( maxScaleElem );
1612 mPipe.
renderer()->
toSld( doc, typeStyleRuleElem, localProps );
1617 QDomNodeList elements = typeStyleRuleElem.elementsByTagName( QStringLiteral(
"sld:RasterSymbolizer" ) );
1618 if ( elements.size() != 0 )
1621 QDomElement rasterSymbolizerElem = elements.at( 0 ).toElement();
1624 auto vendorOptionWriter = [&]( QString
name, QString value )
1626 QDomElement vendorOptionElem = doc.createElement( QStringLiteral(
"sld:VendorOption" ) );
1627 vendorOptionElem.setAttribute( QStringLiteral(
"name" ),
name );
1628 vendorOptionElem.appendChild( doc.createTextNode( value ) );
1629 rasterSymbolizerElem.appendChild( vendorOptionElem );
1639 property = QStringLiteral(
"lightness" );
1642 property = QStringLiteral(
"luminosity" );
1645 property = QStringLiteral(
"average" );
1651 if ( !property.isEmpty() )
1652 vendorOptionWriter( QStringLiteral(
"grayScale" ), property );
1658 vendorOptionWriter( QStringLiteral(
"colorizeOn" ), QString::number(
hueSaturationFilter()->colorizeOn() ) );
1659 vendorOptionWriter( QStringLiteral(
"colorizeRed" ), QString::number(
hueSaturationFilter()->colorizeColor().red() ) );
1660 vendorOptionWriter( QStringLiteral(
"colorizeGreen" ), QString::number(
hueSaturationFilter()->colorizeColor().green() ) );
1661 vendorOptionWriter( QStringLiteral(
"colorizeBlue" ), QString::number(
hueSaturationFilter()->colorizeColor().blue() ) );
1663 vendorOptionWriter( QStringLiteral(
"colorizeStrength" ), QString::number(
hueSaturationFilter()->colorizeStrength() / 100.0 ) );
1664 vendorOptionWriter( QStringLiteral(
"saturation" ), QString::number(
hueSaturationFilter()->colorizeColor().saturationF() ) );
1673 double sF = ( s - ( -100.0 ) ) / ( 100.0 - ( -100.0 ) );
1674 vendorOptionWriter( QStringLiteral(
"saturation" ), QString::number( sF ) );
1683 double bF = ( b - ( -255.0 ) ) / ( 255.0 - ( -255.0 ) );
1684 vendorOptionWriter( QStringLiteral(
"brightness" ), QString::number( bF ) );
1692 double cF = (
c - ( -100.0 ) ) / ( 100.0 - ( -100.0 ) );
1693 vendorOptionWriter( QStringLiteral(
"contrast" ), QString::number( cF ) );
1707 if ( newProps.contains( QStringLiteral(
"contrast" ) ) )
1710 double contrast = newProps[ QStringLiteral(
"contrast" ) ].toDouble();
1711 double percentage = ( contrast - ( -100.0 ) ) / ( 100.0 - ( -100.0 ) );
1712 if ( percentage <= 0.5 )
1715 gamma = percentage / 0.5;
1722 QDomElement globalContrastEnhancementElem = doc.createElement( QStringLiteral(
"sld:ContrastEnhancement" ) );
1723 rasterSymolizerElem.appendChild( globalContrastEnhancementElem );
1725 QDomElement gammaValueElem = doc.createElement( QStringLiteral(
"sld:GammaValue" ) );
1726 gammaValueElem.appendChild( doc.createTextNode( QString::number( gamma ) ) );
1727 globalContrastEnhancementElem.appendChild( gammaValueElem );
1760 if ( mDataProvider )
1767 if ( ! mDataProvider )
1768 return QStringList();
1776 QImage image( size, format );
1781 if ( image.format() == QImage::Format_Indexed8 )
1783 image.setColor( 0, bgColor.rgba() );
1788 image.fill( bgColor );
1793 double mapUnitsPerPixel;
1799 mapUnitsPerPixel =
extent.
width() / image.width();
1800 y = ( image.height() -
extent.
height() / mapUnitsPerPixel ) / 2;
1805 x = ( image.width() -
extent.
width() / mapUnitsPerPixel ) / 2;
1808 const double pixelWidth =
extent.
width() / mapUnitsPerPixel;
1809 const double pixelHeight =
extent.
height() / mapUnitsPerPixel;
1813 rasterViewPort->
mWidth = image.width();
1814 rasterViewPort->
mHeight = image.height();
1822 QPainter *painter =
new QPainter( &image );
1823 draw( painter, rasterViewPort, mapToPixel );
1824 delete rasterViewPort;
1846 Q_UNUSED( errorMessage )
1849 QDomElement rasterRendererElem;
1851 QDomElement layerElement = layer_node.toElement();
1858 QDomNode pipeNode = layer_node.firstChildElement( QStringLiteral(
"pipe" ) );
1859 if ( pipeNode.isNull() )
1861 pipeNode = layer_node;
1865 if ( !layer_node.firstChildElement( QStringLiteral(
"rasterproperties" ) ).isNull() )
1868 QDomNode layerNodeCopy = layer_node.cloneNode();
1869 QDomDocument doc = layerNodeCopy.ownerDocument();
1870 QDomElement rasterPropertiesElem = layerNodeCopy.firstChildElement( QStringLiteral(
"rasterproperties" ) );
1873 rasterRendererElem = layerNodeCopy.firstChildElement( QStringLiteral(
"rasterrenderer" ) );
1878 rasterRendererElem = pipeNode.firstChildElement( QStringLiteral(
"rasterrenderer" ) );
1881 if ( !rasterRendererElem.isNull() )
1883 QString rendererType = rasterRendererElem.attribute( QStringLiteral(
"type" ) );
1897 QDomElement brightnessElem = pipeNode.firstChildElement( QStringLiteral(
"brightnesscontrast" ) );
1898 if ( !brightnessElem.isNull() )
1908 QDomElement hueSaturationElem = pipeNode.firstChildElement( QStringLiteral(
"huesaturation" ) );
1909 if ( !hueSaturationElem.isNull() )
1919 QDomElement resampleElem = pipeNode.firstChildElement( QStringLiteral(
"rasterresampler" ) );
1920 if ( !resampleElem.isNull() )
1926 if ( mDataProvider )
1928 QDomElement providerElem = pipeNode.firstChildElement( QStringLiteral(
"provider" ) );
1929 if ( !providerElem.isNull() )
1931 mDataProvider->
readXml( providerElem );
1936 QDomNode resamplingStageElement = pipeNode.namedItem( QStringLiteral(
"resamplingStage" ) );
1937 if ( !resamplingStageElement.isNull() )
1939 QDomElement e = resamplingStageElement.toElement();
1940 if ( e.text() == QLatin1String(
"provider" ) )
1942 else if ( e.text() == QLatin1String(
"resamplingFilter" ) )
1947 QDomNode blendModeNode = layer_node.namedItem( QStringLiteral(
"blendMode" ) );
1948 if ( !blendModeNode.isNull() )
1950 QDomElement e = blendModeNode.toElement();
1961 return readSymbology( node, errorMessage, context, categories );
1970 QDomNode pkeyNode = layer_node.namedItem( QStringLiteral(
"provider" ) );
1972 if ( pkeyNode.isNull() )
1978 QDomElement pkeyElt = pkeyNode.toElement();
1992 QDomNode rpNode = layer_node.namedItem( QStringLiteral(
"rasterproperties" ) );
1998 if ( !
mDataSource.contains( QLatin1String(
"crs=" ) ) && !
mDataSource.contains( QLatin1String(
"format=" ) ) )
2000 QgsDebugMsgLevel( QStringLiteral(
"Old WMS URI format detected -> adding params" ), 4 );
2003 QDomElement layerElement = rpNode.firstChildElement( QStringLiteral(
"wmsSublayer" ) );
2004 while ( !layerElement.isNull() )
2009 uri.
setParam( QStringLiteral(
"layers" ), layerElement.namedItem( QStringLiteral(
"name" ) ).toElement().text() );
2012 uri.
setParam( QStringLiteral(
"styles" ), layerElement.namedItem( QStringLiteral(
"style" ) ).toElement().text() );
2014 layerElement = layerElement.nextSiblingElement( QStringLiteral(
"wmsSublayer" ) );
2018 uri.
setParam( QStringLiteral(
"format" ), rpNode.namedItem( QStringLiteral(
"wmsFormat" ) ).toElement().text() );
2022 uri.
setParam( QStringLiteral(
"crs" ),
crs().authid() );
2031 QgsDataProvider::ReadFlags
flags = QgsDataProvider::ReadFlags();
2039 const QDomNode extentNode = layer_node.namedItem( QStringLiteral(
"extent" ) );
2040 if ( !extentNode.isNull() )
2055 mOriginalStyleElement = layer_node.namedItem( QStringLiteral(
"originalStyle" ) ).firstChildElement();
2056 if ( mOriginalStyleElement.isNull() )
2057 mOriginalStyleElement = layer_node.toElement();
2058 mOriginalStyleDocument = layer_node.ownerDocument();
2060 if ( ! mDataProvider )
2084 QDomNode stampNode = layer_node.namedItem(
"timestamp" );
2085 if ( !stampNode.isNull() )
2087 QDateTime stamp = QDateTime::fromString( stampNode.toElement().text(), Qt::ISODate );
2089 if ( stamp < mDataProvider->dataTimestamp() )
2092 closeDataProvider();
2095 if ( !
isValid() )
return false;
2101 QDomElement noDataElement = layer_node.firstChildElement( QStringLiteral(
"noData" ) );
2103 QDomNodeList noDataBandList = noDataElement.elementsByTagName( QStringLiteral(
"noDataList" ) );
2105 for (
int i = 0; i < noDataBandList.size(); ++i )
2107 QDomElement bandElement = noDataBandList.at( i ).toElement();
2109 int bandNo = bandElement.attribute( QStringLiteral(
"bandNo" ) ).toInt( &ok );
2111 if ( ok && ( bandNo > 0 ) && ( bandNo <= mDataProvider->
bandCount() ) )
2113 mDataProvider->
setUseSourceNoDataValue( bandNo, bandElement.attribute( QStringLiteral(
"useSrcNoData" ) ).toInt() );
2116 QDomNodeList rangeList = bandElement.elementsByTagName( QStringLiteral(
"noDataRange" ) );
2118 myNoDataRangeList.reserve( rangeList.size() );
2119 for (
int j = 0; j < rangeList.size(); ++j )
2121 QDomElement rangeElement = rangeList.at( j ).toElement();
2122 QgsRasterRange myNoDataRange( rangeElement.attribute( QStringLiteral(
"min" ) ).toDouble(),
2123 rangeElement.attribute( QStringLiteral(
"max" ) ).toDouble() );
2124 QgsDebugMsgLevel( QStringLiteral(
"min = %1 %2" ).arg( rangeElement.attribute(
"min" ) ).arg( myNoDataRange.
min() ), 4 );
2125 myNoDataRangeList << myNoDataRange;
2139 Q_UNUSED( errorMessage )
2142 QDomElement layerElement = layer_node.toElement();
2147 QDomElement pipeElement = document.createElement( QStringLiteral(
"pipe" ) );
2149 for (
int i = 0; i < mPipe.
size(); i++ )
2152 if ( !interface )
continue;
2153 interface->
writeXml( document, pipeElement );
2156 QDomElement resamplingStageElement = document.createElement( QStringLiteral(
"resamplingStage" ) );
2158 resamplingStageElement.appendChild( resamplingStageText );
2159 pipeElement.appendChild( resamplingStageElement );
2161 layer_node.appendChild( pipeElement );
2163 if ( !
isValid() && !mOriginalStyleElement.isNull() )
2165 QDomElement originalStyleElement = document.createElement( QStringLiteral(
"originalStyle" ) );
2166 originalStyleElement.appendChild( mOriginalStyleElement );
2167 layer_node.appendChild( originalStyleElement );
2171 QDomElement blendModeElement = document.createElement( QStringLiteral(
"blendMode" ) );
2173 blendModeElement.appendChild( blendModeText );
2174 layer_node.appendChild( blendModeElement );
2182 return writeSymbology( node, doc, errorMessage, context, categories );
2190 QDomDocument &document,
2193 if ( !mDataProvider )
2198 QDomElement mapLayerNode = layer_node.toElement();
2200 if ( mapLayerNode.isNull() ||
"maplayer" != mapLayerNode.nodeName() )
2210 QDomElement provider = document.createElement( QStringLiteral(
"provider" ) );
2211 QDomText providerText = document.createTextNode(
mProviderKey );
2212 provider.appendChild( providerText );
2213 layer_node.appendChild( provider );
2216 QDomElement noData = document.createElement( QStringLiteral(
"noData" ) );
2218 for (
int bandNo = 1; bandNo <= mDataProvider->
bandCount(); bandNo++ )
2220 QDomElement noDataRangeList = document.createElement( QStringLiteral(
"noDataList" ) );
2221 noDataRangeList.setAttribute( QStringLiteral(
"bandNo" ), bandNo );
2222 noDataRangeList.setAttribute( QStringLiteral(
"useSrcNoData" ), mDataProvider->
useSourceNoDataValue( bandNo ) );
2224 const auto constUserNoDataValues = mDataProvider->
userNoDataValues( bandNo );
2227 QDomElement noDataRange = document.createElement( QStringLiteral(
"noDataRange" ) );
2231 noDataRangeList.appendChild( noDataRange );
2234 noData.appendChild( noDataRangeList );
2237 if ( noData.hasChildNodes() )
2239 layer_node.appendChild( noData );
2246 return writeSymbology( layer_node, document, errorMsg, context );
2250 static bool _parseGpkgColons(
const QString &src, QString &filename, QString &tablename )
2255 QStringList lst = src.split(
':' );
2256 if ( lst.count() != 3 && lst.count() != 4 )
2259 tablename = lst.last();
2260 if ( lst.count() == 3 )
2265 else if ( lst.count() == 4 && lst[1].count() == 1 && ( lst[2][0] ==
'/' || lst[2][0] ==
'\\' ) )
2268 filename = lst[1] +
":" + lst[2];
2278 bool handled =
false;
2283 if ( src.startsWith( QLatin1String(
"NETCDF:" ) ) )
2287 QRegExp r(
"NETCDF:(.+):([^:]+)" );
2288 if ( r.exactMatch( src ) )
2290 QString filename = r.cap( 1 );
2291 if ( filename.startsWith(
'"' ) && filename.endsWith(
'"' ) )
2292 filename = filename.mid( 1, filename.length() - 2 );
2297 else if ( src.startsWith( QLatin1String(
"GPKG:" ) ) )
2300 QString filename, tablename;
2301 if ( _parseGpkgColons( src, filename, tablename ) )
2304 src = QStringLiteral(
"GPKG:%1:%2" ).arg( filename, tablename );
2308 else if ( src.startsWith( QLatin1String(
"HDF4_SDS:" ) ) )
2312 QRegExp r(
"HDF4_SDS:([^:]+):(.+):([^:]+)" );
2313 if ( r.exactMatch( src ) )
2315 QString filename = r.cap( 2 );
2316 if ( filename.startsWith(
'"' ) && filename.endsWith(
'"' ) )
2317 filename = filename.mid( 1, filename.length() - 2 );
2318 src =
"HDF4_SDS:" + r.cap( 1 ) +
":\"" + context.
pathResolver().
writePath( filename ) +
"\":" + r.cap( 3 );
2322 else if ( src.startsWith( QLatin1String(
"HDF5:" ) ) )
2326 QRegExp r(
"HDF5:(.+):([^:]+)" );
2327 if ( r.exactMatch( src ) )
2329 QString filename = r.cap( 1 );
2330 if ( filename.startsWith(
'"' ) && filename.endsWith(
'"' ) )
2331 filename = filename.mid( 1, filename.length() - 2 );
2336 else if ( src.contains( QRegExp(
"^(NITF_IM|RADARSAT_2_CALIB):" ) ) )
2340 QRegExp r(
"([^:]+):([^:]+):(.+)" );
2341 if ( r.exactMatch( src ) )
2353 QUrl srcUrl( uri.
param( QStringLiteral(
"url" ) ) );
2354 if ( srcUrl.isLocalFile() )
2359 uri.
setParam( QStringLiteral(
"url" ), QUrl::fromLocalFile( relSrcUrl ).toString() );
2375 if ( provider == QLatin1String(
"wms" ) )
2389 if ( !src.contains( QLatin1String(
"type=" ) ) &&
2390 !src.contains( QLatin1String(
"crs=" ) ) && !src.contains( QLatin1String(
"format=" ) ) )
2392 QgsDebugMsgLevel( QStringLiteral(
"Old WMS URI format detected -> converting to new format" ), 2 );
2394 if ( !src.startsWith( QLatin1String(
"http:" ) ) )
2396 QStringList parts = src.split(
',' );
2397 QStringListIterator iter( parts );
2398 while ( iter.hasNext() )
2400 QString item = iter.next();
2401 if ( item.startsWith( QLatin1String(
"username=" ) ) )
2405 else if ( item.startsWith( QLatin1String(
"password=" ) ) )
2409 else if ( item.startsWith( QLatin1String(
"tiled=" ) ) )
2415 QStringList params = item.mid( 6 ).split(
';' );
2417 if ( params.size() == 2 )
2419 uri.
setParam( QStringLiteral(
"maxWidth" ), params.takeFirst() );
2420 uri.
setParam( QStringLiteral(
"maxHeight" ), params.takeFirst() );
2422 else if ( params.size() > 2 )
2426 uri.
setParam( QStringLiteral(
"tileMatrixSet" ), QString() );
2429 else if ( item.startsWith( QLatin1String(
"featureCount=" ) ) )
2431 uri.
setParam( QStringLiteral(
"featureCount" ), item.mid( 13 ) );
2433 else if ( item.startsWith( QLatin1String(
"url=" ) ) )
2435 uri.
setParam( QStringLiteral(
"url" ), item.mid( 4 ) );
2437 else if ( item.startsWith( QLatin1String(
"ignoreUrl=" ) ) )
2439 uri.
setParam( QStringLiteral(
"ignoreUrl" ), item.mid( 10 ).split(
';' ) );
2445 uri.
setParam( QStringLiteral(
"url" ), src );
2456 QUrl srcUrl( uri.
param( QStringLiteral(
"url" ) ) );
2457 if ( srcUrl.isLocalFile() )
2461 uri.
setParam( QStringLiteral(
"url" ), QUrl::fromLocalFile( absSrcUrl ).toString() );
2468 bool handled =
false;
2470 if ( provider == QLatin1String(
"gdal" ) )
2472 if ( src.startsWith( QLatin1String(
"NETCDF:" ) ) )
2476 QRegExp r(
"NETCDF:(.+):([^:]+)" );
2477 if ( r.exactMatch( src ) )
2479 QString filename = r.cap( 1 );
2480 if ( filename.startsWith(
'"' ) && filename.endsWith(
'"' ) )
2481 filename = filename.mid( 1, filename.length() - 2 );
2486 else if ( src.startsWith( QLatin1String(
"GPKG:" ) ) )
2489 QString filename, tablename;
2490 if ( _parseGpkgColons( src, filename, tablename ) )
2493 src = QStringLiteral(
"GPKG:%1:%2" ).arg( filename, tablename );
2497 else if ( src.startsWith( QLatin1String(
"HDF4_SDS:" ) ) )
2501 QRegExp r(
"HDF4_SDS:([^:]+):(.+):([^:]+)" );
2502 if ( r.exactMatch( src ) )
2504 QString filename = r.cap( 2 );
2505 if ( filename.startsWith(
'"' ) && filename.endsWith(
'"' ) )
2506 filename = filename.mid( 1, filename.length() - 2 );
2507 src =
"HDF4_SDS:" + r.cap( 1 ) +
":\"" + context.
pathResolver().
readPath( filename ) +
"\":" + r.cap( 3 );
2511 else if ( src.startsWith( QLatin1String(
"HDF5:" ) ) )
2515 QRegExp r(
"HDF5:(.+):([^:]+)" );
2516 if ( r.exactMatch( src ) )
2518 QString filename = r.cap( 1 );
2519 if ( filename.startsWith(
'"' ) && filename.endsWith(
'"' ) )
2520 filename = filename.mid( 1, filename.length() - 2 );
2525 else if ( src.contains( QRegExp(
"^(NITF_IM|RADARSAT_2_CALIB):" ) ) )
2529 QRegExp r(
"([^:]+):([^:]+):(.+)" );
2530 if ( r.exactMatch( src ) )
2547 if ( !mDataProvider )
return 0;
2548 return mDataProvider->
xSize();
2553 if ( !mDataProvider )
return 0;
2554 return mDataProvider->
ySize();
2567 bool QgsRasterLayer::update()
2574 closeDataProvider();
2577 QgsDataProvider::ReadFlags
flags = QgsDataProvider::ReadFlags();
static QString version()
Version string.
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.
@ 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)
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 and new RGB value based on one input value.
@ Interpolated
Interpolates the color between two class breaks linearly.
@ Discrete
Assigns the color of the higher class for every pixel between two class breaks.
void classifyColorRamp(int classes=0, int band=-1, const QgsRectangle &extent=QgsRectangle(), QgsRasterInterface *input=nullptr)
Classify color ramp shader.
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &list)
Sets a custom colormap.
void setColorRampType(QgsColorRampShader::Type colorRampType)
Sets the color ramp type.
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).
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
Contains information about the context in which a coordinate transform is executed.
Abstract base class for spatial data provider implementations.
virtual void setLayerOrder(const QStringList &layers)
Reorder the list of layer names to be rendered by this provider (in order from bottom to top)
@ FlagLoadDefaultStyle
Reset the layer's style to the default for the datasource.
@ FlagTrustDataSource
Trust datasource config (primary key unicity, geometry type and srid, etc). Improves provider load ti...
@ SkipGetExtent
Skip the extent from provider.
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
virtual QString subsetString() const
Returns the subset definition string (typically sql) currently in use by the layer and used by the pr...
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 supportsSubsetString() const
Returns true if the provider supports setting of subset strings.
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
virtual bool setSubsetString(const QString &subset, bool updateFeatureCount=true)
Set the subset string used to create a subset of features in the layer.
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.
int removeParam(const QString &key)
Removes a generic parameter by key.
void setEncodedUri(const QByteArray &uri)
Sets the complete encoded uri.
void setUsername(const QString &username)
Sets the username for the URI.
QString param(const QString &key) const
Returns a generic parameter value corresponding to the specified key.
void setParam(const QString &key, const QString &value)
Sets a generic parameter value on the URI.
void setPassword(const QString &password)
Sets the password for the URI.
Color and saturation filter pipe for rasters.
QgsHueSaturationFilter::GrayscaleMode grayscaleMode() const
void readXml(const QDomElement &filterElem) override
Sets base class members from xml. Usually called from create() methods of subclasses.
static QString typeToString(QgsMapLayerType 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.
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.
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example,...
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
QgsCoordinateReferenceSystem crs
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...
QString mLayerName
Name of the layer - used for display.
QString crsHtmlMetadata() const
Returns a HTML fragment containing the layer's CRS metadata, for use in the htmlMetadata() method.
QgsLayerMetadata metadata
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)
void readCustomProperties(const QDomNode &layerNode, const QString &keyStartsWith=QString())
Read custom properties from project file.
virtual void setMetadata(const QgsLayerMetadata &metadata)
Sets the layer's metadata store.
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...
void rendererChanged()
Signal emitted when renderer is changed.
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.
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
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...
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.
@ 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.
void setDataSource(const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag=false)
Updates the data source of the layer.
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 setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
void setProviderType(const QString &providerType)
Sets the providerType (provider key)
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.
const QgsContrastEnhancement * redContrastEnhancement() const
Returns the contrast enhancement to use for the red channel.
const QgsContrastEnhancement * blueContrastEnhancement() const
Returns the contrast enhancement to use for the blue channel.
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 * greenContrastEnhancement() const
Returns the contrast enhancement to use for the green channel.
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer.
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.
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
The RasterBandStats struct is a container for statistics about a single raster band.
int statsGathered
Collected statistics.
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.
double maximumValue
The maximum cell value in the raster band.
static int typeSize(Qgis::DataType dataType) SIP_HOLDGIL
Returns the size in bytes for the specified dataType.
static QString printValue(double value)
Print double value with all necessary significant digits.
Base class for raster data providers.
virtual QList< QgsColorRampShader::ColorRampItem > colorTable(int bandNo) const
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.
void readXml(const QDomElement &filterElem) override
Sets base class members from xml. Usually called from create() methods of subclasses.
virtual QgsRasterDataProvider::ProviderCapabilities providerCapabilities() const
Returns flags containing the supported capabilities of the data provider.
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.
QStringList subLayers() const override
Returns the sublayers of this layer - useful for providers that manage their own layers,...
static QString identifyFormatName(QgsRaster::IdentifyFormat format)
@ ReadLayerMetadata
Provider can read layer metadata from data store. Since QGIS 3.0. See QgsDataProvider::layerMetadata(...
@ ProviderHintBenefitsFromResampling
Provider benefits from resampling and should apply user default resampling settings (since QGIS 3....
@ ProviderHintCanPerformProviderResampling
Provider can perform resampling (to be opposed to post rendering resampling) (since QGIS 3....
QDateTime dataTimestamp() const override
Current time stamp of data source.
virtual QString htmlMetadata()=0
Returns metadata in a format suitable for feeding directly into a subset of the GUI raster properties...
virtual int colorInterpretation(int bandNo) const
Returns data type for the band specified by number.
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.
virtual bool setZoomedInResamplingMethod(ResamplingMethod method)
Set resampling method to apply for zoomed-in operations.
QgsRasterDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
@ Bilinear
Bilinear (2x2 kernel) resampling.
@ Cubic
Cubic Convolution Approximation (4x4 kernel) resampling.
virtual void setUserNoDataValue(int bandNo, const QgsRasterRangeList &noData)
virtual bool setZoomedOutResamplingMethod(ResamplingMethod method)
Set resampling method to apply for zoomed-out operations.
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 QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
@ IdentifyValue
Numerical values.
@ IdentifyFeature
WMS GML -> feature.
@ Size
Original data source size (and thus resolution) is known, it is not always available,...
virtual QgsRasterInterface * input() const
Current input.
virtual int xSize() const
Gets raster size.
virtual QString generateBandName(int bandNumber) const
helper function to create zero padded band names
virtual int bandCount() const =0
Gets number of bands.
virtual QgsRasterBandStats bandStatistics(int bandNo, int stats=QgsRasterBandStats::All, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, QgsRasterBlockFeedback *feedback=nullptr)
Returns the band statistics.
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).
virtual int capabilities() const
Returns a bitmask containing the supported capabilities.
virtual int ySize() const
virtual void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
Iterator for sequentially processing raster cells.
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 defaultContrastEnhancementSettings(QgsContrastEnhancement::ContrastEnhancementAlgorithm &myAlgorithm, QgsRasterMinMaxOrigin::Limits &myLimits) const
Returns default contrast enhancement settings for that type of raster.
void subsetStringChanged()
Emitted when the layer's subset string has changed.
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...
QgsRasterPipe::ResamplingStage resamplingStage() const
Returns which stage of the pipe should apply resampling.
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)
virtual bool setSubsetString(const QString &subset)
Sets the string (typically sql) used to define a subset of the layer.
bool writeSymbology(QDomNode &, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) const override
QgsRasterLayer * clone() const override
Returns a new instance equivalent to this one.
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 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....
Q_DECL_DEPRECATED void setDataProvider(const QString &provider)
Set the data provider.
QgsRasterPipe * pipe()
Returns the raster pipe.
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.
void refreshRendererIfNeeded(QgsRasterRenderer *rasterRenderer, const QgsRectangle &extent)
Refresh renderer with new extent, if needed.
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...
QgsHueSaturationFilter * hueSaturationFilter() const
Returns the raster's hue/saturation filter.
void setSubLayerVisibility(const QString &name, bool vis) override
Set the visibility of the given sublayer name.
virtual QString subsetString() const
Returns the string (typically sql) used to define a subset of the layer.
static const QgsRasterMinMaxOrigin::Limits SINGLE_BAND_MIN_MAX_LIMITS
Default enhancement limits for single band raster.
static const QgsRasterMinMaxOrigin::Limits MULTIPLE_BAND_MULTI_BYTE_MIN_MAX_LIMITS
Default enhancement limits for multiple band raster of type different from Byte.
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
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.
void setDefaultContrastEnhancement()
Sets the default contrast enhancement.
static const double SAMPLE_SIZE
Default sample size (number of pixels) for estimated statistics/histogram calculation.
static const QgsRasterMinMaxOrigin::Limits MULTIPLE_BAND_SINGLE_BYTE_MIN_MAX_LIMITS
Default enhancement limits for multiple band raster of type Byte.
static const QgsContrastEnhancement::ContrastEnhancementAlgorithm MULTIPLE_BAND_MULTI_BYTE_ENHANCEMENT_ALGORITHM
Default enhancement algorithm for multiple band raster of type different from 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.
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.
bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) override
QgsRasterResampleFilter * resampleFilter() const
Returns the raster's resample filter.
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
void setResamplingStage(QgsRasterPipe::ResamplingStage stage)
Select which stage of the pipe should apply resampling.
QgsBrightnessContrastFilter * brightnessFilter() const
Returns the raster's brightness/contrast filter.
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
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 readStyle(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) override
QPixmap paletteAsPixmap(int bandNumber=1)
Returns a 100x100 pixmap of the color palette.
This class describes the origin of min/max values.
void setExtent(QgsRasterMinMaxOrigin::Extent extent)
Sets the extent.
static QString limitsString(Limits limits)
Returns a string to serialize Limits.
double cumulativeCutLower() const
Returns the lower bound of cumulative cut method (between 0 and 1).
QgsRasterMinMaxOrigin::Limits limits() const
Returns the raster limits.
double stdDevFactor() const
Returns the factor f so that the min/max range is [ mean - f * stddev , mean + f * stddev ].
void setLimits(QgsRasterMinMaxOrigin::Limits limits)
Sets the limits.
@ UpdatedCanvas
Constantly updated extent of the canvas is used to compute statistics.
@ CurrentCanvas
Current extent of the canvas (at the time of computation) is used to compute statistics.
@ WholeRaster
Whole raster is used to compute statistics.
double cumulativeCutUpper() const
Returns the upper bound of cumulative cut method (between 0 and 1).
Limits
This enumerator describes the limits used to compute min/max values.
@ StdDev
Range is [ mean - stdDevFactor() * stddev, mean + stdDevFactor() * stddev ].
@ MinMax
Real min-max values.
@ CumulativeCut
Range is [ min + cumulativeCutLower() * (max - min), min + cumulativeCutUpper() * (max - min) ].
static Limits limitsFromString(const QString &limits)
Deserialize Limits.
QgsRasterMinMaxOrigin::Extent extent() const
Returns the raster extent.
bool set(QgsRasterInterface *interface)
Insert a new known interface in default place or replace interface of the same role if it already exi...
ResamplingStage
Stage at which resampling occurs.
@ Provider
Resampling occurs in Provider.
@ ResampleFilter
Resampling occurs in ResamplingFilter.
QgsRasterProjector * projector() const
bool remove(int idx)
Remove and delete interface at given index if possible.
QgsRasterInterface * last() const
QgsRasterRenderer * renderer() const
void setResamplingStage(ResamplingStage stage)
Select which stage of the pipe should apply resampling.
QgsRasterInterface * at(int idx) const
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
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
void setMinMaxOrigin(const QgsRasterMinMaxOrigin &origin)
Sets origin of min/max values.
double opacity() const
Returns the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
void setOpacity(double opacity)
Sets the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
const QgsRasterMinMaxOrigin & minMaxOrigin() const
Returns const reference to origin of min/max values.
virtual void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const
Used from subclasses to create SLD Rule elements following SLD v1.0 specs.
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.
QgsRasterShaderFunction * rasterShaderFunction()
void setRasterShaderFunction(QgsRasterShaderFunction *function)
A public method that allows the user to set their own shader function.
@ IdentifyFormatUndefined
@ PaletteIndex
Paletted (see associated color table)
@ AlphaBand
Alpha (0=transparent, 255=opaque)
@ ContinuousPalette
Continuous palette, QGIS addition, GRASS.
DrawingStyle
This enumerator describes the different kinds of drawing we can do.
@ SingleBandColorDataStyle
The class is used as a container of context for various read/write operations on other objects.
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.
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
double height() const SIP_HOLDGIL
Returns the height of the rectangle.
double width() const SIP_HOLDGIL
Returns the width of the rectangle.
bool isEmpty() const
Returns true if the rectangle is empty.
Contains information about the context of a rendering operation.
Raster renderer pipe for single band gray.
void setContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
const QgsContrastEnhancement * contrastEnhancement() const
Raster renderer pipe for single band pseudocolor.
void setClassificationMin(double min)
int band() const
Returns the band used by the renderer.
QgsRasterShader * shader()
Returns the raster shader.
void setShader(QgsRasterShader *shader)
Takes ownership of the shader.
void setClassificationMax(double max)
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)
QgsMapLayerType
Types of layers that can be added to a map.
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
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
#define QgsDebugMsgLevel(str, level)
QgsDataProvider * classFactoryFunction_t(const QString *, const QgsDataProvider::ProviderOptions &options)
QList< QPair< QString, QColor > > QgsLegendColorList
QList< QgsRasterRange > QgsRasterRangeList
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 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 coordinate system.
QgsRectangle mDrawnExtent
Intersection of current map extent and layer extent.
QgsCoordinateTransformContext mTransformContext
Coordinate transform context.
qgssize mWidth
Width, number of columns to be rendered.