70 #include <QStringList>    71 #include <QTemporaryFile>   107           if ( legendNode->data( Qt::DisplayRole ).toString() == rule )
   120     : mWmsParameters( parameters )
   121 #ifdef HAVE_SERVER_PYTHON_PLUGINS
   122     , mAccessControl( serverIface->accessControls() )
   124     , mSettings( *serverIface->serverSettings() )
   125     , mProject( project )
   127     mWmsParameters.
dump();
   129     initRestrictedLayers();
   130     initNicknameLayers();
   135     removeTemporaryLayers();
   144                                     QStringLiteral( 
"LAYER is mandatory for GetLegendGraphic operation" ) );
   146     if ( mWmsParameters.
format() == QgsWmsParameters::Format::NONE )
   148                                     QStringLiteral( 
"FORMAT is mandatory for GetLegendGraphic operation" ) );
   150     double scaleDenominator = -1;
   151     if ( ! mWmsParameters.
scale().isEmpty() )
   157     std::unique_ptr<QgsLayerRestorer> restorer;
   160     QList<QgsMapLayer *> layers;
   163     QString sld = mWmsParameters.
sldBody();
   164     if ( !sld.isEmpty() )
   165       layers = sldStylizedLayers( sld );
   167       layers = stylizedLayers( params );
   169     removeUnwantedLayers( layers, scaleDenominator );
   170     std::reverse( layers.begin(), layers.end() );
   174       checkLayerReadPermissions( ml );
   178     std::unique_ptr<QgsLayerTreeModel> legendModel;
   179     legendModel.reset( buildLegendTreeModel( layers, scaleDenominator, rootGroup ) );
   182     qreal dpmm = dotsPerMm();
   183     std::unique_ptr<QImage> image;
   184     std::unique_ptr<QPainter> painter;
   186     if ( !mWmsParameters.
rule().isEmpty() )
   188       QString rule = mWmsParameters.
rule();
   192       image.reset( createImage( width, height, 
false ) );
   193       painter.reset( 
new QPainter( image.get() ) );
   194       painter->setRenderHint( QPainter::Antialiasing, 
true );
   195       painter->scale( dpmm, dpmm );
   203         ctx.
point = QPointF();
   204         double itemHeight = height / dpmm;
   205         legendNode->
drawSymbol( legendSettings, &ctx, itemHeight );
   214       QSize s( minSize.width() * dpmm, minSize.height() * dpmm );
   216       image.reset( createImage( s.width(), s.height(), false ) );
   217       painter.reset( 
new QPainter( image.get() ) );
   218       painter->setRenderHint( QPainter::Antialiasing, 
true );
   219       painter->scale( dpmm, dpmm );
   221       legendRendererNew.drawLegend( painter.get() );
   226     return image.release();
   233     for ( 
const QString &
id : mapSettings.
layerIds() )
   250       runHitTestLayer( vl, usedSymbols, context );
   256     std::unique_ptr< QgsFeatureRenderer > r( vl->
renderer()->
clone() );
   258     r->startRender( context, vl->
fields() );
   266       if ( moreSymbolsPerFeature )
   268         for ( 
QgsSymbol *s : r->originalSymbolsForFeature( f, context ) )
   274     r->stopRender( context );
   282     if ( templateName.isEmpty() )
   285                                     QStringLiteral( 
"The TEMPLATE parameter is required for the GetPrint request" ) );
   289     QList<QgsMapLayer *> layers;
   294     std::unique_ptr<QImage> image( 
new QImage() );
   298     configureMapSettings( image.get(), mapSettings );
   301     std::unique_ptr<QgsLayerRestorer> restorer;
   305     QString sld = mWmsParameters.
sldBody();
   306     if ( !sld.isEmpty() )
   308       layers = sldStylizedLayers( sld );
   312       layers = stylizedLayers( params );
   316     removeUnwantedLayers( layers );
   319     bool updateMapExtent = mWmsParameters.
bbox().isEmpty();
   322       checkLayerReadPermissions( layer );
   326         if ( param.mNickname == layerNickname( *layer ) )
   328           setLayerOpacity( layer, param.mOpacity );
   330           setLayerFilter( layer, param.mFilter );
   332           setLayerSelection( layer, param.mSelection );
   334           if ( updateMapExtent )
   335             updateExtent( layer, mapSettings );
   341       setLayerAccessControlFilter( layer );
   348     std::reverse( layers.begin(), layers.end() );
   356                                     QStringLiteral( 
"Template '%1' is not known" ).arg( templateName ) );
   363                                     QStringLiteral( 
"Template '%1' has no pages" ).arg( templateName ) );
   366     std::unique_ptr<QgsPrintLayout> layout( sourceLayout->
clone() );
   370     QStringList atlasPk = mWmsParameters.
atlasPk();
   371     if ( !atlasPk.isEmpty() ) 
   373       atlas = layout->atlas();
   374       if ( !atlas || !atlas->enabled() )
   378                                       QStringLiteral( 
"The template has no atlas enabled" ) );
   385                                       QStringLiteral( 
"The atlas has no coverage layer" ) );
   389       if ( atlasPk.size() == 1 && atlasPk.at( 0 ) == QStringLiteral( 
"*" ) )
   391         atlas->setFilterFeatures( 
false );
   392         atlas->updateFeatures();
   393         if ( atlas->count() > maxAtlasFeatures )
   396                                         QString( 
"The project configuration allows printing maximum %1 atlas features at a time" ).arg( maxAtlasFeatures ) );
   402         if ( pkIndexes.size() < 1 )
   405                                         QStringLiteral( 
"An error occurred during the Atlas print" ) );
   407         QStringList pkAttributeNames;
   408         for ( 
int i = 0; i < pkIndexes.size(); ++i )
   410           pkAttributeNames.append( cLayer->
fields()[pkIndexes.at( i )].name() );
   413         int nAtlasFeatures = atlasPk.size() / pkIndexes.size();
   414         if ( nAtlasFeatures * pkIndexes.size() != atlasPk.size() ) 
   417                                         QStringLiteral( 
"Wrong number of ATLAS_PK parameters" ) );
   421         if ( nAtlasFeatures > maxAtlasFeatures )
   424                                         QString( 
"%1 atlas features have been requestet, but the project configuration only allows printing %2 atlas features at a time" )
   425                                         .arg( nAtlasFeatures ).arg( maxAtlasFeatures ) );
   428         QString filterString;
   429         int currentAtlasPk = 0;
   431         for ( 
int i = 0; i < nAtlasFeatures; ++i )
   435             filterString.append( 
" OR " );
   438           filterString.append( 
"( " );
   440           for ( 
int j = 0; j < pkIndexes.size(); ++j )
   444               filterString.append( 
" AND " );
   446             filterString.append( QString( 
"\"%1\" = %2" ).arg( pkAttributeNames.at( j ) ).arg( atlasPk.at( currentAtlasPk ) ) );
   450           filterString.append( 
" )" );
   453         atlas->setFilterFeatures( 
true );
   455         atlas->setFilterExpression( filterString, errorString );
   456         if ( !errorString.isEmpty() )
   459                                         QStringLiteral( 
"An error occurred during the Atlas print" ) );
   464     configurePrintLayout( layout.get(), mapSettings, atlas );
   467     QTemporaryFile tempOutputFile( QDir::tempPath() +  
'/' + QStringLiteral( 
"XXXXXX.%1" ).arg( formatString.toLower() ) );
   468     if ( !tempOutputFile.open() )
   470       throw QgsServerException( QStringLiteral( 
"Could not open temporary file for the GetPrint request." ) );
   475     if ( formatString.compare( QLatin1String( 
"svg" ), Qt::CaseInsensitive ) == 0 )
   479       if ( !mWmsParameters.
dpi().isEmpty() )
   482         double dpi( mWmsParameters.
dpi().toDouble( &ok ) );
   484           exportSettings.
dpi = dpi;
   491         atlas->beginRender();
   495           atlasSvgExport.
exportToSvg( tempOutputFile.fileName(), exportSettings );
   501         exporter.
exportToSvg( tempOutputFile.fileName(), exportSettings );
   504     else if ( formatString.compare( QLatin1String( 
"png" ), Qt::CaseInsensitive ) == 0 || formatString.compare( QLatin1String( 
"jpg" ), Qt::CaseInsensitive ) == 0 )
   509       double dpi( layout->renderContext().dpi( ) );
   510       if ( !mWmsParameters.
dpi().isEmpty() )
   513         double _dpi = mWmsParameters.
dpi().toDouble( &ok );
   517       exportSettings.
dpi = dpi;
   521       QgsLayoutSize layoutSize( layout->pageCollection()->page( 0 )->sizeWithUnits() );
   522       QgsLayoutMeasurement width( layout->convertFromLayoutUnits( layoutSize.width(), QgsUnitTypes::LayoutUnit::LayoutMillimeters ) );
   523       QgsLayoutMeasurement height( layout->convertFromLayoutUnits( layoutSize.height(), QgsUnitTypes::LayoutUnit::LayoutMillimeters ) );
   524       exportSettings.
imageSize = QSize( static_cast<int>( width.length() * dpi / 25.4 ), static_cast<int>( height.
length() * dpi / 25.4 ) );
   526       exportSettings.
pages.append( 0 );
   530         atlas->beginRender();
   534           atlasPngExport.
exportToImage( tempOutputFile.fileName(), exportSettings );
   540         exporter.
exportToImage( tempOutputFile.fileName(), exportSettings );
   543     else if ( formatString.compare( QLatin1String( 
"pdf" ), Qt::CaseInsensitive ) == 0 )
   548       if ( !mWmsParameters.
dpi().isEmpty() )
   551         double dpi( mWmsParameters.
dpi().toDouble( &ok ) );
   553           exportSettings.
dpi = dpi;
   558       exportSettings.
rasterizeWholeImage = layout->customProperty( QStringLiteral( 
"rasterize" ), 
false ).toBool();
   564         exporter.
exportToPdf( atlas, tempOutputFile.fileName(), exportSettings, exportError );
   568         exporter.exportToPdf( tempOutputFile.fileName(), exportSettings );
   574                                     QStringLiteral( 
"Output format '%1' is not supported in the GetPrint request" ).arg( formatString ) );
   579       handlePrintErrors( atlas->layout() );
   583       handlePrintErrors( layout.get() );
   586     return tempOutputFile.readAll();
   593     QList<QgsLayoutItemMap *> maps;
   599     for ( 
const auto &map : qgis::as_const( maps ) )
   604       if ( !atlasPrint || !map->atlasDriven() ) 
   628         if ( cMapParams.
mScale > 0 )
   630           map->setScale( cMapParams.
mScale );
   636           map->setMapRotation( cMapParams.
mRotation );
   640       if ( !map->keepLayerSet() )
   642         if ( cMapParams.
mLayers.isEmpty() )
   644           map->setLayers( mapSettings.
layers() );
   648           QList<QgsMapLayer *> layerSet = stylizedLayers( cMapParams.
mLayers );
   650           std::reverse( layerSet.begin(), layerSet.end() );
   651           map->setLayers( layerSet );
   653         map->setKeepLayerSet( 
true );
   659         map->grid()->setIntervalX( cMapParams.
mGridX );
   660         map->grid()->setIntervalY( cMapParams.
mGridY );
   665     QList<QgsLayoutItemLabel *> labels;
   667     for ( 
const auto &label : qgis::as_const( labels ) )
   670       const QString labelId = label->
id();
   671       const QString labelParam = mWmsParameters.
layoutParameter( labelId, ok );
   676       if ( labelParam.isEmpty() )
   680         c->removeItem( label );
   685       label->setText( labelParam );
   689     QList<QgsLayoutItemHtml *> htmls;
   691     for ( 
const auto &html : qgis::as_const( htmls ) )
   693       if ( html->frameCount() == 0 )
   698       const QString htmlId = htmlFrame->
id();
   717       html->setUrl( newUrl );
   723     QList<QgsLayoutItemLegend *> legends;
   725     for ( 
const auto &legend : qgis::as_const( legends ) )
   727       if ( legend->autoUpdateModel() )
   737         legend->setAutoUpdateModel( 
false );
   741         QStringList layerSet;
   742         const QList<QgsMapLayer *> layerList( map->
layers() );
   743         for ( 
const auto &layer : layerList )
   744           layerSet << layer->id();
   756         for ( 
const auto &layerId : layerIds )
   763           if ( !layerSet.contains( layerId ) )
   785     return getMap( mapSettings, hitTest );
   791     if ( !checkMaximumWidthHeight() )
   794                                     QStringLiteral( 
"The requested map size is too large" ) );
   798     QList<QgsMapLayer *> layers;
   802     std::unique_ptr<QgsLayerRestorer> restorer;
   806     QString sld = mWmsParameters.
sldBody();
   807     if ( !sld.isEmpty() )
   809       layers = sldStylizedLayers( sld );
   813       layers = stylizedLayers( params );
   817     removeUnwantedLayers( layers );
   820     bool updateMapExtent = mWmsParameters.
bbox().isEmpty();
   823       checkLayerReadPermissions( layer );
   827         if ( param.mNickname == layerNickname( *layer ) )
   829           setLayerOpacity( layer, param.mOpacity );
   831           setLayerFilter( layer, param.mFilter );
   833           setLayerSelection( layer, param.mSelection );
   835           if ( updateMapExtent )
   836             updateExtent( layer, mapSettings );
   842       setLayerAccessControlFilter( layer );
   849     std::unique_ptr<QPainter> painter;
   850     std::unique_ptr<QImage> image( createImage() );
   853     configureMapSettings( image.get(), mapSettings );
   856     std::reverse( layers.begin(), layers.end() );
   860     painter.reset( layersRendering( mapSettings, *image, hitTest ) );
   863     annotationsRendering( painter.get() );
   869     QImage *scaledImage = scaleImage( image.get() );
   871       image.reset( scaledImage );
   874     return image.release();
   886     QList<QgsMapLayer *> layers;
   890     std::unique_ptr<QgsLayerRestorer> restorer;
   894     QString sld = mWmsParameters.
sldBody();
   895     if ( !sld.isEmpty() )
   897       layers = sldStylizedLayers( sld );
   901       layers = stylizedLayers( params );
   905     QStringList layerAttributes;
   906     QMap<QString, QString>::const_iterator layerAttributesIt = options.find( QStringLiteral( 
"LAYERATTRIBUTES" ) );
   907     if ( layerAttributesIt != options.constEnd() )
   909       layerAttributes = options.value( QStringLiteral( 
"LAYERATTRIBUTES" ) ).split( 
',' );
   916     QList< QgsDxfExport::DxfLayer > dxfLayers;
   923       if ( !wfsLayerIds.contains( layer->id() ) )
   926       checkLayerReadPermissions( layer );
   930         if ( param.mNickname == layerNickname( *layer ) )
   932           setLayerOpacity( layer, param.mOpacity );
   934           setLayerFilter( layer, param.mFilter );
   940       setLayerAccessControlFilter( layer );
   946       int layerAttribute = -1;
   947       if ( layerAttributes.size() > layerIdx )
   961     QMap<QString, QString>::const_iterator modeIt = options.find( QStringLiteral( 
"MODE" ) );
   964     if ( modeIt == options.constEnd() )
   970       if ( modeIt->compare( QStringLiteral( 
"SymbolLayerSymbology" ), Qt::CaseInsensitive ) == 0 )
   974       else if ( modeIt->compare( QStringLiteral( 
"FeatureSymbology" ), Qt::CaseInsensitive ) == 0 )
   986     QMap<QString, QString>::const_iterator scaleIt = options.find( QStringLiteral( 
"SCALE" ) );
   987     if ( scaleIt != options.constEnd() )
   998     if ( i < 0 || i > mapSettings.
outputSize().width() || j < 0 || j > mapSettings.
outputSize().height() )
  1014     if ( queryLayers.isEmpty() )
  1016       QString msg = QObject::tr( 
"QUERY_LAYERS parameter is required for GetFeatureInfo" );
  1021     const bool ijDefined = !mWmsParameters.
i().isEmpty() && !mWmsParameters.
j().isEmpty();
  1022     const bool xyDefined = !mWmsParameters.
x().isEmpty() && !mWmsParameters.
y().isEmpty();
  1023     const bool filtersDefined = !mWmsParameters.
filters().isEmpty();
  1024     const bool filterGeomDefined = !mWmsParameters.
filterGeom().isEmpty();
  1026     if ( !ijDefined && !xyDefined && !filtersDefined && !filterGeomDefined )
  1029                                     QStringLiteral( 
"I/J parameters are required for GetFeatureInfo" ) );
  1033     if ( infoFormat == QgsWmsParameters::Format::NONE )
  1036                                     QStringLiteral( 
"Invalid INFO_FORMAT parameter" ) );
  1040     QList<QgsMapLayer *> layers;
  1044     std::unique_ptr<QgsLayerRestorer> restorer;
  1048     QString sld = mWmsParameters.
sldBody();
  1049     if ( !sld.isEmpty() )
  1050       layers = sldStylizedLayers( sld );
  1052       layers = stylizedLayers( params );
  1055     for ( 
const QString &queryLayer : queryLayers )
  1057       if ( mNicknameLayers.contains( queryLayer )
  1058            && !layers.contains( mNicknameLayers[queryLayer] ) )
  1060         layers.append( mNicknameLayers[queryLayer] );
  1065     int imageWidth = mWmsParameters.
widthAsInt();
  1076     std::unique_ptr<QImage> outputImage( createImage( imageWidth, imageHeight ) );
  1079     configureMapSettings( outputImage.get(), mapSettings );
  1088     double scaleDenominator = scaleCalc.calculate( mapExtent, outputImage->width() );
  1091     removeUnwantedLayers( layers, scaleDenominator );
  1097       checkLayerReadPermissions( layer );
  1101         if ( param.mNickname == layerNickname( *layer ) )
  1103           setLayerFilter( layer, param.mFilter );
  1109       setLayerAccessControlFilter( layer );
  1113     std::reverse( layers.begin(), layers.end() );
  1116     QDomDocument result = featureInfoDocument( layers, mapSettings, outputImage.get(), version );
  1120     if ( infoFormat == QgsWmsParameters::Format::TEXT )
  1121       ba = convertFeatureInfoToText( result );
  1122     else if ( infoFormat == QgsWmsParameters::Format::HTML )
  1123       ba = convertFeatureInfoToHtml( result );
  1124     else if ( infoFormat == QgsWmsParameters::Format::JSON )
  1125       ba = convertFeatureInfoToJson( layers, result );
  1127       ba = result.toByteArray();
  1132   QImage *QgsRenderer::createImage( 
int width, 
int height, 
bool useBbox )
 const  1145       if ( !mWmsParameters.
bbox().isEmpty() && mapExtent.
isEmpty() )
  1148                                       QStringLiteral( 
"Invalid BBOX parameter" ) );
  1151       QString 
crs = mWmsParameters.
crs();
  1152       if ( crs.compare( 
"CRS:84", Qt::CaseInsensitive ) == 0 )
  1154         crs = QString( 
"EPSG:4326" );
  1162       if ( !mapExtent.
isEmpty() && height > 0 && width > 0 )
  1164         double mapWidthHeightRatio = mapExtent.
width() / mapExtent.
height();
  1165         double imageWidthHeightRatio = 
static_cast<double>( width ) / static_cast<double>( height );
  1166         if ( !
qgsDoubleNear( mapWidthHeightRatio, imageWidthHeightRatio, 0.0001 ) )
  1169           double cellsize = ( mapExtent.
width() / 
static_cast<double>( width ) ) * 0.5 + ( mapExtent.
height() / 
static_cast<double>( height ) ) * 0.5;
  1170           width = mapExtent.
width() / cellsize;
  1171           height = mapExtent.
height() / cellsize;
  1176     if ( width <= 0 || height <= 0 )
  1178       throw QgsException( QStringLiteral( 
"createImage: Invalid width / height parameters" ) );
  1181     std::unique_ptr<QImage> image;
  1189       image = qgis::make_unique<QImage>( width, height, QImage::Format_ARGB32_Premultiplied );
  1194       image = qgis::make_unique<QImage>( width, height, QImage::Format_RGB32 );
  1199     if ( image->isNull() )
  1201       throw QgsException( QStringLiteral( 
"createImage: image could not be created, check for out of memory conditions" ) );
  1206     double OGC_PX_M = 0.00028; 
  1207     int dpm = 1 / OGC_PX_M;
  1208     if ( !mWmsParameters.
dpi().isEmpty() )
  1211     image->setDotsPerMeterX( dpm );
  1212     image->setDotsPerMeterY( dpm );
  1213     return image.release();
  1216   void QgsRenderer::configureMapSettings( 
const QPaintDevice *paintDevice, 
QgsMapSettings &mapSettings )
 const  1220       throw QgsException( QStringLiteral( 
"configureMapSettings: no paint device" ) );
  1223     mapSettings.
setOutputSize( QSize( paintDevice->width(), paintDevice->height() ) );
  1224     mapSettings.
setOutputDpi( paintDevice->logicalDpiX() );
  1228     if ( !mWmsParameters.
bbox().isEmpty() && mapExtent.
isEmpty() )
  1230       throw QgsBadRequestException( QStringLiteral( 
"InvalidParameterValue" ), QStringLiteral( 
"Invalid BBOX parameter" ) );
  1233     QString 
crs = mWmsParameters.
crs();
  1234     if ( crs.compare( 
"CRS:84", Qt::CaseInsensitive ) == 0 )
  1236       crs = QString( 
"EPSG:4326" );
  1247       throw QgsBadRequestException( QStringLiteral( 
"InvalidCRS" ), QStringLiteral( 
"Could not create output CRS" ) );
  1273     else if ( backgroundColor.isValid() )
  1290     int myRed = mProject->
readNumEntry( 
"Gui", 
"/SelectionColorRedPart", 255 );
  1291     int myGreen = mProject->
readNumEntry( 
"Gui", 
"/SelectionColorGreenPart", 255 );
  1292     int myBlue = mProject->
readNumEntry( 
"Gui", 
"/SelectionColorBluePart", 0 );
  1293     int myAlpha = mProject->
readNumEntry( 
"Gui", 
"/SelectionColorAlphaPart", 255 );
  1297   QDomDocument QgsRenderer::featureInfoDocument( QList<QgsMapLayer *> &layers, 
const QgsMapSettings &mapSettings,
  1298       const QImage *outputImage, 
const QString &version )
 const  1302     bool ijDefined = ( !mWmsParameters.
i().isEmpty() && !mWmsParameters.
j().isEmpty() );
  1304     bool xyDefined = ( !mWmsParameters.
x().isEmpty() && !mWmsParameters.
y().isEmpty() );
  1306     bool filtersDefined = !mWmsParameters.
filters().isEmpty();
  1308     bool filterGeomDefined = !mWmsParameters.
filterGeom().isEmpty();
  1311     if ( featureCount < 1 )
  1316     int i = mWmsParameters.
iAsInt();
  1317     int j = mWmsParameters.
jAsInt();
  1318     if ( xyDefined && !ijDefined )
  1320       i = mWmsParameters.
xAsInt();
  1321       j = mWmsParameters.
yAsInt();
  1325     if ( ( i != -1 && j != -1 && width != 0 && height != 0 ) && ( width != outputImage->width() || height != outputImage->height() ) )
  1327       i *= ( outputImage->width() / 
static_cast<double>( width ) );
  1328       j *= ( outputImage->height() / 
static_cast<double>( height ) );
  1332     std::unique_ptr<QgsRectangle> featuresRect;
  1333     std::unique_ptr<QgsGeometry> filterGeom;
  1334     std::unique_ptr<QgsPointXY> infoPoint;
  1336     if ( i != -1 && j != -1 )
  1339       infoPointToMapCoordinates( i, j, infoPoint.get(), mapSettings );
  1341     else if ( filtersDefined )
  1345     else if ( filterGeomDefined )
  1350     QDomDocument result;
  1352     QDomElement getFeatureInfoElement;
  1354     if ( infoFormat == QgsWmsParameters::Format::GML )
  1356       getFeatureInfoElement = result.createElement( QStringLiteral( 
"wfs:FeatureCollection" ) );
  1357       getFeatureInfoElement.setAttribute( QStringLiteral( 
"xmlns:wfs" ), QStringLiteral( 
"http://www.opengis.net/wfs" ) );
  1358       getFeatureInfoElement.setAttribute( QStringLiteral( 
"xmlns:ogc" ), QStringLiteral( 
"http://www.opengis.net/ogc" ) );
  1359       getFeatureInfoElement.setAttribute( QStringLiteral( 
"xmlns:gml" ), QStringLiteral( 
"http://www.opengis.net/gml" ) );
  1360       getFeatureInfoElement.setAttribute( QStringLiteral( 
"xmlns:ows" ), QStringLiteral( 
"http://www.opengis.net/ows" ) );
  1361       getFeatureInfoElement.setAttribute( QStringLiteral( 
"xmlns:xlink" ), QStringLiteral( 
"http://www.w3.org/1999/xlink" ) );
  1362       getFeatureInfoElement.setAttribute( QStringLiteral( 
"xmlns:qgs" ), QStringLiteral( 
"http://qgis.org/gml" ) );
  1363       getFeatureInfoElement.setAttribute( QStringLiteral( 
"xmlns:xsi" ), QStringLiteral( 
"http://www.w3.org/2001/XMLSchema-instance" ) );
  1364       getFeatureInfoElement.setAttribute( QStringLiteral( 
"xsi:schemaLocation" ), QStringLiteral( 
"http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/wfs.xsd http://qgis.org/gml" ) );
  1369       if ( featureInfoElemName.isEmpty() )
  1371         featureInfoElemName = QStringLiteral( 
"GetFeatureInfoResponse" );
  1374       if ( featureInfoElemNs.isEmpty() )
  1376         getFeatureInfoElement = result.createElement( featureInfoElemName );
  1380         getFeatureInfoElement = result.createElementNS( featureInfoElemNs, featureInfoElemName );
  1384       if ( !featureInfoSchema.isEmpty() )
  1386         getFeatureInfoElement.setAttribute( QStringLiteral( 
"xmlns:xsi" ), QStringLiteral( 
"http://www.w3.org/2001/XMLSchema-instance" ) );
  1387         getFeatureInfoElement.setAttribute( QStringLiteral( 
"xsi:schemaLocation" ), featureInfoSchema );
  1390     result.appendChild( getFeatureInfoElement );
  1400     for ( 
const QString &queryLayer : queryLayers )
  1402       bool validLayer = 
false;
  1403       bool queryableLayer = 
true;
  1406         if ( queryLayer == layerNickname( *layer ) )
  1410           if ( !queryableLayer )
  1415           QDomElement layerElement;
  1416           if ( infoFormat == QgsWmsParameters::Format::GML )
  1418             layerElement = getFeatureInfoElement;
  1422             layerElement = result.createElement( QStringLiteral( 
"Layer" ) );
  1423             QString layerName = queryLayer;
  1426             QHash<QString, QString>::const_iterator layerAliasIt = layerAliasMap.find( layerName );
  1427             if ( layerAliasIt != layerAliasMap.constEnd() )
  1429               layerName = layerAliasIt.value();
  1432             layerElement.setAttribute( QStringLiteral( 
"name" ), layerName );
  1433             getFeatureInfoElement.appendChild( layerElement );
  1436               layerElement.setAttribute( QStringLiteral( 
"id" ), layer->id() );
  1445               ( void )featureInfoFromVectorLayer( vectorLayer, infoPoint.get(), featureCount, result, layerElement, mapSettings, renderContext, version, featuresRect.get(), filterGeom.get() );
  1465             if ( infoFormat == QgsWmsParameters::Format::GML )
  1467               layerElement = result.createElement( QStringLiteral( 
"gml:featureMember" ) );
  1468               getFeatureInfoElement.appendChild( layerElement );
  1471             ( void )featureInfoFromRasterLayer( rasterLayer, mapSettings, &layerInfoPoint, result, layerElement, version );
  1476       if ( !validLayer && !mNicknameLayers.contains( queryLayer ) && !mLayerGroups.contains( queryLayer ) )
  1478         QString msg = QObject::tr( 
"Layer '%1' not found" ).arg( queryLayer );
  1481       else if ( ( validLayer && !queryableLayer ) || ( !validLayer && mLayerGroups.contains( queryLayer ) ) )
  1483         QString msg = QObject::tr( 
"Layer '%1' is not queryable" ).arg( queryLayer );
  1490       if ( infoFormat == QgsWmsParameters::Format::GML )
  1492         QDomElement bBoxElem = result.createElement( QStringLiteral( 
"gml:boundedBy" ) );
  1493         QDomElement boxElem;
  1495         if ( gmlVersion < 3 )
  1505         if ( crs.isValid() )
  1507           boxElem.setAttribute( QStringLiteral( 
"srsName" ), crs.authid() );
  1509         bBoxElem.appendChild( boxElem );
  1510         getFeatureInfoElement.insertBefore( bBoxElem, QDomNode() ); 
  1514         QDomElement bBoxElem = result.createElement( QStringLiteral( 
"BoundingBox" ) );
  1516         bBoxElem.setAttribute( QStringLiteral( 
"minx" ), 
qgsDoubleToString( featuresRect->xMinimum(), 8 ) );
  1517         bBoxElem.setAttribute( QStringLiteral( 
"maxx" ), 
qgsDoubleToString( featuresRect->xMaximum(), 8 ) );
  1518         bBoxElem.setAttribute( QStringLiteral( 
"miny" ), 
qgsDoubleToString( featuresRect->yMinimum(), 8 ) );
  1519         bBoxElem.setAttribute( QStringLiteral( 
"maxy" ), 
qgsDoubleToString( featuresRect->yMaximum(), 8 ) );
  1520         getFeatureInfoElement.insertBefore( bBoxElem, QDomNode() ); 
  1524     if ( sia2045 && infoFormat == QgsWmsParameters::Format::XML )
  1526       convertFeatureInfoToSia2045( result );
  1532   bool QgsRenderer::featureInfoFromVectorLayer( 
QgsVectorLayer *layer,
  1535       QDomDocument &infoDocument,
  1536       QDomElement &layerElement,
  1539       const QString &version,
  1551     std::unique_ptr<QgsGeometry> layerFilterGeom;
  1554       layerFilterGeom.reset( 
new QgsGeometry( *filterGeom ) );
  1568       searchRect = featureInfoSearchRect( layer, mapSettings, renderContext, *infoPoint );
  1570     else if ( layerFilterGeom )
  1572       searchRect = layerFilterGeom->boundingBox();
  1574     else if ( !mWmsParameters.
bbox().isEmpty() )
  1576       searchRect = layerRect;
  1583     int featureCounter = 0;
  1590     bool hasGeometry = addWktGeometry || featureBBox || layerFilterGeom;
  1603     if ( layerFilterGeom )
  1605       fReq.
setFilterExpression( QString( 
"intersects( $geometry, geom_from_wkt('%1') )" ).arg( layerFilterGeom->asWkt() ) );
  1608 #ifdef HAVE_SERVER_PYTHON_PLUGINS  1609     mAccessControl->filterFeatures( layer, fReq );
  1611     QStringList attributes;
  1612     for ( 
const QgsField &field : fields )
  1614       attributes.append( field.name() );
  1616     attributes = mAccessControl->layerAttributes( layer, attributes );
  1621     std::unique_ptr< QgsFeatureRenderer > r2( layer->
renderer() ? layer->
renderer()->
clone() : nullptr );
  1624       r2->startRender( renderContext, layer->
fields() );
  1627     bool featureBBoxInitialized = 
false;
  1636       if ( featureCounter > nFeatures )
  1651         bool render = r2->willRenderFeature( feature, renderContext );
  1664           if ( !featureBBoxInitialized && featureBBox->
isEmpty() )
  1667             featureBBoxInitialized = 
true;
  1682       if ( mWmsParameters.
infoFormat() == QgsWmsParameters::Format::GML )
  1686         QString 
typeName = layerNickname( *layer );
  1687         QDomElement elem = createFeatureGML(
  1688                              &feature, layer, infoDocument, outputCrs, mapSettings, typeName, withGeom, gmlVersion
  1689 #ifdef HAVE_SERVER_PYTHON_PLUGINS
  1693         QDomElement featureMemberElem = infoDocument.createElement( QStringLiteral( 
"gml:featureMember" ) );
  1694         featureMemberElem.appendChild( elem );
  1695         layerElement.appendChild( featureMemberElem );
  1700         QDomElement featureElement = infoDocument.createElement( QStringLiteral( 
"Feature" ) );
  1701         featureElement.setAttribute( QStringLiteral( 
"id" ), 
FID_TO_STRING( feature.
id() ) );
  1702         layerElement.appendChild( featureElement );
  1706         for ( 
int i = 0; i < featureAttributes.count(); ++i )
  1709           if ( excludedAttributes.contains( fields.at( i ).name() ) )
  1713 #ifdef HAVE_SERVER_PYTHON_PLUGINS  1715           if ( !attributes.contains( fields.at( i ).name() ) )
  1724           QDomElement attributeElement = infoDocument.createElement( QStringLiteral( 
"Attribute" ) );
  1725           attributeElement.setAttribute( QStringLiteral( 
"name" ), attributeName );
  1727           attributeElement.setAttribute( QStringLiteral( 
"value" ),
  1729                                            replaceValueMapAndRelation(
  1731                                              featureAttributes[i] ),
  1734           featureElement.appendChild( attributeElement );
  1739         if ( !mapTip.isEmpty() && mWmsParameters.
withMapTip() )
  1741           QDomElement maptipElem = infoDocument.createElement( QStringLiteral( 
"Attribute" ) );
  1742           maptipElem.setAttribute( QStringLiteral( 
"name" ), QStringLiteral( 
"maptip" ) );
  1744           featureElement.appendChild( maptipElem );
  1750           QDomElement bBoxElem = infoDocument.createElement( QStringLiteral( 
"BoundingBox" ) );
  1751           bBoxElem.setAttribute( version == QLatin1String( 
"1.1.1" ) ? 
"SRS" : 
"CRS", outputCrs.
authid() );
  1756           featureElement.appendChild( bBoxElem );
  1772             if ( segmentizeWktGeometry )
  1780                   geom.
set( segmentizedGeom );
  1784             QDomElement geometryElement = infoDocument.createElement( QStringLiteral( 
"Attribute" ) );
  1785             geometryElement.setAttribute( QStringLiteral( 
"name" ), QStringLiteral( 
"geometry" ) );
  1787             geometryElement.setAttribute( QStringLiteral( 
"type" ), QStringLiteral( 
"derived" ) );
  1788             featureElement.appendChild( geometryElement );
  1795       r2->stopRender( renderContext );
  1801   bool QgsRenderer::featureInfoFromRasterLayer( 
QgsRasterLayer *layer,
  1804       QDomDocument &infoDocument,
  1805       QDomElement &layerElement,
  1806       const QString &version )
 const  1808     Q_UNUSED( version );
  1835     if ( !identifyResult.
isValid() )
  1838     QMap<int, QVariant> attributes = identifyResult.
results();
  1840     if ( mWmsParameters.
infoFormat() == QgsWmsParameters::Format::GML )
  1846       for ( 
auto it = attributes.constBegin(); it != attributes.constEnd(); ++it )
  1849         feature.
setAttribute( index++, QString::number( it.value().toDouble() ) );
  1855       QString 
typeName = layerNickname( *layer );
  1856       QDomElement elem = createFeatureGML(
  1857                            &feature, 
nullptr, infoDocument, layerCrs, mapSettings, typeName, 
false, gmlVersion, 
nullptr );
  1858       layerElement.appendChild( elem );
  1862       for ( 
auto it = attributes.constBegin(); it != attributes.constEnd(); ++it )
  1864         QDomElement attributeElement = infoDocument.createElement( QStringLiteral( 
"Attribute" ) );
  1865         attributeElement.setAttribute( QStringLiteral( 
"name" ), layer->
bandName( it.key() ) );
  1866         attributeElement.setAttribute( QStringLiteral( 
"value" ), QString::number( it.value().toDouble() ) );
  1867         layerElement.appendChild( attributeElement );
  1873   bool QgsRenderer::testFilterStringSafety( 
const QString &filter )
 const  1876     if ( filter.contains( QLatin1String( 
";" ) ) )
  1881     QStringList tokens = filter.split( 
' ', QString::SkipEmptyParts );
  1882     groupStringList( tokens, QStringLiteral( 
"'" ) );
  1883     groupStringList( tokens, QStringLiteral( 
"\"" ) );
  1885     for ( 
auto tokenIt = tokens.constBegin() ; tokenIt != tokens.constEnd(); ++tokenIt )
  1888       if ( tokenIt->compare( QLatin1String( 
"," ) ) == 0
  1889            || tokenIt->compare( QLatin1String( 
"(" ) ) == 0
  1890            || tokenIt->compare( QLatin1String( 
")" ) ) == 0
  1891            || tokenIt->compare( QLatin1String( 
"=" ) ) == 0
  1892            || tokenIt->compare( QLatin1String( 
"!=" ) ) == 0
  1893            || tokenIt->compare( QLatin1String( 
"<" ) ) == 0
  1894            || tokenIt->compare( QLatin1String( 
"<=" ) ) == 0
  1895            || tokenIt->compare( QLatin1String( 
">" ) ) == 0
  1896            || tokenIt->compare( QLatin1String( 
">=" ) ) == 0
  1897            || tokenIt->compare( QLatin1String( 
"%" ) ) == 0
  1898            || tokenIt->compare( QLatin1String( 
"AND" ), Qt::CaseInsensitive ) == 0
  1899            || tokenIt->compare( QLatin1String( 
"OR" ), Qt::CaseInsensitive ) == 0
  1900            || tokenIt->compare( QLatin1String( 
"IN" ), Qt::CaseInsensitive ) == 0
  1901            || tokenIt->compare( QLatin1String( 
"LIKE" ), Qt::CaseInsensitive ) == 0
  1902            || tokenIt->compare( QLatin1String( 
"ILIKE" ), Qt::CaseInsensitive ) == 0
  1903            || tokenIt->compare( QLatin1String( 
"DMETAPHONE" ), Qt::CaseInsensitive ) == 0
  1904            || tokenIt->compare( QLatin1String( 
"SOUNDEX" ), Qt::CaseInsensitive ) == 0 )
  1911       tokenIt->toDouble( &isNumeric );
  1920       if ( *tokenIt == QLatin1String( 
"''" ) )
  1926       if ( tokenIt->size() > 2
  1927            && ( *tokenIt )[0] == QChar( 
'\'' )
  1928            && ( *tokenIt )[tokenIt->size() - 1] == QChar( 
'\'' )
  1929            && ( *tokenIt )[1] != QChar( 
'\'' )
  1930            && ( *tokenIt )[tokenIt->size() - 2] != QChar( 
'\'' ) )
  1936       if ( tokenIt->size() > 2
  1937            && ( *tokenIt )[0] == QChar( 
'"' )
  1938            && ( *tokenIt )[tokenIt->size() - 1] == QChar( 
'"' )
  1939            && ( *tokenIt )[1] != QChar( 
'"' )
  1940            && ( *tokenIt )[tokenIt->size() - 2] != QChar( 
'"' ) )
  1951   void QgsRenderer::groupStringList( QStringList &list, 
const QString &groupString )
  1954     bool groupActive = 
false;
  1955     int startGroup = -1;
  1956     QString concatString;
  1958     for ( 
int i = 0; i < list.size(); ++i )
  1960       QString &str = list[i];
  1961       if ( str.startsWith( groupString ) )
  1965         concatString.clear();
  1970         if ( i != startGroup )
  1972           concatString.append( 
" " );
  1974         concatString.append( str );
  1977       if ( str.endsWith( groupString ) )
  1980         groupActive = 
false;
  1982         if ( startGroup != -1 )
  1984           list[startGroup] = concatString;
  1985           for ( 
int j = startGroup + 1; j <= endGroup; ++j )
  1987             list.removeAt( startGroup + 1 );
  1992         concatString.clear();
  1998   bool QgsRenderer::checkMaximumWidthHeight()
 const  2003     if ( wmsMaxWidth != -1 && width > wmsMaxWidth )
  2010     if ( wmsMaxHeight != -1 && height > wmsMaxHeight )
  2023     switch ( mWmsParameters.
format() )
  2025       case QgsWmsParameters::Format::JPG:
  2031     const int bytes_per_line = ( ( width * depth + 31 ) >> 5 ) << 2; 
  2033     if ( std::numeric_limits<int>::max() / depth < static_cast<uint>( width )
  2034          || bytes_per_line <= 0
  2036          || std::numeric_limits<int>::max() / 
static_cast<uint
>( bytes_per_line ) < static_cast<uint>( height )
  2037          || std::numeric_limits<int>::max() / 
sizeof( uchar * ) < static_cast<uint>( height ) )
  2043   void QgsRenderer::convertFeatureInfoToSia2045( QDomDocument &doc )
 const  2045     QDomDocument SIAInfoDoc;
  2046     QDomElement infoDocElement = doc.documentElement();
  2047     QDomElement SIAInfoDocElement = SIAInfoDoc.importNode( infoDocElement, 
false ).toElement();
  2048     SIAInfoDoc.appendChild( SIAInfoDocElement );
  2050     QString currentAttributeName;
  2051     QString currentAttributeValue;
  2052     QDomElement currentAttributeElem;
  2053     QString currentLayerName;
  2054     QDomElement currentLayerElem;
  2055     QDomNodeList layerNodeList = infoDocElement.elementsByTagName( QStringLiteral( 
"Layer" ) );
  2056     for ( 
int i = 0; i < layerNodeList.size(); ++i )
  2058       currentLayerElem = layerNodeList.at( i ).toElement();
  2059       currentLayerName = currentLayerElem.attribute( QStringLiteral( 
"name" ) );
  2061       QDomElement currentFeatureElem;
  2063       QDomNodeList featureList = currentLayerElem.elementsByTagName( QStringLiteral( 
"Feature" ) );
  2064       if ( featureList.isEmpty() )
  2067         QDomNodeList attributeList = currentLayerElem.elementsByTagName( QStringLiteral( 
"Attribute" ) );
  2068         QDomElement rasterLayerElem;
  2069         if ( !attributeList.isEmpty() )
  2071           rasterLayerElem = SIAInfoDoc.createElement( currentLayerName );
  2073         for ( 
int j = 0; j < attributeList.size(); ++j )
  2075           currentAttributeElem = attributeList.at( j ).toElement();
  2076           currentAttributeName = currentAttributeElem.attribute( QStringLiteral( 
"name" ) );
  2077           currentAttributeValue = currentAttributeElem.attribute( QStringLiteral( 
"value" ) );
  2078           QDomElement outAttributeElem = SIAInfoDoc.createElement( currentAttributeName );
  2079           QDomText outAttributeText = SIAInfoDoc.createTextNode( currentAttributeValue );
  2080           outAttributeElem.appendChild( outAttributeText );
  2081           rasterLayerElem.appendChild( outAttributeElem );
  2083         if ( !attributeList.isEmpty() )
  2085           SIAInfoDocElement.appendChild( rasterLayerElem );
  2091         QSet<QString> layerPropertyAttributes;
  2092         QString currentLayerId = currentLayerElem.attribute( QStringLiteral( 
"id" ) );
  2093         if ( !currentLayerId.isEmpty() )
  2098             QString WMSPropertyAttributesString = currentLayer->
customProperty( QStringLiteral( 
"WMSPropertyAttributes" ) ).toString();
  2099             if ( !WMSPropertyAttributesString.isEmpty() )
  2101               QStringList propertyList = WMSPropertyAttributesString.split( QStringLiteral( 
"//" ) );
  2102               for ( 
auto propertyIt = propertyList.constBegin() ; propertyIt != propertyList.constEnd(); ++propertyIt )
  2104                 layerPropertyAttributes.insert( *propertyIt );
  2110         QDomElement propertyRefChild; 
  2111         for ( 
int j = 0; j < featureList.size(); ++j )
  2113           QDomElement SIAFeatureElem = SIAInfoDoc.createElement( currentLayerName );
  2114           currentFeatureElem = featureList.at( j ).toElement();
  2115           QDomNodeList attributeList = currentFeatureElem.elementsByTagName( QStringLiteral( 
"Attribute" ) );
  2117           for ( 
int k = 0; k < attributeList.size(); ++k )
  2119             currentAttributeElem = attributeList.at( k ).toElement();
  2120             currentAttributeName = currentAttributeElem.attribute( QStringLiteral( 
"name" ) );
  2121             currentAttributeValue = currentAttributeElem.attribute( QStringLiteral( 
"value" ) );
  2122             if ( layerPropertyAttributes.contains( currentAttributeName ) )
  2124               QDomElement propertyElem = SIAInfoDoc.createElement( QStringLiteral( 
"property" ) );
  2125               QDomElement identifierElem = SIAInfoDoc.createElement( QStringLiteral( 
"identifier" ) );
  2126               QDomText identifierText = SIAInfoDoc.createTextNode( currentAttributeName );
  2127               identifierElem.appendChild( identifierText );
  2128               QDomElement valueElem = SIAInfoDoc.createElement( QStringLiteral( 
"value" ) );
  2129               QDomText valueText = SIAInfoDoc.createTextNode( currentAttributeValue );
  2130               valueElem.appendChild( valueText );
  2131               propertyElem.appendChild( identifierElem );
  2132               propertyElem.appendChild( valueElem );
  2133               if ( propertyRefChild.isNull() )
  2135                 SIAFeatureElem.insertBefore( propertyElem, QDomNode() );
  2136                 propertyRefChild = propertyElem;
  2140                 SIAFeatureElem.insertAfter( propertyElem, propertyRefChild );
  2145               QDomElement SIAAttributeElem = SIAInfoDoc.createElement( currentAttributeName );
  2146               QDomText SIAAttributeText = SIAInfoDoc.createTextNode( currentAttributeValue );
  2147               SIAAttributeElem.appendChild( SIAAttributeText );
  2148               SIAFeatureElem.appendChild( SIAAttributeElem );
  2151           SIAInfoDocElement.appendChild( SIAFeatureElem );
  2158   QByteArray QgsRenderer::convertFeatureInfoToHtml( 
const QDomDocument &doc )
 const  2160     QString featureInfoString;
  2163     featureInfoString.append( 
"<HEAD>\n" );
  2164     featureInfoString.append( 
"<TITLE> GetFeatureInfo results </TITLE>\n" );
  2165     featureInfoString.append( 
"<META http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/>\n" );
  2166     featureInfoString.append( 
"</HEAD>\n" );
  2169     featureInfoString.append( 
"<BODY>\n" );
  2171     QDomNodeList layerList = doc.elementsByTagName( QStringLiteral( 
"Layer" ) );
  2174     for ( 
int i = 0; i < layerList.size(); ++i )
  2176       QDomElement layerElem = layerList.at( i ).toElement();
  2178       featureInfoString.append( 
"<TABLE border=1 width=100%>\n" );
  2179       featureInfoString.append( 
"<TR><TH width=25%>Layer</TH><TD>" + layerElem.attribute( QStringLiteral( 
"name" ) ) + 
"</TD></TR>\n" );
  2180       featureInfoString.append( 
"</BR>" );
  2183       QDomNodeList featureNodeList = layerElem.elementsByTagName( QStringLiteral( 
"Feature" ) );
  2184       QDomElement currentFeatureElement;
  2186       if ( !featureNodeList.isEmpty() ) 
  2188         for ( 
int j = 0; j < featureNodeList.size(); ++j )
  2190           QDomElement featureElement = featureNodeList.at( j ).toElement();
  2191           featureInfoString.append( 
"<TABLE border=1 width=100%>\n" );
  2192           featureInfoString.append( 
"<TR><TH>Feature</TH><TD>" + featureElement.attribute( QStringLiteral( 
"id" ) ) +
  2196           QDomNodeList attributeNodeList = featureElement.elementsByTagName( QStringLiteral( 
"Attribute" ) );
  2197           for ( 
int k = 0; k < attributeNodeList.size(); ++k )
  2199             QDomElement attributeElement = attributeNodeList.at( k ).toElement();
  2200             featureInfoString.append( 
"<TR><TH>" + attributeElement.attribute( QStringLiteral( 
"name" ) ) +
  2201                                       "</TH><TD>" + attributeElement.attribute( QStringLiteral( 
"value" ) ) + 
"</TD></TR>\n" );
  2204           featureInfoString.append( 
"</TABLE>\n</BR>\n" );
  2209         QDomNodeList attributeNodeList = layerElem.elementsByTagName( QStringLiteral( 
"Attribute" ) );
  2210         for ( 
int j = 0; j < attributeNodeList.size(); ++j )
  2212           QDomElement attributeElement = attributeNodeList.at( j ).toElement();
  2213           featureInfoString.append( 
"<TR><TH>" + attributeElement.attribute( QStringLiteral( 
"name" ) ) +
  2214                                     "</TH><TD>" + attributeElement.attribute( QStringLiteral( 
"value" ) ) + 
"</TD></TR>\n" );
  2218       featureInfoString.append( 
"</TABLE>\n<BR></BR>\n" );
  2222     featureInfoString.append( 
"</BODY>\n" );
  2224     return featureInfoString.toUtf8();
  2227   QByteArray QgsRenderer::convertFeatureInfoToText( 
const QDomDocument &doc )
 const  2229     QString featureInfoString;
  2232     featureInfoString.append( 
"GetFeatureInfo results\n" );
  2233     featureInfoString.append( 
"\n" );
  2235     QDomNodeList layerList = doc.elementsByTagName( QStringLiteral( 
"Layer" ) );
  2238     for ( 
int i = 0; i < layerList.size(); ++i )
  2240       QDomElement layerElem = layerList.at( i ).toElement();
  2242       featureInfoString.append( 
"Layer '" + layerElem.attribute( QStringLiteral( 
"name" ) ) + 
"'\n" );
  2245       QDomNodeList featureNodeList = layerElem.elementsByTagName( QStringLiteral( 
"Feature" ) );
  2246       QDomElement currentFeatureElement;
  2248       if ( !featureNodeList.isEmpty() ) 
  2250         for ( 
int j = 0; j < featureNodeList.size(); ++j )
  2252           QDomElement featureElement = featureNodeList.at( j ).toElement();
  2253           featureInfoString.append( 
"Feature " + featureElement.attribute( QStringLiteral( 
"id" ) ) + 
"\n" );
  2256           QDomNodeList attributeNodeList = featureElement.elementsByTagName( QStringLiteral( 
"Attribute" ) );
  2257           for ( 
int k = 0; k < attributeNodeList.size(); ++k )
  2259             QDomElement attributeElement = attributeNodeList.at( k ).toElement();
  2260             featureInfoString.append( attributeElement.attribute( QStringLiteral( 
"name" ) ) + 
" = '" +
  2261                                       attributeElement.attribute( QStringLiteral( 
"value" ) ) + 
"'\n" );
  2267         QDomNodeList attributeNodeList = layerElem.elementsByTagName( QStringLiteral( 
"Attribute" ) );
  2268         for ( 
int j = 0; j < attributeNodeList.size(); ++j )
  2270           QDomElement attributeElement = attributeNodeList.at( j ).toElement();
  2271           featureInfoString.append( attributeElement.attribute( QStringLiteral( 
"name" ) ) + 
" = '" +
  2272                                     attributeElement.attribute( QStringLiteral( 
"value" ) ) + 
"'\n" );
  2276       featureInfoString.append( 
"\n" );
  2279     return featureInfoString.toUtf8();
  2282   QByteArray QgsRenderer::convertFeatureInfoToJson( 
const QList<QgsMapLayer *> &layers, 
const QDomDocument &doc )
 const  2285     json.append( QStringLiteral( 
"{\"type\": \"FeatureCollection\",\n" ) );
  2286     json.append( QStringLiteral( 
"    \"features\":[\n" ) );
  2290     const QDomNodeList layerList = doc.elementsByTagName( QStringLiteral( 
"Layer" ) );
  2291     for ( 
int i = 0; i < layerList.size(); ++i )
  2293       const QDomElement layerElem = layerList.at( i ).toElement();
  2294       const QString layerName = layerElem.attribute( QStringLiteral( 
"name" ) );
  2299         if ( layerNickname( *l ).compare( layerName ) == 0 )
  2315         const QDomNodeList featuresNode = layerElem.elementsByTagName( QStringLiteral( 
"Feature" ) );
  2316         if ( featuresNode.isEmpty() )
  2319         for ( 
int j = 0; j < featuresNode.size(); ++j )
  2321           const QDomElement featureNode = featuresNode.at( j ).toElement();
  2322           const QgsFeatureId fid = featureNode.attribute( QStringLiteral( 
"id" ) ).toLongLong();
  2328             const QDomNodeList attrs = featureNode.elementsByTagName( 
"Attribute" );
  2329             for ( 
int k = 0; k < attrs.count(); k++ )
  2331               const QDomElement elm = attrs.at( k ).toElement();
  2332               if ( elm.attribute( QStringLiteral( 
"name" ) ).compare( 
"geometry" ) == 0 )
  2339             if ( ! wkt.isEmpty() )
  2345           features << feature;
  2348           if ( !attributes.isEmpty() )
  2351           const QDomNodeList attributesNode = featureNode.elementsByTagName( QStringLiteral( 
"Attribute" ) );
  2352           for ( 
int k = 0; k < attributesNode.size(); ++k )
  2354             const QDomElement attributeElement = attributesNode.at( k ).toElement();
  2355             const QString fieldName = attributeElement.
attribute( QStringLiteral( 
"name" ) );
  2357             attributes << feature.fieldNameIndex( fieldName );
  2367         for ( 
const auto feature : features )
  2369           if ( json.right( 1 ).compare( QStringLiteral( 
"}" ) ) == 0 )
  2371             json.append( QStringLiteral( 
"," ) );
  2375           json.append( exporter.
exportFeature( feature, QVariantMap(), 
id ) );
  2380         json.append( QStringLiteral( 
"{" ) );
  2381         json.append( QStringLiteral( 
"\"type\":\"Feature\",\n" ) );
  2382         json.append( QStringLiteral( 
"\"id\":\"%1\",\n" ).arg( layer->
name() ) );
  2383         json.append( QStringLiteral( 
"\"properties\":{\n" ) );
  2385         const QDomNodeList attributesNode = layerElem.elementsByTagName( QStringLiteral( 
"Attribute" ) );
  2386         for ( 
int j = 0; j < attributesNode.size(); ++j )
  2388           const QDomElement attrElmt = attributesNode.at( j ).toElement();
  2389           const QString name = attrElmt.attribute( QStringLiteral( 
"name" ) );
  2390           const QString value = attrElmt.attribute( QStringLiteral( 
"value" ) );
  2393             json.append( QStringLiteral( 
",\n" ) );
  2395           json.append( QStringLiteral( 
"    \"%1\": \"%2\"" ).arg( name, value ) );
  2398         json.append( QStringLiteral( 
"\n}\n}" ) );
  2402     json.append( QStringLiteral( 
"]}" ) );
  2404     return json.toUtf8();
  2407   QDomElement QgsRenderer::createFeatureGML(
  2416     QStringList *attributes )
 const  2419     QDomElement typeNameElement = doc.createElement( 
"qgs:" + typeName  );
  2420     typeNameElement.setAttribute( QStringLiteral( 
"fid" ), typeName + 
"." + QString::number( feat->
id() ) );
  2423     if ( layer && layer->
crs() != 
crs )
  2446           box = transformedBox;
  2454       QDomElement bbElem = doc.createElement( QStringLiteral( 
"gml:boundedBy" ) );
  2455       QDomElement boxElem;
  2467         boxElem.setAttribute( QStringLiteral( 
"srsName" ), crs.
authid() );
  2469       bbElem.appendChild( boxElem );
  2470       typeNameElement.appendChild( bbElem );
  2473     if ( withGeom && !geom.
isNull() )
  2482       QDomElement geomElem = doc.createElement( QStringLiteral( 
"qgs:geometry" ) );
  2483       QDomElement gmlElem;
  2493       if ( !gmlElem.isNull() )
  2497           gmlElem.setAttribute( QStringLiteral( 
"srsName" ), crs.
authid() );
  2499         geomElem.appendChild( gmlElem );
  2500         typeNameElement.appendChild( geomElem );
  2507     for ( 
int i = 0; i < fields.
count(); ++i )
  2509       QString attributeName = fields.
at( i ).
name();
  2516       if ( attributes && !attributes->contains( attributeName ) )
  2521       QDomElement fieldElem = doc.createElement( 
"qgs:" + attributeName.replace( 
' ', 
'_' ) );
  2522       QString fieldTextString = featureAttributes.at( i ).toString();
  2527       QDomText fieldText = doc.createTextNode( fieldTextString );
  2528       fieldElem.appendChild( fieldText );
  2529       typeNameElement.appendChild( fieldElem );
  2537       if ( !mapTip.isEmpty() && mWmsParameters.
withMapTip() )
  2540         QDomElement fieldElem = doc.createElement( QStringLiteral( 
"qgs:maptip" ) );
  2541         QDomText maptipText = doc.createTextNode( fieldTextString );
  2542         fieldElem.appendChild( maptipText );
  2543         typeNameElement.appendChild( fieldElem );
  2547     return typeNameElement;
  2550   QString QgsRenderer::replaceValueMapAndRelation( 
QgsVectorLayer *vl, 
int idx, 
const QVariant &attributeVal )
  2554     QString value( fieldFormatter->
representValue( vl, idx, setup.
config(), QVariant(), attributeVal ) );
  2556     if ( setup.
config().value( QStringLiteral( 
"AllowMulti" ) ).toBool() && value.startsWith( QLatin1String( 
"{" ) ) && value.endsWith( QLatin1String( 
"}" ) ) )
  2558       value = value.mid( 1, value.size() - 2 );
  2574     return imageQuality;
  2585     if ( WMSPrecisionParameter > -1 )
  2586       return WMSPrecisionParameter;
  2588       return WMSPrecision;
  2598     double mapUnitTolerance = 0.0;
  2608         mapUnitTolerance = mapSettings.
extent().
width() / 400.0;
  2620         mapUnitTolerance = mapSettings.
extent().
width() / 200.0;
  2632         mapUnitTolerance = mapSettings.
extent().
width() / 100.0;
  2636     QgsRectangle mapRectangle( infoPoint.
x() - mapUnitTolerance, infoPoint.
y() - mapUnitTolerance,
  2637                                infoPoint.
x() + mapUnitTolerance, infoPoint.
y() + mapUnitTolerance );
  2642   void QgsRenderer::initRestrictedLayers()
  2644     mRestrictedLayers.clear();
  2650     QStringList restrictedLayersNames;
  2653     for ( 
const QString &l : restricted )
  2658         QList<QgsLayerTreeLayer *> groupLayers = group->
findLayers();
  2661           restrictedLayersNames.append( treeLayer->name() );
  2666         restrictedLayersNames.append( l );
  2671     QList<QgsLayerTreeLayer *> layers = root->
findLayers();
  2674       if ( restrictedLayersNames.contains( layer->
name() ) )
  2676         mRestrictedLayers.append( layerNickname( *layer->layer() ) );
  2681   void QgsRenderer::initNicknameLayers()
  2685       mNicknameLayers[ layerNickname( *ml ) ] = ml;
  2691     initLayerGroupsRecursive( root, rootName.isEmpty() ? mProject->
title() : rootName );
  2694   void QgsRenderer::initLayerGroupsRecursive( 
const QgsLayerTreeGroup *group, 
const QString &groupName )
  2696     if ( !groupName.isEmpty() )
  2698       mLayerGroups[groupName] = QList<QgsMapLayer *>();
  2701         mLayerGroups[groupName].append( layer->layer() );
  2709         QString name = child->customProperty( QStringLiteral( 
"wmsShortName" ) ).toString();
  2711         if ( name.isEmpty() )
  2712           name = child->name();
  2714         initLayerGroupsRecursive( static_cast<const QgsLayerTreeGroup *>( child ), name );
  2720   QString QgsRenderer::layerNickname( 
const QgsMapLayer &layer )
 const  2727     else if ( name.isEmpty() )
  2729       name = layer.
name();
  2735   bool QgsRenderer::layerScaleVisibility( 
const QgsMapLayer &layer, 
double scaleDenominator )
 const  2737     bool visible = 
false;
  2739     bool useScaleConstraint = ( scaleDenominator > 0 && scaleBasedVisibility );
  2741     if ( !useScaleConstraint || layer.
isInScaleRange( scaleDenominator ) )
  2749   QList<QgsMapLayer *> QgsRenderer::highlightLayers( QList<QgsWmsParametersHighlightLayer> params )
  2751     QList<QgsMapLayer *> highlightLayers;
  2754     QString crs = mWmsParameters.
crs();
  2758       QDomDocument sldDoc;
  2759       if ( !sldDoc.setContent( param.mSld, 
true ) )
  2766       std::unique_ptr<QgsFeatureRenderer> renderer;
  2767       QDomElement el = sldDoc.documentElement();
  2777       QString url = typeName + 
"?crs=" + 
crs;
  2778       if ( ! param.mLabel.isEmpty() )
  2780         url += 
"&field=label:string";
  2784       std::unique_ptr<QgsVectorLayer> layer;
  2786       if ( !layer->isValid() )
  2793       if ( ! param.mLabel.isEmpty() )
  2804         switch ( param.mGeom.type() )
  2809             palSettings.
dist = 2; 
  2820             QVariant x( pt.
x() );
  2824             QVariant y( pt.
y() );
  2828             QVariant hali( 
"Center" );
  2832             QVariant vali( 
"Half" );
  2839             palSettings.
dist = 2;
  2848         if ( param.mColor.isValid() )
  2850           textFormat.
setColor( param.mColor );
  2853         if ( param.mSize > 0 )
  2855           textFormat.
setSize( param.mSize );
  2863         if ( ! param.mFont.isEmpty() )
  2865           textFormat.
setFont( param.mFont );
  2868         if ( param.mBufferColor.isValid() )
  2870           bufferSettings.
setColor( param.mBufferColor );
  2873         if ( param.mBufferSize > 0 )
  2876           bufferSettings.
setSize( param.mBufferSize );
  2883         layer->setLabeling( simpleLabeling );
  2884         layer->setLabelsEnabled( 
true );
  2886       fet.setGeometry( param.mGeom );
  2890       layer->setRenderer( renderer.release() );
  2893       if ( layer->isValid() )
  2895         highlightLayers.append( layer.release() );
  2899     mTemporaryLayers.append( highlightLayers );
  2900     return highlightLayers;
  2903   QList<QgsMapLayer *> QgsRenderer::sldStylizedLayers( 
const QString &sld )
 const  2905     QList<QgsMapLayer *> layers;
  2907     if ( !sld.isEmpty() )
  2910       ( void )doc.setContent( sld, 
true );
  2911       QDomElement docEl = doc.documentElement();
  2913       QDomElement root = doc.firstChildElement( 
"StyledLayerDescriptor" );
  2914       QDomElement namedElem = root.firstChildElement( 
"NamedLayer" );
  2916       if ( !docEl.isNull() )
  2918         QDomNodeList named = docEl.elementsByTagName( 
"NamedLayer" );
  2919         for ( 
int i = 0; i < named.size(); ++i )
  2921           QDomNodeList names = named.item( i ).toElement().elementsByTagName( 
"Name" );
  2922           if ( !names.isEmpty() )
  2924             QString lname = names.item( 0 ).toElement().text();
  2926             if ( mNicknameLayers.contains( lname ) && !mRestrictedLayers.contains( lname ) )
  2928               mNicknameLayers[lname]->readSld( namedElem, err );
  2929               mNicknameLayers[lname]->setCustomProperty( 
"readSLD", 
true );
  2930               layers.append( mNicknameLayers[lname] );
  2932             else if ( mLayerGroups.contains( lname ) )
  2936                 if ( !mRestrictedLayers.contains( layerNickname( *layer ) ) )
  2938                   layer->
readSld( namedElem, err );
  2940                   layers.insert( 0, layer );
  2947                                             QStringLiteral( 
"Layer \"%1\" does not exist" ).arg( lname ) );
  2957   QList<QgsMapLayer *> QgsRenderer::stylizedLayers( 
const QList<QgsWmsParametersLayer> ¶ms )
  2959     QList<QgsMapLayer *> layers;
  2963       QString nickname = param.mNickname;
  2964       QString style = param.mStyle;
  2965       if ( nickname.startsWith( 
"EXTERNAL_WMS:" ) )
  2967         QString externalLayerId = nickname;
  2968         externalLayerId.remove( 0, 13 );
  2969         QgsMapLayer *externalWMSLayer = createExternalWMSLayer( externalLayerId );
  2970         if ( externalWMSLayer )
  2972           layers.append( externalWMSLayer );
  2973           mNicknameLayers[nickname] = externalWMSLayer; 
  2974           mTemporaryLayers.append( externalWMSLayer );
  2977       else if ( mNicknameLayers.contains( nickname ) && !mRestrictedLayers.contains( nickname ) )
  2979         if ( !style.isEmpty() )
  2981           bool rc = mNicknameLayers[nickname]->styleManager()->setCurrentStyle( style );
  2984             throw QgsMapServiceException( QStringLiteral( 
"StyleNotDefined" ), QStringLiteral( 
"Style \"%1\" does not exist for layer \"%2\"" ).arg( style, nickname ) );
  2988         layers.append( mNicknameLayers[nickname] );
  2990       else if ( mLayerGroups.contains( nickname ) )
  2993         QList<QgsMapLayer *> layersFromGroup;
  2994         for ( 
QgsMapLayer *layer : mLayerGroups[nickname] )
  2996           if ( !mRestrictedLayers.contains( layerNickname( *layer ) ) )
  2998             if ( !style.isEmpty() )
  3003                 throw QgsMapServiceException( QStringLiteral( 
"StyleNotDefined" ), QStringLiteral( 
"Style \"%1\" does not exist for layer \"%2\"" ).arg( style, layerNickname( *layer ) ) );
  3006             layersFromGroup.push_front( layer );
  3009         layers.append( layersFromGroup );
  3014                                       QStringLiteral( 
"Layer \"%1\" does not exist" ).arg( nickname ) );
  3021   QgsMapLayer *QgsRenderer::createExternalWMSLayer( 
const QString &externalLayerId )
 const  3023     QString wmsUri = mWmsParameters.
externalWMSUri( externalLayerId.toUpper() );
  3034   void QgsRenderer::removeTemporaryLayers()
  3036     qDeleteAll( mTemporaryLayers );
  3037     mTemporaryLayers.clear();
  3040   QPainter *QgsRenderer::layersRendering( 
const QgsMapSettings &mapSettings, QImage &image, 
HitTest *hitTest )
 const  3042     QPainter *painter = 
nullptr;
  3045       runHitTest( mapSettings, *hitTest );
  3046       painter = 
new QPainter();
  3052 #ifdef HAVE_SERVER_PYTHON_PLUGINS  3053       mAccessControl->resolveFilterFeatures( mapSettings.
layers() );
  3057       renderJob.
render( mapSettings, &image );
  3058       painter = renderJob.takePainter();
  3060       if ( !renderJob.errors().isEmpty() )
  3062         QString layerWMSName;
  3063         QString firstErrorLayerId = renderJob.errors().at( 0 ).layerID;
  3067           layerWMSName = layerNickname( *errorLayer );
  3071         QString errorMsg = QStringLiteral( 
"Map rendering error in layer '%1'" ).arg( firstErrorLayerId );
  3073         throw QgsServerException( QStringLiteral( 
"Map rendering error in layer '%1'" ).arg( layerWMSName ) );
  3080   void QgsRenderer::setLayerOpacity( 
QgsMapLayer *layer, 
int opacity )
 const  3082     if ( opacity >= 0 && opacity <= 255 )
  3084       switch ( layer->
type() )
  3086         case QgsMapLayer::LayerType::VectorLayer:
  3093         case QgsMapLayer::LayerType::RasterLayer:
  3097           rasterRenderer->
setOpacity( opacity / 255. );
  3108   void QgsRenderer::setLayerFilter( 
QgsMapLayer *layer, 
const QList<QgsWmsParametersFilter> &filters )
  3118           QDomDocument filterXml;
  3120           if ( !filterXml.setContent( filter.mFilter, 
true, &errorMsg ) )
  3123                                           QStringLiteral( 
"error message: %1. The XML string was: %2" ).arg( errorMsg, filter.mFilter ) );
  3125           QDomElement filterElem = filterXml.firstChildElement();
  3130             mFeatureFilter.
setFilter( filteredLayer, *expression );
  3136           if ( !testFilterStringSafety( filter.mFilter ) )
  3139                                           QStringLiteral( 
"The filter string %1"  3140                                               " has been rejected because of security reasons."  3141                                               " Note: Text strings have to be enclosed in single or double quotes."  3142                                               " A space between each word / special character is mandatory."  3143                                               " Allowed Keywords and special characters are "  3144                                               " AND,OR,IN,<,>=,>,>=,!=,',',(,),DMETAPHONE,SOUNDEX."  3145                                               " Not allowed are semicolons in the filter expression." ).arg(
  3149           QString newSubsetString = filter.mFilter;
  3152             newSubsetString.prepend( 
") AND (" );
  3153             newSubsetString.append( 
")" );
  3154             newSubsetString.prepend( filteredLayer->
subsetString() );
  3155             newSubsetString.prepend( 
"(" );
  3163   void QgsRenderer::setLayerSelection( 
QgsMapLayer *layer, 
const QStringList &fids )
 const  3169       for ( 
const QString &
id : fids )
  3179   void QgsRenderer::setLayerAccessControlFilter( 
QgsMapLayer *layer )
 const  3181 #ifdef HAVE_SERVER_PYTHON_PLUGINS  3199   void QgsRenderer::annotationsRendering( QPainter *painter )
 const  3202     const QList< QgsAnnotation * > annotations = annotationManager->
annotations();
  3207       if ( !annotation || !annotation->isVisible() )
  3210       annotation->render( renderContext );
  3214   QImage *QgsRenderer::scaleImage( 
const QImage *image )
 const  3219     QImage *scaledImage = 
nullptr;
  3222     if ( width != image->width() || height != image->height() )
  3224       scaledImage = 
new QImage( image->scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
  3230   void QgsRenderer::checkLayerReadPermissions( 
QgsMapLayer *layer )
 const  3232 #ifdef HAVE_SERVER_PYTHON_PLUGINS  3233     if ( !mAccessControl->layerReadPermission( layer ) )
  3235       throw QgsSecurityException( QStringLiteral( 
"You are not allowed to access to the layer: %1" ).arg( layer->
name() ) );
  3242   void QgsRenderer::removeUnwantedLayers( QList<QgsMapLayer *> &layers, 
double scaleDenominator )
 const  3244     QList<QgsMapLayer *> wantedLayers;
  3248       if ( !layerScaleVisibility( *layer, scaleDenominator ) )
  3251       if ( mRestrictedLayers.contains( layerNickname( *layer ) ) )
  3254       wantedLayers.append( layer );
  3257     layers = wantedLayers;
  3260   void QgsRenderer::removeNonIdentifiableLayers( QList<QgsMapLayer *> &layers )
 const  3262     QList<QgsMapLayer *>::iterator it = layers.begin();
  3263     while ( it != layers.end() )
  3266         it = layers.erase( it );
  3272   QgsLayerTreeModel *QgsRenderer::buildLegendTreeModel( 
const QList<QgsMapLayer *> &layers, 
double scaleDenominator, 
QgsLayerTree &rootGroup )
  3279     bool ruleDefined = 
false;
  3280     if ( !mWmsParameters.
rule().isEmpty() )
  3283     bool contentBasedLegend = 
false;
  3285     if ( ! mWmsParameters.
bbox().isEmpty() )
  3287       contentBasedLegend = 
true;
  3289       if ( contentBasedLegendExtent.
isEmpty() )
  3291                                       QStringLiteral( 
"Invalid BBOX parameter" ) );
  3293       if ( !mWmsParameters.
rule().isEmpty() )
  3295                                       QStringLiteral( 
"BBOX parameter cannot be combined with RULE" ) );
  3300     QList<QgsVectorLayerFeatureCounter *> counters;
  3304       lt->
setCustomProperty( QStringLiteral( 
"showFeatureCount" ), showFeatureCount );
  3306       if ( !ml->
title().isEmpty() )
  3316       counters.append( counter );
  3321     if ( scaleDenominator > 0 )
  3325     if ( contentBasedLegend )
  3328       getMap( contentBasedMapSettings, &hitTest );
  3339         const SymbolSet &usedSymbols = hitTest[vl];
  3345           if ( usedSymbols.contains( sProp ) )
  3351         if ( order.isEmpty() )
  3362     if ( ! ruleDefined )
  3364       QList<QgsLayerTreeNode *> rootChildren = rootGroup.
children();
  3375           if ( !drawLegendItemLabel )
  3379               legendNode->setUserLabel( QStringLiteral( 
" " ) ); 
  3382           else if ( !drawLegendLayerLabel )
  3386               if ( legendNode->isEmbeddedInParent() )
  3387                 legendNode->setEmbeddedInParent( 
false );
  3396       c->waitForFinished();
  3402   qreal QgsRenderer::dotsPerMm()
 const  3404     std::unique_ptr<QImage> tmpImage( createImage( 1, 1, 
false ) );
  3405     return tmpImage->dotsPerMeterX() / 1000.0;
  3408   void QgsRenderer::handlePrintErrors( 
const QgsLayout *layout )
 const  3414     QList< QgsLayoutItemMap * > mapList;
  3417     QList< QgsLayoutItemMap * >::const_iterator mapIt = mapList.constBegin();
  3418     for ( ; mapIt != mapList.constEnd(); ++mapIt )
  3420       if ( !( *mapIt )->renderingErrors().isEmpty() )
  3424         QString errorMsg = QString( 
"Rendering error : '%1' in layer %2" ).arg( e.
message ).arg( e.
layerID );
 void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it. 
 
QgsPrintLayout * clone() const override
Creates a clone of the layout. 
 
QList< QgsWmsParametersHighlightLayer > highlightLayersParameters() const
Returns parameters for each highlight layer. 
 
static void setNodeLegendStyle(QgsLayerTreeNode *node, QgsLegendStyle::Style style)
Sets the style of a node. 
 
QByteArray getFeatureInfo(const QString &version="1.3.0")
Creates an xml document that describes the result of the getFeatureInfo request. 
 
void updateFields()
Will regenerate the fields property of this layer by obtaining all fields from the dataProvider...
 
Layer tree group node serves as a container for layers and further groups. 
 
Wrapper for iterator of features from vector data provider or vector layer. 
 
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend. 
 
bool contains(const QgsRectangle &rect) const
Returns true when rectangle contains other rectangle. 
 
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system 
 
void removeChildrenGroupWithoutLayers()
Remove all child group nodes without layers. 
 
May use more than one symbol to render a feature: symbolsForFeature() will return them...
 
static QgsLayerTreeLayer * toLayer(QgsLayerTreeNode *node)
Cast node to a layer. 
 
A rectangle specified with double values. 
 
Base class for all map layer types. 
 
void dump() const
Dumps parameters. 
 
void setExtent(const QgsRectangle &rect, bool magnified=true)
Set coordinates of the rectangle which should be rendered. 
 
int imageQualityAsInt() const
Returns IMAGE_QUALITY parameter as an integer. 
 
static void setLegendNodeOrder(QgsLayerTreeLayer *nodeLayer, const QList< int > &order)
 
QgsVectorLayerFeatureCounter * countSymbolFeatures()
Count features for symbols. 
 
Item model implementation based on layer tree model for layout legend. 
 
SERVER_EXPORT int wmsMaxWidth(const QgsProject &project)
Returns the maximum width for WMS images defined in a QGIS project. 
 
QSet< QgsFeatureId > QgsFeatureIds
 
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters. 
 
QgsMasterLayoutInterface * layoutByName(const QString &name) const
Returns the layout with a matching name, or nullptr if no matching layouts were found. 
 
void setAttributeDisplayName(bool displayName)
Sets whether to print original names of attributes or aliases if defined. 
 
void layoutObjects(QList< T *> &objectList) const
Returns a list of layout objects (items and multiframes) of a specific type. 
 
QString i() const
Returns I parameter or an empty string if not defined. 
 
void setFields(const QgsFields &fields, bool initAttributes=false)
Assign a field map with the feature to allow attribute access by attribute name. 
 
const Flags & flags() const
 
Manages storage of a set of QgsAnnotation annotation objects. 
 
Abstract base class for all rendered symbols. 
 
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct. 
 
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context. 
 
int featureCountAsInt() const
Returns FEATURE_COUNT as an integer. 
 
virtual QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const
Draws symbol on the left side of the item. 
 
Use exact geometry intersection (slower) instead of bounding boxes. 
 
QSet< QString > excludeAttributesWms() const
A set of attributes that are not advertised in WMS requests with QGIS server. 
 
A layout item subclass for text labels. 
 
QStringList layerIds() const
Gets list of layer IDs for map rendering The layers are stored in the reverse order of how they are r...
 
void setCoordinateTransform(const QgsCoordinateTransform &t)
Sets the current coordinate transform for the context. 
 
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer. 
 
QStringList filters() const
Returns the list of filters found in FILTER parameter. 
 
QgsRectangle bboxAsRectangle() const
Returns BBOX as a rectangle if defined and valid. 
 
QString j() const
Returns J parameter or an empty string if not defined. 
 
ExportResult exportToImage(const QString &filePath, const QgsLayoutExporter::ImageExportSettings &settings)
Exports the layout to the filePath, using the specified export settings. 
 
void render(const QgsMapSettings &mapSettings, QImage *image)
Sequential or parallel map rendering. 
 
QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error. 
 
QList< QgsWmsParametersLayer > mLayers
 
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context. 
 
This class provides qgis with the ability to render raster datasets onto the mapcanvas. 
 
QList< QgsFeature > QgsFeatureList
 
void setIncludeGeometry(bool includeGeometry)
Sets whether to include geometry in the JSON exports. 
 
Counts the features in a QgsVectorLayer in task. 
 
QString scale() const
Returns SCALE parameter or an empty string if none is defined. 
 
void setSize(double size)
Sets the size of the buffer. 
 
A class to represent a 2D point. 
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference) 
 
QgsFeature getFeature(QgsFeatureId fid) const
Query the layer for the feature with the given id. 
 
void setFont(const QFont &font)
Sets the font used for rendering text. 
 
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
 
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer. 
 
SERVER_EXPORT QString wmsFeatureInfoDocumentElement(const QgsProject &project)
Returns the document element name for XML GetFeatureInfo request. 
 
QgsLegendSettings legendSettings() const
Returns legend settings. 
 
void setOutputDpi(double dpi)
Sets DPI used for conversion between real world units (e.g. mm) and pixels. 
 
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched. 
 
QString sldBody() const
Returns SLD_body if defined or an empty string. 
 
int yAsInt() const
Returns Y parameter as an int or its default value if not defined. 
 
int getImageQuality() const
Returns the image quality to use for getMap request. 
 
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon. 
 
double dpiAsDouble() const
Returns DPI parameter as an int or its default value if not defined. 
 
X-coordinate data defined label position. 
 
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale. 
 
Container of fields for a vector layer. 
 
SERVER_EXPORT QHash< QString, QString > wmsFeatureInfoLayerAliasMap(const QgsProject &project)
Returns the mapping between layer name and wms layer name for GetFeatureInfo request. 
 
A geometry is the spatial representation of a feature. 
 
void selectByIds(const QgsFeatureIds &ids, SelectBehavior behavior=SetSelection)
Select matching features using a list of feature IDs. 
 
SERVER_EXPORT bool wmsInfoFormatSia2045(const QgsProject &project)
Returns if the info format is SIA20145. 
 
bool setAttribute(int field, const QVariant &attr)
Set an attribute's value by field index. 
 
void removeChildNode(QgsLayerTreeNode *node)
Remove a child node from this group. 
 
Format
Output format for the response. 
 
int widthAsInt() const
Returns WIDTH parameter as an int or its default value if not defined. 
 
QgsUnitTypes::DistanceUnit mapUnits
 
static QDomElement rectangleToGMLBox(QgsRectangle *box, QDomDocument &doc, int precision=17)
Exports the rectangle to GML2 Box. 
 
void setSymbologyExport(QgsDxfExport::SymbologyExport e)
Set symbology export mode. 
 
QgsRasterRenderer * renderer() const
 
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project. 
 
Exception thrown in case of malformed request. 
 
QList< QgsMapLayer * > layers() const
Gets list of layers for map rendering The layers are stored in the reverse order of how they are rend...
 
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
 
Format infoFormat() const
Returns infoFormat. 
 
Layers and optional attribute index to split into multiple layers using attribute value as layer name...
 
const QgsCoordinateReferenceSystem & crs
 
bool isValid() const
Returns the status of the layer. 
 
RAII class to restore layer configuration on destruction (opacity, filters, ...) 
 
bool transparentAsBool() const
Returns TRANSPARENT parameter as a bool or its default value if not defined. 
 
QgsMapLayer::LayerType type() const
Returns the type of the layer. 
 
int count() const
Returns number of items. 
 
QgsLayoutRenderContext & renderContext()
Returns a reference to the layout's render context, which stores information relating to the current ...
 
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
 
QPainter * painter
Painter. 
 
int readNumEntry(const QString &scope, const QString &key, int def=0, bool *ok=nullptr) const
 
QList< int > pages
List of specific pages to export, or an empty list to export all pages. 
 
bool withMapTip() const
withMapTip 
 
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc. 
 
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system 
 
virtual QgsRectangle extent() const
Returns the extent of the layer. 
 
QgsLayerTreeLayer * addLayer(QgsMapLayer *layer)
Append a new layer node for given map layer. 
 
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected) 
 
Abstract base class for annotation items which are drawn over a map. 
 
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1) 
 
QString bbox() const
Returns BBOX if defined or an empty string. 
 
The QgsMapSettings class contains configuration for rendering of the map. 
 
bool ruleLabelAsBool() const
Returns RULELABEL as a bool. 
 
void setAttributes(const QgsAttributeList &attributes)
Sets the list of attributes to include in the JSON exports. 
 
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager. 
 
SERVER_EXPORT bool wmsFeatureInfoAddWktGeometry(const QgsProject &project)
Returns if the geometry is displayed as Well Known Text in GetFeatureInfo request. 
 
QgsCoordinateTransform layerTransform(const QgsMapLayer *layer) const
Returns the coordinate transform from layer's CRS to destination CRS. 
 
Raster identify results container. 
 
bool showFeatureCountAsBool() const
Returns SHOWFEATURECOUNT as a bool. 
 
void layoutItems(QList< T *> &itemList) const
Returns a list of layout items of a specific type. 
 
int getWMSPrecision() const
Returns the precision to use for GetFeatureInfo request. 
 
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
 
QImage * getMap(HitTest *hitTest=nullptr)
Returns the map as an image (or a null pointer in case of error). 
 
static void applyAccessControlLayerFilters(const QgsAccessControl *accessControl, QgsMapLayer *mapLayer, QHash< QgsMapLayer *, QString > &originalLayerFilters)
Apply filter from AccessControl. 
 
The QgsLayerTreeModel class is model implementation for Qt item views framework. 
 
QHash< QgsVectorLayer *, SymbolSet > HitTest
 
QSize imageSize
Manual size in pixels for output image. 
 
QStringList allLayersNickname() const
Returns nickname of layers found in LAYER and LAYERS parameters. 
 
int lineToleranceAsInt() const
Returns FI_LINE_TOLERANCE parameter as an integer. 
 
QgsRasterDataProvider * dataProvider() override
Returns the layer's data provider, it may be null. 
 
Property
Data definable properties. 
 
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression. 
 
bool isValid() const
Returns true if valid. 
 
QgsRectangle extent() const
Returns geographical coordinates of the rectangle that should be rendered. 
 
QList< QgsMapLayer * > layers() const
Returns the stored layer set. 
 
int indexFromName(const QString &fieldName) const
Gets the field index from the field name. 
 
Layout graphical items for displaying a map. 
 
void setOutputSize(QSize size)
Sets the size of the resulting map image. 
 
QByteArray getPrint(const QString &formatString)
Returns printed page as binary. 
 
QgsDxfExport getDxf(const QMap< QString, QString > &options)
Returns the map as DXF data. 
 
bool displayAll
If true, all features will be labelled even when overlaps occur. 
 
void setSize(double size)
Sets the size for rendered text. 
 
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
 
QString x() const
Returns X parameter or an empty string if not defined. 
 
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject. 
 
QString layoutParameter(const QString &id, bool &ok) const
Returns a layout parameter thanks to its id. 
 
QList< QgsLayerTreeNode * > children()
Gets list of children of the node. Children are owned by the parent. 
 
QgsFields fields() const FINAL
Returns the list of fields of this layer. 
 
SERVER_EXPORT int wmsMaxAtlasFeatures(const QgsProject &project)
Returns the maximum number of atlas features which can be printed in a request. 
 
#define STRING_TO_FID(str)
 
static QString encodeValue(const QVariant &value)
Encodes a value to a JSON string representation, adding appropriate quotations and escaping where req...
 
Namespace with helper functions for layer tree operations. 
 
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
 
QString crs() const
Returns CRS or an empty string if none is defined. 
 
SERVER_EXPORT QString wmsFeatureInfoDocumentElementNs(const QgsProject &project)
Returns the document element namespace for XML GetFeatureInfo request. 
 
bool isEmpty() const
Returns true if the rectangle is empty. 
 
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
 
virtual int capabilities() const
Returns a bitmask containing the supported capabilities. 
 
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source. 
 
double dpi
Resolution to export layout at. If dpi <= 0 the default layout dpi will be used. 
 
QString filterGeom() const
Returns the filter geometry found in FILTER_GEOM parameter. 
 
QgsLayoutPageCollection * pageCollection()
Returns a pointer to the layout's page collection, which stores and manages page items in the layout...
 
double scale() const
Returns the calculated map scale. 
 
A class to describe the version of a project. 
 
void initAttributes(int fieldCount)
Initialize this feature with the given number of fields. 
 
double width() const
Returns the width of the rectangle. 
 
Provides an interface to retrieve and manipulate WMS parameters received from the client...
 
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double. 
 
QImage * getLegendGraphics()
Returns the map legend as an image (or a null pointer in case of error). 
 
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
 
QgsLayerTreeNode * parent()
Gets pointer to the parent. If parent is a null pointer, the node is a root node. ...
 
int infoFormatVersion() const
Returns the infoFormat version for GML. 
 
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary). 
 
bool rasterizeWholeImage
Set to true to force whole layout to be rasterized while exporting. 
 
double mapUnitsPerPixel() const
Returns the distance in geographical coordinates that equals to one pixel in the map. 
 
QString bandName(int bandNoInt) const
Returns the name of a band given its number. 
 
void setY(double y)
Sets the y value of the point. 
 
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector ...
 
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
 
SERVER_EXPORT bool wmsFeatureInfoSegmentizeWktGeometry(const QgsProject &project)
Returns if the geometry has to be segmentize in GetFeatureInfo request. 
 
void setEnabled(bool enabled)
Sets whether the text buffer will be drawn. 
 
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
 
static QgsRenderContext fromQPainter(QPainter *painter)
Creates a default render context given a pixel based QPainter destination. 
 
void setFilter(const QgsVectorLayer *layer, const QgsExpression &expression)
Set a filter for the given layer. 
 
Horizontal alignment for data defined label position (Left, Center, Right) 
 
void clear()
Clear any information from this layer tree. 
 
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
 
void setColor(const QColor &color)
Sets the color that text will be rendered in. 
 
QString imageQuality() const
Returns IMAGE_QUALITY parameter or an empty string if not defined. 
 
This class wraps a request for features to a vector layer (or directly its vector data provider)...
 
void setSelectionColor(const QColor &color)
Sets color that is used for drawing of selected vector features. 
 
QgsAttributeList primaryKeyAttributes() const
Returns the list of attributes which make up the layer's primary keys. 
 
QList< QgsWmsParametersHighlightLayer > mHighlightLayers
 
void removeMultiFrame(QgsLayoutMultiFrame *multiFrame)
Removes a multiFrame from the layout (but does not delete it). 
 
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken. 
 
QgsRectangle layerExtentToOutputExtent(const QgsMapLayer *layer, QgsRectangle extent) const
transform bounding box from layer's CRS to output CRS 
 
static bool isLayer(const QgsLayerTreeNode *node)
Check whether the node is a valid layer node. 
 
QString composerTemplate() const
Returns TEMPLATE parameter or an empty string if not defined. 
 
This class is a base class for nodes in a layer tree. 
 
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false) ...
 
Reads and writes project states. 
 
void setLegendFilterByScale(double scale)
Force only display of legend nodes which are valid for a given scale. 
 
QgsProjectVersion versionAsNumber() const
Returns VERSION parameter if defined or its default value. 
 
QgsFeatureRenderer * renderer()
Returns renderer. 
 
ExportResult exportToSvg(const QString &filePath, const QgsLayoutExporter::SvgExportSettings &settings)
Exports the layout as an SVG to the filePath, using the specified export settings. 
 
QString id() const
Returns the item's ID name. 
 
Encapsulate a field in an attribute table or data source. 
 
QgsGeometry pointOnSurface() const
Returns a point guaranteed to lie on the surface of a geometry. 
 
QStringList queryLayersNickname() const
Returns nickname of layers found in QUERY_LAYERS parameter. 
 
Abstract base class for all geometries. 
 
double mapUnitsPerPixel() const
Returns current map units per pixel. 
 
QgsLayoutRenderContext::Flags flags
Layout context flags, which control how the export will be created. 
 
int pointToleranceAsInt() const
Returns FI_POINT_TOLERANCE parameter as an integer. 
 
Format format() const
Returns format. 
 
Base class for layouts, which can contain items such as maps, labels, scalebars, etc. 
 
Manages storage of a set of layouts. 
 
QgsWkbTypes::Type wkbType() const
Returns the WKB type of the geometry. 
 
Keeps the number of features and export symbology per feature (using the first symbol level) ...
 
QMap< QString, QgsMapLayer * > mapLayers(const bool validOnly=false) const
Returns a map of all registered layers by layer ID. 
 
virtual bool readSld(const QDomNode &node, QString &errorMessage)
 
QgsAnnotationManager * annotationManager()
Returns pointer to the project's annotation manager. 
 
int polygonToleranceAsInt() const
Returns FI_POLYGON_TOLERANCE parameter as an integer. 
 
void setX(double x)
Sets the x value of the point. 
 
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages compositions within the project. 
 
Handles exporting QgsFeature features to GeoJSON features. 
 
Exception base class for server exceptions. 
 
void setName(const QString &n) override
Sets the layer's name. 
 
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request. 
 
bool layerTitleAsBool() const
Returns LAYERTITLE as a bool or its default value if not defined. 
 
Median cut implementation. 
 
void refreshLayerLegend(QgsLayerTreeLayer *nodeLayer)
Force a refresh of legend nodes of a layer node. 
 
bool parallelRendering() const
Returns parallel rendering setting. 
 
bool withGeometry() const
Returns if the client wants the feature info response with geometry information. 
 
QMap< int, QVariant > results() const
Returns the identify results. 
 
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive. 
 
int pageCount() const
Returns the number of pages in the collection. 
 
double yMinimum() const
Returns the y minimum value (bottom side of rectangle). 
 
QgsExpressionContext & expressionContext()
Gets the expression context. 
 
QString asWkt(int precision=17) const
Exports the geometry to WKT. 
 
Calculates scale for a given combination of canvas size, map extent, and monitor dpi. 
 
Handles rendering and exports of layouts to various formats. 
 
static QString symbolProperties(QgsSymbol *symbol)
Returns a string representing the symbol. 
 
QgsLayerTree * layerTreeRoot() const
Returns pointer to the root (invisible) node of the project's layer tree. 
 
double xMaximum() const
Returns the x maximum value (right side of rectangle). 
 
QgsMapLayer * layer() const
Returns the map layer associated with this node. 
 
unsigned int placementFlags
 
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle...
 
int heightAsInt() const
Returns HEIGHT parameter as an int or its default value if not defined. 
 
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string. 
 
int wmsPrecisionAsInt() const
Returns WMS_PRECISION parameter as an int or its default value if not defined. 
 
Placement
Placement modes which determine how label candidates are generated for a feature. ...
 
QSet< QString > SymbolSet
 
Contains settings relating to exporting layouts to PDF. 
 
void setBackgroundColor(const QColor &color)
Sets the background color of the map. 
 
void setSymbologyScale(double scale)
Set reference scale for output. 
 
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins...
 
Special style, item is hidden including margins around. 
 
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
 
void setLabelingEngineSettings(const QgsLabelingEngineSettings &settings)
Sets the global configuration of the labeling engine. 
 
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
 
Contains information about the context of a rendering operation. 
 
double length() const
Returns the length of the measurement. 
 
Contains settings relating to exporting layouts to raster images. 
 
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object...
 
int jAsInt() const
Returns J parameter as an int or its default value if not defined. 
 
double scaleAsDouble() const
Returns SCALE as a double. 
 
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string. 
 
const QgsMapToPixel & mapToPixel() const
 
QList< QgsAnnotation *> annotations() const
Returns a list of all annotations contained in the manager. 
 
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point. 
 
#define FID_TO_STRING(fid)
 
QgsEditorWidgetSetup editorWidgetSetup(int index) const
The editor widget setup defines which QgsFieldFormatter and editor widget will be used for the field ...
 
void removeLayoutItem(QgsLayoutItem *item)
Removes an item from the layout. 
 
void setLayerTitleAsName(bool layerTitleAsName)
Enable use of title (where set) instead of layer name, when attribute index of corresponding layer in...
 
QgsLayerTree * rootGroup() const
Returns pointer to the root node of the layer tree. Always a non-null pointer. 
 
void setSelectionColor(const QColor &color)
Sets color that is used for drawing of selected vector features. 
 
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer. 
 
QPointF point
Top-left corner of the legend item. 
 
void setExtent(const QgsRectangle &r)
Set extent of area to export. 
 
double dpi
Resolution to export layout at. If dpi <= 0 the default layout dpi will be used. 
 
QString pointTolerance() const
Returns FI_POINT_TOLERANCE parameter or an empty string if not defined. 
 
static bool isCurvedType(Type type)
Returns true if the WKB type is a curved type or can contain curved geometries. 
 
SERVER_EXPORT int wmsFeatureInfoPrecision(const QgsProject &project)
Returns the geometry precision for GetFeatureInfo request. 
 
QgsPointXY layerToMapCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from layer's CRS to output CRS 
 
double scale() const
Returns the map scale. 
 
static QgsFeatureRenderer * loadSld(const QDomNode &node, QgsWkbTypes::GeometryType geomType, QString &errorMessage)
Create a new renderer according to the information contained in the UserStyle element of a SLD style ...
 
Container for settings relating to a text buffer. 
 
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings 
 
QgsLayerTreeGroup * findGroup(const QString &name)
Find group node with specified name. 
 
ExportResult exportToPdf(const QString &filePath, const QgsLayoutExporter::PdfExportSettings &settings)
Exports the layout as a PDF to the filePath, using the specified export settings. ...
 
Exception thrown when data access violates access controls. 
 
Proxy for sequential or parallel map render job. 
 
double dist
Distance from feature to the label. 
 
QgsRectangle boundingBox() const
Returns the bounding box of the geometry. 
 
bool hasAxisInverted() const
Returns whether axis is inverted (e.g., for WMS 1.3) for the CRS. 
 
SERVER_EXPORT QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS. 
 
This class represents a coordinate reference system (CRS). 
 
QgsFeatureFilterProviderGroup & addProvider(const QgsFeatureFilterProvider *provider)
Add another filter provider to the group. 
 
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry. 
 
QString polygonTolerance() const
Returns FI_POLYGON_TOLERANCE parameter or an empty string if not defined. 
 
virtual QgsRasterIdentifyResult identify(const QgsPointXY &point, QgsRaster::IdentifyFormat format, const QgsRectangle &boundingBox=QgsRectangle(), int width=0, int height=0, int dpi=96)
Identify raster value(s) found on the point position. 
 
QStringList atlasPk() const
Returns the ATLAS_PK parameter. 
 
static QDomElement geometryToGML(const QgsGeometry &geometry, QDomDocument &doc, QgsOgcUtils::GMLVersion gmlVersion, const QString &srsName, bool invertAxisOrientation, const QString &gmlIdBase, int precision=17)
Exports the geometry to GML. 
 
static QString displayString(Type type)
Returns a display string type for a WKB type, e.g., the geometry name used in WKT geometry representa...
 
virtual bool setSubsetString(const QString &subset)
Set the string (typically sql) used to define a subset of the layer. 
 
static QDomElement rectangleToGMLEnvelope(QgsRectangle *env, QDomDocument &doc, int precision=17)
Exports the rectangle to GML3 Envelope. 
 
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
 
const QgsCoordinateReferenceSystem & outputCrs
 
double xMinimum() const
Returns the x minimum value (left side of rectangle). 
 
void setLayers(const QList< QgsMapLayer *> &layers)
Set list of layers for map rendering. 
 
Basic implementation of the labeling interface. 
 
QList< QgsLayerTreeModelLegendNode * > layerLegendNodes(QgsLayerTreeLayer *nodeLayer, bool skipNodeEmbeddedInParent=false)
Returns filtered list of active legend nodes attached to a particular layer node (by default it retur...
 
QString lineTolerance() const
Returns FI_LINE_TOLERANCE parameter or an empty string if not defined. 
 
QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID. 
 
QSizeF minimumSize(QgsRenderContext *renderContext=nullptr)
Runs the layout algorithm and returns the minimum size required for the legend. 
 
void setBuffer(const QgsTextBufferSettings &bufferSettings)
Sets the text's buffer settings. 
 
double yMaximum() const
Returns the y maximum value (top side of rectangle). 
 
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Query the layer for features specified in request. 
 
QString rule() const
Returns RULE parameter or an empty string if none is defined. 
 
Enable vector simplification and other rendering optimizations. 
 
QString y() const
Returns Y parameter or an empty string if not defined. 
 
QColor backgroundColorAsColor() const
Returns BGCOLOR parameter as a QColor or its default value if not defined. 
 
void setOpacity(double opacity)
Sets the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1...
 
QStringList findLayerIds() const
Find layer IDs used in all layer nodes. 
 
QgsWkbTypes::GeometryType type
 
Custom exception class for Coordinate Reference System related exceptions. 
 
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer. 
 
QString title() const
Returns the project's title. 
 
QColor selectionColor() const
Gets color that is used for drawing of selected vector features. 
 
SERVER_EXPORT QString wmsFeatureInfoSchema(const QgsProject &project)
Returns the schema URL for XML GetFeatureInfo request. 
 
QList< int > QgsAttributeList
 
Print layout, a QgsLayout subclass for static or atlas-based layouts. 
 
QList< QgsLayerTreeLayer * > findLayers() const
Find all layer nodes. 
 
QString exportFeature(const QgsFeature &feature, const QVariantMap &extraProperties=QVariantMap(), const QVariant &id=QVariant()) const
Returns a GeoJSON string representation of a feature. 
 
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer. 
 
A layout item subclass for map legends. 
 
QgsLayerTreeLayer * findLayer(QgsMapLayer *layer) const
Find layer node representing the map layer. 
 
QgsRenderer(QgsServerInterface *serverIface, const QgsProject *project, const QgsWmsParameters ¶meters)
Constructor. 
 
Y-coordinate data defined label position. 
 
bool nextFeature(QgsFeature &f)
 
SERVER_EXPORT QStringList wmsRestrictedLayers(const QgsProject &project)
Returns the restricted layer name list. 
 
Container of other groups and layers. 
 
Container for all settings relating to text rendering. 
 
QgsLayoutRenderContext::Flags flags
Layout context flags, which control how the export will be created. 
 
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
 
SERVER_EXPORT QString wmsRootName(const QgsProject &project)
Returns the WMS root layer name defined in a QGIS project. 
 
Geometry is not required. It may still be returned if e.g. required for a filter condition. 
 
void set(QgsAbstractGeometry *geometry)
Sets the underlying geometry store. 
 
static QgsExpression * expressionFromOgcFilter(const QDomElement &element, QgsVectorLayer *layer=nullptr)
Parse XML with OGC filter into QGIS expression. 
 
double dpi
Resolution to export layout at. If dpi <= 0 the default layout dpi will be used. 
 
int maxThreads() const
Returns the maximum number of threads to use. 
 
Exception class for WMS service exceptions (for compatibility only). 
 
QString dpi() const
Returns DPI parameter or an empty string if not defined. 
 
QgsPointXY mapToLayerCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from output CRS to layer's CRS 
 
Represents a vector layer which manages a vector based data sets. 
 
double labelXOffset
offset from the left side where label should start 
 
int iAsInt() const
Returns I parameter as an int or its default value if not defined. 
 
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name. 
 
Contains settings relating to exporting layouts to SVG. 
 
Base class for frame items, which form a layout multiframe item. 
 
bool infoFormatIsImage() const
Checks if INFO_FORMAT parameter is one of the image formats (PNG, JPG). 
 
QList< QgsWmsParametersLayer > layersParameters() const
Returns parameters for each layer found in LAYER/LAYERS. 
 
QgsWmsParametersComposerMap composerMapParameters(int mapId) const
Returns the requested parameters for a composer map parameter. 
 
virtual QgsAbstractGeometry * segmentize(double tolerance=M_PI/180., SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a version of the geometry without curves. 
 
A layout multiframe subclass for HTML content. 
 
Vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top) ...
 
Defines a QGIS exception class. 
 
QgsCoordinateTransformContext transformContext() const
Returns the transform context, for use when a destinationCrs() has been set and reprojection is requi...
 
void addLayers(const QList< QgsDxfExport::DxfLayer > &layers)
Add layers to export. 
 
QString attributeDisplayName(int index) const
Convenience function that returns the attribute alias if defined or the field name else...
 
void setColor(const QColor &color)
Sets the color for the buffer. 
 
int priority
Label priority. 
 
If the layer is identifiable using the identify map tool and as a WMS layer. 
 
QSize outputSize() const
Returns the size of the resulting map image. 
 
Raster renderer pipe that applies colors to a raster. 
 
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer. 
 
QString authid() const
Returns the authority identifier for the CRS. 
 
A filter filter provider grouping several filter providers. 
 
bool setCurrentStyle(const QString &name)
Set a different style as the current style - will apply it to the layer. 
 
QString externalWMSUri(const QString &id) const
Returns the external WMS uri. 
 
QgsCoordinateReferenceSystem crs
 
SERVER_EXPORT int wmsImageQuality(const QgsProject &project)
Returns the quality for WMS images defined in a QGIS project. 
 
void invert()
Swap x/y coordinates in the rectangle. 
 
double height() const
Returns the height of the rectangle. 
 
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched. 
 
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label's property collection, used for data defined overrides. 
 
int xAsInt() const
Returns X parameter as an int or its default value if not defined. 
 
void setCustomProperty(const QString &key, const QVariant &value)
Sets a custom property for the node. Properties are stored in a map and saved in project file...
 
Layer tree node points to a map layer. 
 
The QgsLegendRenderer class handles automatic layout and rendering of legend. 
 
QgsLayoutRenderContext::Flags flags
Layout context flags, which control how the export will be created. 
 
SERVER_EXPORT int wmsMaxHeight(const QgsProject &project)
Returns the maximum height for WMS images defined in a QGIS project. 
 
static QString replaceExpressionText(const QString &action, const QgsExpressionContext *context, const QgsDistanceArea *distanceArea=nullptr)
This function replaces each expression between [% and %] in the string with the result of its evaluat...
 
QString fieldName
Name of field (or an expression) to use for label text. 
 
const QgsLabelingEngineSettings & labelingEngineSettings() const
Returns project's global labeling engine settings. 
 
SERVER_EXPORT bool wmsUseLayerIds(const QgsProject &project)
Returns if layer ids are used as name in WMS. 
 
bool isValid() const
Returns whether this CRS is correctly initialized and usable. 
 
Exports one feature per symbol layer (considering symbol levels) 
 
void setOpacity(double opacity)
Sets the opacity for the vector layer, where opacity is a value between 0 (totally transparent) and 1...