67 #include "qgsattributeeditorcontainer.h"
68 #include "qgsattributeeditorelement.h"
69 #include "qgsattributeeditorfield.h"
73 #include <QStringList>
74 #include <QTemporaryFile>
77 #include <nlohmann/json.hpp>
102 : mContext( context )
107 mWmsParameters.
dump();
112 removeTemporaryLayers();
118 std::unique_ptr<QgsWmsRestorer> restorer;
130 std::unique_ptr<QImage> image;
133 const QSize size(
static_cast<int>( minSize.width() * dpmm ),
static_cast<int>( minSize.height() * dpmm ) );
134 image.reset( createImage( size ) );
137 QPainter painter( image.get() );
151 return image.release();
157 std::unique_ptr<QgsWmsRestorer> restorer;
166 std::unique_ptr<QImage> image( createImage( size ) );
170 std::unique_ptr<QPainter> painter;
171 painter.reset(
new QPainter( image.get() ) );
172 painter->setRenderHint( QPainter::Antialiasing,
true );
173 painter->scale( dpmm, dpmm );
179 nodeModel.
drawSymbol( settings, &ctx, size.height() / dpmm );
182 return image.release();
188 std::unique_ptr<QgsWmsRestorer> restorer;
204 void QgsRenderer::runHitTest(
const QgsMapSettings &mapSettings, HitTest &hitTest )
const
208 for (
const QString &
id : mapSettings.
layerIds() )
225 runHitTestLayer( vl, usedSymbols, context );
231 std::unique_ptr< QgsFeatureRenderer > r( vl->
renderer()->
clone() );
233 r->startRender( context, vl->
fields() );
241 if ( moreSymbolsPerFeature )
243 for (
QgsSymbol *s : r->originalSymbolsForFeature( f, context ) )
249 r->stopRender( context );
258 QStringLiteral(
"The requested map size is too large" ) );
262 std::unique_ptr<QgsWmsRestorer> restorer;
272 std::unique_ptr<QPainter> painter;
273 std::unique_ptr<QImage> image( createImage( mContext.
mapSize() ) );
276 configureMapSettings( image.get(), mapSettings );
283 runHitTest( mapSettings,
symbols );
291 std::unique_ptr<QgsWmsRestorer> restorer;
296 if ( templateName.isEmpty() )
315 QStringLiteral(
"The template has no pages" ) );
318 std::unique_ptr<QgsPrintLayout> layout( sourceLayout->
clone() );
322 QStringList atlasPk = mWmsParameters.
atlasPk();
323 if ( !atlasPk.isEmpty() )
325 atlas = layout->atlas();
326 if ( !atlas || !atlas->
enabled() )
330 QStringLiteral(
"The template has no atlas enabled" ) );
337 QStringLiteral(
"The atlas has no coverage layer" ) );
341 if ( atlasPk.size() == 1 && atlasPk.at( 0 ) == QLatin1String(
"*" ) )
345 if ( atlas->
count() > maxAtlasFeatures )
348 QString(
"The project configuration allows printing maximum %1 atlas features at a time" ).arg( maxAtlasFeatures ) );
354 if ( pkIndexes.size() < 1 )
356 throw QgsException( QStringLiteral(
"An error occurred during the Atlas print" ) );
358 QStringList pkAttributeNames;
359 for (
int i = 0; i < pkIndexes.size(); ++i )
361 pkAttributeNames.append( cLayer->
fields()[pkIndexes.at( i )].name() );
364 int nAtlasFeatures = atlasPk.size() / pkIndexes.size();
365 if ( nAtlasFeatures * pkIndexes.size() != atlasPk.size() )
368 QStringLiteral(
"Wrong number of ATLAS_PK parameters" ) );
372 if ( nAtlasFeatures > maxAtlasFeatures )
375 QString(
"%1 atlas features have been requestet, but the project configuration only allows printing %2 atlas features at a time" )
376 .arg( nAtlasFeatures ).arg( maxAtlasFeatures ) );
379 QString filterString;
380 int currentAtlasPk = 0;
382 for (
int i = 0; i < nAtlasFeatures; ++i )
386 filterString.append(
" OR " );
389 filterString.append(
"( " );
391 for (
int j = 0; j < pkIndexes.size(); ++j )
395 filterString.append(
" AND " );
397 filterString.append( QString(
"\"%1\" = %2" ).arg( pkAttributeNames.at( j ), atlasPk.at( currentAtlasPk ) ) );
401 filterString.append(
" )" );
407 if ( !errorString.isEmpty() )
409 throw QgsException( QStringLiteral(
"An error occurred during the Atlas print" ) );
421 std::unique_ptr<QImage> image(
new QImage() );
422 configureMapSettings( image.get(), mapSettings );
428 configurePrintLayout( layout.get(), mapSettings, atlas );
430 #ifdef HAVE_SERVER_PYTHON_PLUGINS
432 mContext.accessControl()->resolveFilterFeatures( mapSettings.
layers() );
442 QTemporaryFile tempOutputFile( QDir::tempPath() +
'/' + QStringLiteral(
"XXXXXX.%1" ).arg( extension ) );
443 if ( !tempOutputFile.open() )
445 throw QgsException( QStringLiteral(
"Could not open temporary file for the GetPrint request." ) );
454 if ( !mWmsParameters.
dpi().isEmpty() )
457 double dpi( mWmsParameters.
dpi().toDouble( &ok ) );
459 exportSettings.
dpi = dpi;
470 atlasSvgExport.
exportToSvg( tempOutputFile.fileName(), exportSettings );
476 exporter.
exportToSvg( tempOutputFile.fileName(), exportSettings );
485 double dpi( layout->renderContext().dpi( ) );
486 if ( !mWmsParameters.
dpi().isEmpty() )
489 double _dpi = mWmsParameters.
dpi().toDouble( &ok );
493 exportSettings.
dpi = dpi;
497 QgsLayoutSize layoutSize( layout->pageCollection()->page( 0 )->sizeWithUnits() );
498 QgsLayoutMeasurement width( layout->convertFromLayoutUnits( layoutSize.
width(), QgsUnitTypes::LayoutUnit::LayoutMillimeters ) );
499 QgsLayoutMeasurement height( layout->convertFromLayoutUnits( layoutSize.
height(), QgsUnitTypes::LayoutUnit::LayoutMillimeters ) );
500 exportSettings.
imageSize = QSize(
static_cast<int>( width.
length() * dpi / 25.4 ),
static_cast<int>( height.
length() * dpi / 25.4 ) );
502 exportSettings.
pages.append( 0 );
510 atlasPngExport.
exportToImage( tempOutputFile.fileName(), exportSettings );
514 throw QgsServiceException( QStringLiteral(
"Bad request" ), QStringLiteral(
"Atlas error: empty atlas." ), QString(), 400 );
520 exporter.
exportToImage( tempOutputFile.fileName(), exportSettings );
528 if ( !mWmsParameters.
dpi().isEmpty() )
531 double dpi( mWmsParameters.
dpi().toDouble( &ok ) );
533 exportSettings.
dpi = dpi;
538 exportSettings.
rasterizeWholeImage = layout->customProperty( QStringLiteral(
"rasterize" ),
false ).toBool();
544 exporter.
exportToPdf( atlas, tempOutputFile.fileName(), exportSettings, exportError );
548 exporter.
exportToPdf( tempOutputFile.fileName(), exportSettings );
559 handlePrintErrors( atlas->
layout() );
563 handlePrintErrors( layout.get() );
566 return tempOutputFile.readAll();
574 QList<QgsLayoutItemMap *> maps;
580 for (
const auto &map : qgis::as_const( maps ) )
585 if ( !atlasPrint || !map->atlasDriven() )
591 c->removeLayoutItem( map );
609 if ( cMapParams.
mScale > 0 )
611 map->setScale(
static_cast<double>( cMapParams.
mScale ) );
617 map->setMapRotation( cMapParams.
mRotation );
621 if ( !map->keepLayerSet() )
623 if ( cMapParams.
mLayers.isEmpty() )
625 map->setLayers( mapSettings.
layers() );
629 QList<QgsMapLayer *> layerSet;
630 for (
auto layer : cMapParams.
mLayers )
634 QList<QgsMapLayer *> layersFromGroup;
636 const QList<QgsMapLayer *> cLayersFromGroup = mContext.
layersFromGroup( layer.mNickname );
637 for (
QgsMapLayer *layerFromGroup : cLayersFromGroup )
640 if ( ! layerFromGroup )
645 layersFromGroup.push_front( layerFromGroup );
648 if ( !layersFromGroup.isEmpty() )
650 layerSet.append( layersFromGroup );
662 setLayerStyle( mlayer, layer.mStyle );
668 std::reverse( layerSet.begin(), layerSet.end() );
669 map->setLayers( layerSet );
671 map->setKeepLayerSet(
true );
677 map->grid()->setIntervalX(
static_cast<double>( cMapParams.
mGridX ) );
678 map->grid()->setIntervalY(
static_cast<double>( cMapParams.
mGridY ) );
683 QList<QgsLayoutItemLabel *> labels;
685 for (
const auto &label : qgis::as_const( labels ) )
688 const QString labelId = label->
id();
689 const QString labelParam = mWmsParameters.
layoutParameter( labelId, ok );
694 if ( labelParam.isEmpty() )
698 c->removeItem( label );
703 label->setText( labelParam );
707 QList<QgsLayoutItemHtml *> htmls;
709 for (
const auto &html : qgis::as_const( htmls ) )
711 if ( html->frameCount() == 0 )
716 const QString htmlId = htmlFrame->
id();
729 c->removeMultiFrame( html );
735 html->setUrl( newUrl );
741 QList<QgsLayoutItemLegend *> legends;
743 for (
const auto &legend : qgis::as_const( legends ) )
745 if ( legend->autoUpdateModel() )
755 legend->setAutoUpdateModel(
false );
759 QStringList layerSet;
760 const QList<QgsMapLayer *> layerList( map->
layers() );
761 for (
const auto &layer : layerList )
762 layerSet << layer->id();
774 for (
const auto &layerId : layerIds )
781 if ( !layerSet.contains( layerId ) )
783 qobject_cast<QgsLayerTreeGroup *>( nodeLayer->
parent() )->removeChildNode( nodeLayer );
790 qobject_cast<QgsLayerTreeGroup *>( nodeLayer->
parent() )->removeChildNode( nodeLayer );
806 QStringLiteral(
"The requested map size is too large" ) );
810 std::unique_ptr<QgsWmsRestorer> restorer;
821 std::unique_ptr<QPainter> painter;
822 std::unique_ptr<QImage> image( createImage( mContext.
mapSize() ) );
825 configureMapSettings( image.get(), mapSettings );
831 painter.reset( layersRendering( mapSettings, *image ) );
834 annotationsRendering( painter.get() );
840 QImage *scaledImage = scaleImage( image.get() );
842 image.reset( scaledImage );
845 return image.release();
851 std::unique_ptr<QgsWmsRestorer> restorer;
860 QList< QgsDxfExport::DxfLayer > dxfLayers;
872 int layerAttribute = -1;
873 if ( attributes.size() > layerIdx )
884 QString
crs = mWmsParameters.
crs();
885 if (
crs.compare( QStringLiteral(
"CRS:84" ), Qt::CaseInsensitive ) == 0 )
887 crs = QStringLiteral(
"EPSG:4326" );
890 else if (
crs.isEmpty() )
892 crs = QStringLiteral(
"EPSG:4326" );
926 std::unique_ptr<QgsDxfExport> dxf = qgis::make_unique<QgsDxfExport>();
927 dxf->setExtent( mapExtent );
928 dxf->setDestinationCrs( outputCRS );
929 dxf->addLayers( dxfLayers );
931 dxf->setSymbologyExport( mWmsParameters.
dxfMode() );
932 if ( mWmsParameters.
dxfFormatOptions().contains( QgsWmsParameters::DxfFormatOption::SCALE ) )
934 dxf->setSymbologyScale( mWmsParameters.
dxfScale() );
937 dxf->setForce2d( mWmsParameters.
isForce2D() );
938 QgsDxfExport::Flags flags;
939 if ( mWmsParameters.
noMText() )
940 flags.setFlag( QgsDxfExport::Flag::FlagNoMText );
942 dxf->setFlags( flags );
950 if ( i < 0 || i > mapSettings.
outputSize().width() )
958 if ( j < 0 || j > mapSettings.
outputSize().height() )
983 const bool ijDefined = !mWmsParameters.
i().isEmpty() && !mWmsParameters.
j().isEmpty();
984 const bool xyDefined = !mWmsParameters.
x().isEmpty() && !mWmsParameters.
y().isEmpty();
985 const bool filtersDefined = !mWmsParameters.
filters().isEmpty();
986 const bool filterGeomDefined = !mWmsParameters.
filterGeom().isEmpty();
988 if ( !ijDefined && !xyDefined && !filtersDefined && !filterGeomDefined )
992 if ( mWmsParameters.
j().isEmpty() )
999 if ( infoFormat == QgsWmsParameters::Format::NONE )
1006 std::unique_ptr<QImage> outputImage( createImage( mContext.
mapSize() ) );
1009 std::unique_ptr<QgsWmsRestorer> restorer;
1014 bool mandatoryCrsParam =
true;
1015 if ( filtersDefined && !ijDefined && !xyDefined && mWmsParameters.
crs().isEmpty() )
1017 mandatoryCrsParam =
false;
1023 configureMapSettings( outputImage.get(), mapSettings, mandatoryCrsParam );
1039 #ifdef HAVE_SERVER_PYTHON_PLUGINS
1040 mContext.accessControl()->resolveFilterFeatures( mapSettings.
layers() );
1043 QDomDocument result = featureInfoDocument( layers, mapSettings, outputImage.get(), version );
1047 if ( infoFormat == QgsWmsParameters::Format::TEXT )
1048 ba = convertFeatureInfoToText( result );
1049 else if ( infoFormat == QgsWmsParameters::Format::HTML )
1050 ba = convertFeatureInfoToHtml( result );
1051 else if ( infoFormat == QgsWmsParameters::Format::JSON )
1052 ba = convertFeatureInfoToJson( layers, result );
1054 ba = result.toByteArray();
1059 QImage *QgsRenderer::createImage(
const QSize &size )
const
1061 std::unique_ptr<QImage> image;
1069 image = qgis::make_unique<QImage>( size, QImage::Format_ARGB32_Premultiplied );
1074 image = qgis::make_unique<QImage>( size, QImage::Format_RGB32 );
1079 if ( image->isNull() )
1081 throw QgsException( QStringLiteral(
"createImage: image could not be created, check for out of memory conditions" ) );
1084 const int dpm =
static_cast<int>( mContext.
dotsPerMm() * 1000.0 );
1085 image->setDotsPerMeterX( dpm );
1086 image->setDotsPerMeterY( dpm );
1088 return image.release();
1091 void QgsRenderer::configureMapSettings(
const QPaintDevice *paintDevice,
QgsMapSettings &mapSettings,
bool mandatoryCrsParam )
const
1095 throw QgsException( QStringLiteral(
"configureMapSettings: no paint device" ) );
1098 mapSettings.
setOutputSize( QSize( paintDevice->width(), paintDevice->height() ) );
1099 mapSettings.
setOutputDpi( paintDevice->logicalDpiX() );
1103 if ( !mWmsParameters.
bbox().isEmpty() && mapExtent.
isEmpty() )
1109 QString
crs = mWmsParameters.
crs();
1110 if (
crs.compare(
"CRS:84", Qt::CaseInsensitive ) == 0 )
1112 crs = QString(
"EPSG:4326" );
1115 else if (
crs.isEmpty() && !mandatoryCrsParam )
1117 crs = QString(
"EPSG:4326" );
1127 QgsWmsParameter parameter;
1169 else if ( backgroundColor.isValid() )
1191 QDomDocument QgsRenderer::featureInfoDocument( QList<QgsMapLayer *> &layers,
const QgsMapSettings &mapSettings,
1192 const QImage *outputImage,
const QString &version )
const
1196 bool ijDefined = ( !mWmsParameters.
i().isEmpty() && !mWmsParameters.
j().isEmpty() );
1198 bool xyDefined = ( !mWmsParameters.
x().isEmpty() && !mWmsParameters.
y().isEmpty() );
1200 bool filtersDefined = !mWmsParameters.
filters().isEmpty();
1202 bool filterGeomDefined = !mWmsParameters.
filterGeom().isEmpty();
1205 if ( featureCount < 1 )
1210 int i = mWmsParameters.
iAsInt();
1211 int j = mWmsParameters.
jAsInt();
1212 if ( xyDefined && !ijDefined )
1214 i = mWmsParameters.
xAsInt();
1215 j = mWmsParameters.
yAsInt();
1219 if ( ( i != -1 && j != -1 && width != 0 && height != 0 ) && ( width != outputImage->width() || height != outputImage->height() ) )
1221 i *= ( outputImage->width() /
static_cast<double>( width ) );
1222 j *= ( outputImage->height() /
static_cast<double>( height ) );
1226 std::unique_ptr<QgsRectangle> featuresRect;
1227 std::unique_ptr<QgsGeometry> filterGeom;
1228 std::unique_ptr<QgsPointXY> infoPoint;
1230 if ( i != -1 && j != -1 )
1233 infoPointToMapCoordinates( i, j, infoPoint.get(), mapSettings );
1235 else if ( filtersDefined )
1239 else if ( filterGeomDefined )
1244 QDomDocument result;
1246 QDomElement getFeatureInfoElement;
1248 if ( infoFormat == QgsWmsParameters::Format::GML )
1250 getFeatureInfoElement = result.createElement( QStringLiteral(
"wfs:FeatureCollection" ) );
1251 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:wfs" ), QStringLiteral(
"http://www.opengis.net/wfs" ) );
1252 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:ogc" ), QStringLiteral(
"http://www.opengis.net/ogc" ) );
1253 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:gml" ), QStringLiteral(
"http://www.opengis.net/gml" ) );
1254 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:ows" ), QStringLiteral(
"http://www.opengis.net/ows" ) );
1255 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1256 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:qgs" ), QStringLiteral(
"http://qgis.org/gml" ) );
1257 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
1258 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" ) );
1263 if ( featureInfoElemName.isEmpty() )
1265 featureInfoElemName = QStringLiteral(
"GetFeatureInfoResponse" );
1268 if ( featureInfoElemNs.isEmpty() )
1270 getFeatureInfoElement = result.createElement( featureInfoElemName );
1274 getFeatureInfoElement = result.createElementNS( featureInfoElemNs, featureInfoElemName );
1278 if ( !featureInfoSchema.isEmpty() )
1280 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
1281 getFeatureInfoElement.setAttribute( QStringLiteral(
"xsi:schemaLocation" ), featureInfoSchema );
1284 result.appendChild( getFeatureInfoElement );
1294 for (
const QString &queryLayer : queryLayers )
1296 bool validLayer =
false;
1297 bool queryableLayer =
true;
1298 for (
QgsMapLayer *layer : qgis::as_const( layers ) )
1304 if ( !queryableLayer )
1309 QDomElement layerElement;
1310 if ( infoFormat == QgsWmsParameters::Format::GML )
1312 layerElement = getFeatureInfoElement;
1316 layerElement = result.createElement( QStringLiteral(
"Layer" ) );
1317 QString layerName = queryLayer;
1320 QHash<QString, QString>::const_iterator layerAliasIt = layerAliasMap.constFind( layerName );
1321 if ( layerAliasIt != layerAliasMap.constEnd() )
1323 layerName = layerAliasIt.value();
1326 layerElement.setAttribute( QStringLiteral(
"name" ), layerName );
1327 getFeatureInfoElement.appendChild( layerElement );
1330 layerElement.setAttribute( QStringLiteral(
"id" ), layer->id() );
1336 QgsVectorLayer *vectorLayer = qobject_cast<QgsVectorLayer *>( layer );
1339 ( void )featureInfoFromVectorLayer( vectorLayer, infoPoint.get(), featureCount, result, layerElement, mapSettings, renderContext, version, featuresRect.get(), filterGeom.get() );
1345 QgsRasterLayer *rasterLayer = qobject_cast<QgsRasterLayer *>( layer );
1354 QgsPointXY layerInfoPoint = mapSettings.mapToLayerCoordinates( layer, *( infoPoint.get() ) );
1359 if ( infoFormat == QgsWmsParameters::Format::GML )
1361 layerElement = result.createElement( QStringLiteral(
"gml:featureMember" ) );
1362 getFeatureInfoElement.appendChild( layerElement );
1365 ( void )featureInfoFromRasterLayer( rasterLayer, mapSettings, &layerInfoPoint, result, layerElement, version );
1373 param.mValue = queryLayer;
1377 else if ( ( validLayer && !queryableLayer ) || ( !validLayer && mContext.
isValidGroup( queryLayer ) ) )
1380 param.mValue = queryLayer;
1382 bool hasGroupAndQueryable {
false };
1387 for (
const QString &ql : constNicks )
1391 const QList<QgsMapLayer *> constLayers { mContext.
layerGroups()[ql] };
1394 if ( ( ! ml->shortName().isEmpty() && ml->shortName() == queryLayer ) || ( ml->name() == queryLayer ) )
1400 hasGroupAndQueryable =
true;
1409 if ( ! hasGroupAndQueryable )
1419 if ( infoFormat == QgsWmsParameters::Format::GML )
1421 QDomElement bBoxElem = result.createElement( QStringLiteral(
"gml:boundedBy" ) );
1422 QDomElement boxElem;
1424 if ( gmlVersion < 3 )
1436 boxElem.setAttribute( QStringLiteral(
"srsName" ),
crs.
authid() );
1438 bBoxElem.appendChild( boxElem );
1439 getFeatureInfoElement.insertBefore( bBoxElem, QDomNode() );
1443 QDomElement bBoxElem = result.createElement( QStringLiteral(
"BoundingBox" ) );
1444 bBoxElem.setAttribute( QStringLiteral(
"CRS" ), mapSettings.destinationCrs().authid() );
1445 bBoxElem.setAttribute( QStringLiteral(
"minx" ),
qgsDoubleToString( featuresRect->xMinimum(), 8 ) );
1446 bBoxElem.setAttribute( QStringLiteral(
"maxx" ),
qgsDoubleToString( featuresRect->xMaximum(), 8 ) );
1447 bBoxElem.setAttribute( QStringLiteral(
"miny" ),
qgsDoubleToString( featuresRect->yMinimum(), 8 ) );
1448 bBoxElem.setAttribute( QStringLiteral(
"maxy" ),
qgsDoubleToString( featuresRect->yMaximum(), 8 ) );
1449 getFeatureInfoElement.insertBefore( bBoxElem, QDomNode() );
1453 if ( sia2045 && infoFormat == QgsWmsParameters::Format::XML )
1455 convertFeatureInfoToSia2045( result );
1461 bool QgsRenderer::featureInfoFromVectorLayer(
QgsVectorLayer *layer,
1464 QDomDocument &infoDocument,
1465 QDomElement &layerElement,
1468 const QString &version,
1480 std::unique_ptr<QgsGeometry> layerFilterGeom;
1483 layerFilterGeom.reset(
new QgsGeometry( *filterGeom ) );
1497 searchRect = featureInfoSearchRect( layer, mapSettings, renderContext, *infoPoint );
1499 else if ( layerFilterGeom )
1501 searchRect = layerFilterGeom->boundingBox();
1503 else if ( !mWmsParameters.
bbox().isEmpty() )
1505 searchRect = layerRect;
1512 int featureCounter = 0;
1531 if ( layerFilterGeom )
1533 fReq.
setFilterExpression( QString(
"intersects( $geometry, geom_from_wkt('%1') )" ).arg( layerFilterGeom->asWkt() ) );
1538 #ifdef HAVE_SERVER_PYTHON_PLUGINS
1539 mContext.accessControl()->filterFeatures( layer, fReq );
1541 QStringList attributes;
1546 attributes = mContext.accessControl()->layerAttributes( layer, attributes );
1551 std::unique_ptr< QgsFeatureRenderer > r2( layer->
renderer() ? layer->
renderer()->
clone() :
nullptr );
1554 r2->startRender( renderContext, layer->
fields() );
1557 bool featureBBoxInitialized =
false;
1566 if ( featureCounter > nFeatures )
1581 bool render = r2->willRenderFeature( feature, renderContext );
1594 if ( !featureBBoxInitialized && featureBBox->
isEmpty() )
1597 featureBBoxInitialized =
true;
1612 if ( mWmsParameters.
infoFormat() == QgsWmsParameters::Format::GML )
1617 QDomElement elem = createFeatureGML(
1619 #ifdef HAVE_SERVER_PYTHON_PLUGINS
1623 QDomElement featureMemberElem = infoDocument.createElement( QStringLiteral(
"gml:featureMember" ) );
1624 featureMemberElem.appendChild( elem );
1625 layerElement.appendChild( featureMemberElem );
1630 QDomElement featureElement = infoDocument.createElement( QStringLiteral(
"Feature" ) );
1632 layerElement.appendChild( featureElement );
1638 writeAttributesTabLayout( editConfig, layer, fields, featureAttributes, infoDocument, featureElement, renderContext
1639 #ifdef HAVE_SERVER_PYTHON_PLUGINS
1646 for (
int i = 0; i < featureAttributes.count(); ++i )
1648 writeVectorLayerAttribute( i, layer, fields, featureAttributes, infoDocument, featureElement, renderContext
1649 #ifdef HAVE_SERVER_PYTHON_PLUGINS
1658 if ( !mapTip.isEmpty() && mWmsParameters.
withMapTip() )
1660 QDomElement maptipElem = infoDocument.createElement( QStringLiteral(
"Attribute" ) );
1661 maptipElem.setAttribute( QStringLiteral(
"name" ), QStringLiteral(
"maptip" ) );
1663 featureElement.appendChild( maptipElem );
1670 QDomElement bBoxElem = infoDocument.createElement( QStringLiteral(
"BoundingBox" ) );
1671 bBoxElem.setAttribute( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS",
outputCrs.
authid() );
1676 featureElement.appendChild( bBoxElem );
1692 if ( segmentizeWktGeometry )
1700 geom.
set( segmentizedGeom );
1704 QDomElement geometryElement = infoDocument.createElement( QStringLiteral(
"Attribute" ) );
1705 geometryElement.setAttribute( QStringLiteral(
"name" ), QStringLiteral(
"geometry" ) );
1706 geometryElement.setAttribute( QStringLiteral(
"value" ), geom.
asWkt( mContext.
precision() ) );
1707 geometryElement.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"derived" ) );
1708 featureElement.appendChild( geometryElement );
1715 r2->stopRender( renderContext );
1721 void QgsRenderer::writeAttributesTabGroup(
const QgsAttributeEditorElement *group,
QgsVectorLayer *layer,
const QgsFields &fields,
QgsAttributes &featureAttributes, QDomDocument &doc, QDomElement &parentElem,
QgsRenderContext &renderContext, QStringList *attributes )
const
1723 const QgsAttributeEditorContainer *container =
dynamic_cast<const QgsAttributeEditorContainer *
>( group );
1726 QString groupName = container->name();
1727 QDomElement nameElem;
1729 if ( !groupName.isEmpty() )
1731 nameElem = doc.createElement( groupName );
1732 parentElem.appendChild( nameElem );
1735 QList<QgsAttributeEditorElement *> children = container->children();
1736 foreach (
const QgsAttributeEditorElement *child, children )
1738 if ( child->type() == QgsAttributeEditorElement::AeTypeContainer )
1740 writeAttributesTabGroup( child, layer, fields, featureAttributes, doc, nameElem.isNull() ? parentElem : nameElem, renderContext );
1742 else if ( child->type() == QgsAttributeEditorElement::AeTypeField )
1744 const QgsAttributeEditorField *editorField =
dynamic_cast<const QgsAttributeEditorField *
>( child );
1747 writeVectorLayerAttribute( editorField->idx(), layer, fields, featureAttributes, doc, nameElem.isNull() ? parentElem : nameElem, renderContext, attributes );
1754 void QgsRenderer::writeAttributesTabLayout( QgsEditFormConfig &config,
QgsVectorLayer *layer,
const QgsFields &fields,
QgsAttributes &featureAttributes, QDomDocument &doc, QDomElement &featureElem,
QgsRenderContext &renderContext, QStringList *attributes )
const
1756 QgsAttributeEditorContainer *editorContainer = config.invisibleRootContainer();
1757 if ( !editorContainer )
1762 writeAttributesTabGroup( editorContainer, layer, fields, featureAttributes, doc, featureElem, renderContext, attributes );
1765 void QgsRenderer::writeVectorLayerAttribute(
int attributeIndex,
QgsVectorLayer *layer,
const QgsFields &fields,
QgsAttributes &featureAttributes, QDomDocument &doc, QDomElement &featureElem,
QgsRenderContext &renderContext, QStringList *attributes )
const
1767 #ifndef HAVE_SERVER_PYTHON_PLUGINS
1768 Q_UNUSED( attributes );
1781 #ifdef HAVE_SERVER_PYTHON_PLUGINS
1783 if ( attributes && !attributes->contains( fields.
at( attributeIndex ).
name() ) )
1790 QDomElement attributeElement = doc.createElement( QStringLiteral(
"Attribute" ) );
1791 attributeElement.setAttribute( QStringLiteral(
"name" ), attributeName );
1793 attributeElement.setAttribute( QStringLiteral(
"value" ),
1795 replaceValueMapAndRelation(
1796 layer, attributeIndex,
1797 featureAttributes[attributeIndex] ),
1800 featureElem.appendChild( attributeElement );
1803 bool QgsRenderer::featureInfoFromRasterLayer(
QgsRasterLayer *layer,
1806 QDomDocument &infoDocument,
1807 QDomElement &layerElement,
1808 const QString &version )
const
1827 ? QgsRaster::IdentifyFormat::IdentifyFormatFeature
1828 : QgsRaster::IdentifyFormat::IdentifyFormatValue );
1840 .arg( layer->
name() ) );
1849 if ( !identifyResult.
isValid() )
1852 QMap<int, QVariant> attributes = identifyResult.
results();
1854 if ( mWmsParameters.
infoFormat() == QgsWmsParameters::Format::GML )
1866 for (
auto it = attributes.constBegin(); it != attributes.constEnd(); ++it )
1869 feature.
setAttribute( index++, QString::number( it.value().toDouble() ) );
1872 QDomElement elem = createFeatureGML(
1873 &feature,
nullptr, infoDocument, layerCrs, mapSettings,
typeName,
false, gmlVersion,
nullptr );
1874 layerElement.appendChild( elem );
1878 const auto values = identifyResult.
results();
1879 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
1881 QVariant value = it.value();
1882 if ( value.type() == QVariant::Bool && !value.toBool() )
1888 if ( value.type() == QVariant::String )
1899 for (
const QgsFeature &feature : storeFeatures )
1901 QDomElement elem = createFeatureGML(
1902 &feature,
nullptr, infoDocument, layerCrs, mapSettings,
typeName,
false, gmlVersion,
nullptr );
1903 layerElement.appendChild( elem );
1913 for (
auto it = attributes.constBegin(); it != attributes.constEnd(); ++it )
1915 QDomElement attributeElement = infoDocument.createElement( QStringLiteral(
"Attribute" ) );
1916 attributeElement.setAttribute( QStringLiteral(
"name" ), layer->
bandName( it.key() ) );
1919 if ( ! it.value().isNull() )
1921 value = QString::number( it.value().toDouble() );
1924 attributeElement.setAttribute( QStringLiteral(
"value" ), value );
1925 layerElement.appendChild( attributeElement );
1930 const auto values = identifyResult.
results();
1931 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
1933 QVariant value = it.value();
1934 if ( value.type() == QVariant::Bool && !value.toBool() )
1940 if ( value.type() == QVariant::String )
1950 for (
const QgsFeature &feature : storeFeatures )
1952 for (
const auto &fld : feature.
fields() )
1954 const auto val { feature.
attribute( fld.name() )};
1955 if ( val.isValid() )
1957 QDomElement attributeElement = infoDocument.createElement( QStringLiteral(
"Attribute" ) );
1958 attributeElement.setAttribute( QStringLiteral(
"name" ), fld.name() );
1959 attributeElement.setAttribute( QStringLiteral(
"value" ), val.toString() );
1960 layerElement.appendChild( attributeElement );
1971 bool QgsRenderer::testFilterStringSafety(
const QString &filter )
const
1974 if ( filter.contains( QLatin1String(
";" ) ) )
1979 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
1980 QStringList tokens = filter.split(
' ', QString::SkipEmptyParts );
1982 QStringList tokens = filter.split(
' ', Qt::SkipEmptyParts );
1984 groupStringList( tokens, QStringLiteral(
"'" ) );
1985 groupStringList( tokens, QStringLiteral(
"\"" ) );
1987 for (
auto tokenIt = tokens.constBegin() ; tokenIt != tokens.constEnd(); ++tokenIt )
1990 if ( tokenIt->compare( QLatin1String(
"," ) ) == 0
1991 || tokenIt->compare( QLatin1String(
"(" ) ) == 0
1992 || tokenIt->compare( QLatin1String(
")" ) ) == 0
1993 || tokenIt->compare( QLatin1String(
"=" ) ) == 0
1994 || tokenIt->compare( QLatin1String(
"!=" ) ) == 0
1995 || tokenIt->compare( QLatin1String(
"<" ) ) == 0
1996 || tokenIt->compare( QLatin1String(
"<=" ) ) == 0
1997 || tokenIt->compare( QLatin1String(
">" ) ) == 0
1998 || tokenIt->compare( QLatin1String(
">=" ) ) == 0
1999 || tokenIt->compare( QLatin1String(
"%" ) ) == 0
2000 || tokenIt->compare( QLatin1String(
"IS" ), Qt::CaseInsensitive ) == 0
2001 || tokenIt->compare( QLatin1String(
"NOT" ), Qt::CaseInsensitive ) == 0
2002 || tokenIt->compare( QLatin1String(
"NULL" ), Qt::CaseInsensitive ) == 0
2003 || tokenIt->compare( QLatin1String(
"AND" ), Qt::CaseInsensitive ) == 0
2004 || tokenIt->compare( QLatin1String(
"OR" ), Qt::CaseInsensitive ) == 0
2005 || tokenIt->compare( QLatin1String(
"IN" ), Qt::CaseInsensitive ) == 0
2006 || tokenIt->compare( QLatin1String(
"LIKE" ), Qt::CaseInsensitive ) == 0
2007 || tokenIt->compare( QLatin1String(
"ILIKE" ), Qt::CaseInsensitive ) == 0
2008 || tokenIt->compare( QLatin1String(
"DMETAPHONE" ), Qt::CaseInsensitive ) == 0
2009 || tokenIt->compare( QLatin1String(
"SOUNDEX" ), Qt::CaseInsensitive ) == 0 )
2016 tokenIt->toDouble( &isNumeric );
2025 if ( *tokenIt == QLatin1String(
"''" ) )
2031 if ( tokenIt->size() > 2
2032 && ( *tokenIt )[0] == QChar(
'\'' )
2033 && ( *tokenIt )[tokenIt->size() - 1] == QChar(
'\'' )
2034 && ( *tokenIt )[1] != QChar(
'\'' )
2035 && ( *tokenIt )[tokenIt->size() - 2] != QChar(
'\'' ) )
2041 if ( tokenIt->size() > 2
2042 && ( *tokenIt )[0] == QChar(
'"' )
2043 && ( *tokenIt )[tokenIt->size() - 1] == QChar(
'"' )
2044 && ( *tokenIt )[1] != QChar(
'"' )
2045 && ( *tokenIt )[tokenIt->size() - 2] != QChar(
'"' ) )
2056 void QgsRenderer::groupStringList( QStringList &list,
const QString &groupString )
2059 bool groupActive =
false;
2060 int startGroup = -1;
2061 QString concatString;
2063 for (
int i = 0; i < list.size(); ++i )
2065 QString &str = list[i];
2066 if ( str.startsWith( groupString ) )
2070 concatString.clear();
2075 if ( i != startGroup )
2077 concatString.append(
" " );
2079 concatString.append( str );
2082 if ( str.endsWith( groupString ) )
2085 groupActive =
false;
2087 if ( startGroup != -1 )
2089 list[startGroup] = concatString;
2090 for (
int j = startGroup + 1; j <= endGroup; ++j )
2092 list.removeAt( startGroup + 1 );
2097 concatString.clear();
2103 void QgsRenderer::convertFeatureInfoToSia2045( QDomDocument &doc )
const
2105 QDomDocument SIAInfoDoc;
2106 QDomElement infoDocElement = doc.documentElement();
2107 QDomElement SIAInfoDocElement = SIAInfoDoc.importNode( infoDocElement,
false ).toElement();
2108 SIAInfoDoc.appendChild( SIAInfoDocElement );
2110 QString currentAttributeName;
2111 QString currentAttributeValue;
2112 QDomElement currentAttributeElem;
2113 QString currentLayerName;
2114 QDomElement currentLayerElem;
2115 QDomNodeList layerNodeList = infoDocElement.elementsByTagName( QStringLiteral(
"Layer" ) );
2116 for (
int i = 0; i < layerNodeList.size(); ++i )
2118 currentLayerElem = layerNodeList.at( i ).toElement();
2119 currentLayerName = currentLayerElem.attribute( QStringLiteral(
"name" ) );
2121 QDomElement currentFeatureElem;
2123 QDomNodeList featureList = currentLayerElem.elementsByTagName( QStringLiteral(
"Feature" ) );
2124 if ( featureList.isEmpty() )
2127 QDomNodeList attributeList = currentLayerElem.elementsByTagName( QStringLiteral(
"Attribute" ) );
2128 QDomElement rasterLayerElem;
2129 if ( !attributeList.isEmpty() )
2131 rasterLayerElem = SIAInfoDoc.createElement( currentLayerName );
2133 for (
int j = 0; j < attributeList.size(); ++j )
2135 currentAttributeElem = attributeList.at( j ).toElement();
2136 currentAttributeName = currentAttributeElem.attribute( QStringLiteral(
"name" ) );
2137 currentAttributeValue = currentAttributeElem.attribute( QStringLiteral(
"value" ) );
2138 QDomElement outAttributeElem = SIAInfoDoc.createElement( currentAttributeName );
2139 QDomText outAttributeText = SIAInfoDoc.createTextNode( currentAttributeValue );
2140 outAttributeElem.appendChild( outAttributeText );
2141 rasterLayerElem.appendChild( outAttributeElem );
2143 if ( !attributeList.isEmpty() )
2145 SIAInfoDocElement.appendChild( rasterLayerElem );
2151 QSet<QString> layerPropertyAttributes;
2152 QString currentLayerId = currentLayerElem.attribute( QStringLiteral(
"id" ) );
2153 if ( !currentLayerId.isEmpty() )
2158 QString WMSPropertyAttributesString = currentLayer->
customProperty( QStringLiteral(
"WMSPropertyAttributes" ) ).toString();
2159 if ( !WMSPropertyAttributesString.isEmpty() )
2161 QStringList propertyList = WMSPropertyAttributesString.split( QStringLiteral(
"//" ) );
2162 for (
auto propertyIt = propertyList.constBegin() ; propertyIt != propertyList.constEnd(); ++propertyIt )
2164 layerPropertyAttributes.insert( *propertyIt );
2170 QDomElement propertyRefChild;
2171 for (
int j = 0; j < featureList.size(); ++j )
2173 QDomElement SIAFeatureElem = SIAInfoDoc.createElement( currentLayerName );
2174 currentFeatureElem = featureList.at( j ).toElement();
2175 QDomNodeList attributeList = currentFeatureElem.elementsByTagName( QStringLiteral(
"Attribute" ) );
2177 for (
int k = 0; k < attributeList.size(); ++k )
2179 currentAttributeElem = attributeList.at( k ).toElement();
2180 currentAttributeName = currentAttributeElem.attribute( QStringLiteral(
"name" ) );
2181 currentAttributeValue = currentAttributeElem.attribute( QStringLiteral(
"value" ) );
2182 if ( layerPropertyAttributes.contains( currentAttributeName ) )
2184 QDomElement propertyElem = SIAInfoDoc.createElement( QStringLiteral(
"property" ) );
2185 QDomElement identifierElem = SIAInfoDoc.createElement( QStringLiteral(
"identifier" ) );
2186 QDomText identifierText = SIAInfoDoc.createTextNode( currentAttributeName );
2187 identifierElem.appendChild( identifierText );
2188 QDomElement valueElem = SIAInfoDoc.createElement( QStringLiteral(
"value" ) );
2189 QDomText valueText = SIAInfoDoc.createTextNode( currentAttributeValue );
2190 valueElem.appendChild( valueText );
2191 propertyElem.appendChild( identifierElem );
2192 propertyElem.appendChild( valueElem );
2193 if ( propertyRefChild.isNull() )
2195 SIAFeatureElem.insertBefore( propertyElem, QDomNode() );
2196 propertyRefChild = propertyElem;
2200 SIAFeatureElem.insertAfter( propertyElem, propertyRefChild );
2205 QDomElement SIAAttributeElem = SIAInfoDoc.createElement( currentAttributeName );
2206 QDomText SIAAttributeText = SIAInfoDoc.createTextNode( currentAttributeValue );
2207 SIAAttributeElem.appendChild( SIAAttributeText );
2208 SIAFeatureElem.appendChild( SIAAttributeElem );
2211 SIAInfoDocElement.appendChild( SIAFeatureElem );
2218 QByteArray QgsRenderer::convertFeatureInfoToHtml(
const QDomDocument &doc )
const
2220 QString featureInfoString;
2223 featureInfoString.append(
"<HEAD>\n" );
2224 featureInfoString.append(
"<TITLE> GetFeatureInfo results </TITLE>\n" );
2225 featureInfoString.append(
"<META http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/>\n" );
2226 featureInfoString.append(
"</HEAD>\n" );
2229 featureInfoString.append(
"<BODY>\n" );
2231 QDomNodeList layerList = doc.elementsByTagName( QStringLiteral(
"Layer" ) );
2234 for (
int i = 0; i < layerList.size(); ++i )
2236 QDomElement layerElem = layerList.at( i ).toElement();
2238 featureInfoString.append(
"<TABLE border=1 width=100%>\n" );
2239 featureInfoString.append(
"<TR><TH width=25%>Layer</TH><TD>" + layerElem.attribute( QStringLiteral(
"name" ) ) +
"</TD></TR>\n" );
2240 featureInfoString.append(
"</BR>" );
2243 QDomNodeList featureNodeList = layerElem.elementsByTagName( QStringLiteral(
"Feature" ) );
2244 QDomElement currentFeatureElement;
2246 if ( !featureNodeList.isEmpty() )
2248 for (
int j = 0; j < featureNodeList.size(); ++j )
2250 QDomElement featureElement = featureNodeList.at( j ).toElement();
2251 featureInfoString.append(
"<TABLE border=1 width=100%>\n" );
2252 featureInfoString.append(
"<TR><TH>Feature</TH><TD>" + featureElement.attribute( QStringLiteral(
"id" ) ) +
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(
"<TR><TH>" + attributeElement.attribute( QStringLiteral(
"name" ) ) +
2261 "</TH><TD>" + attributeElement.attribute( QStringLiteral(
"value" ) ) +
"</TD></TR>\n" );
2264 featureInfoString.append(
"</TABLE>\n</BR>\n" );
2269 QDomNodeList attributeNodeList = layerElem.elementsByTagName( QStringLiteral(
"Attribute" ) );
2270 for (
int j = 0; j < attributeNodeList.size(); ++j )
2272 QDomElement attributeElement = attributeNodeList.at( j ).toElement();
2273 QString value = attributeElement.attribute( QStringLiteral(
"value" ) );
2274 if ( value.isEmpty() )
2276 value = QStringLiteral(
"no data" );
2278 featureInfoString.append(
"<TR><TH>" + attributeElement.attribute( QStringLiteral(
"name" ) ) +
2279 "</TH><TD>" + value +
"</TD></TR>\n" );
2283 featureInfoString.append(
"</TABLE>\n<BR></BR>\n" );
2287 featureInfoString.append(
"</BODY>\n" );
2289 return featureInfoString.toUtf8();
2292 QByteArray QgsRenderer::convertFeatureInfoToText(
const QDomDocument &doc )
const
2294 QString featureInfoString;
2297 featureInfoString.append(
"GetFeatureInfo results\n" );
2298 featureInfoString.append(
"\n" );
2300 QDomNodeList layerList = doc.elementsByTagName( QStringLiteral(
"Layer" ) );
2303 for (
int i = 0; i < layerList.size(); ++i )
2305 QDomElement layerElem = layerList.at( i ).toElement();
2307 featureInfoString.append(
"Layer '" + layerElem.attribute( QStringLiteral(
"name" ) ) +
"'\n" );
2310 QDomNodeList featureNodeList = layerElem.elementsByTagName( QStringLiteral(
"Feature" ) );
2311 QDomElement currentFeatureElement;
2313 if ( !featureNodeList.isEmpty() )
2315 for (
int j = 0; j < featureNodeList.size(); ++j )
2317 QDomElement featureElement = featureNodeList.at( j ).toElement();
2318 featureInfoString.append(
"Feature " + featureElement.attribute( QStringLiteral(
"id" ) ) +
"\n" );
2321 QDomNodeList attributeNodeList = featureElement.elementsByTagName( QStringLiteral(
"Attribute" ) );
2322 for (
int k = 0; k < attributeNodeList.size(); ++k )
2324 QDomElement attributeElement = attributeNodeList.at( k ).toElement();
2325 featureInfoString.append( attributeElement.attribute( QStringLiteral(
"name" ) ) +
" = '" +
2326 attributeElement.attribute( QStringLiteral(
"value" ) ) +
"'\n" );
2332 QDomNodeList attributeNodeList = layerElem.elementsByTagName( QStringLiteral(
"Attribute" ) );
2333 for (
int j = 0; j < attributeNodeList.size(); ++j )
2335 QDomElement attributeElement = attributeNodeList.at( j ).toElement();
2336 QString value = attributeElement.attribute( QStringLiteral(
"value" ) );
2337 if ( value.isEmpty() )
2339 value = QStringLiteral(
"no data" );
2341 featureInfoString.append( attributeElement.attribute( QStringLiteral(
"name" ) ) +
" = '" +
2346 featureInfoString.append(
"\n" );
2349 return featureInfoString.toUtf8();
2352 QByteArray QgsRenderer::convertFeatureInfoToJson(
const QList<QgsMapLayer *> &layers,
const QDomDocument &doc )
const
2356 {
"type",
"FeatureCollection" },
2357 {
"features", json::array() },
2361 const QDomNodeList layerList = doc.elementsByTagName( QStringLiteral(
"Layer" ) );
2362 for (
int i = 0; i < layerList.size(); ++i )
2364 const QDomElement layerElem = layerList.at( i ).toElement();
2365 const QString layerName = layerElem.attribute( QStringLiteral(
"name" ) );
2370 if ( mContext.
layerNickname( *l ).compare( layerName ) == 0 )
2386 const QDomNodeList featuresNode = layerElem.elementsByTagName( QStringLiteral(
"Feature" ) );
2387 if ( featuresNode.isEmpty() )
2390 QMap<QgsFeatureId, QString> fidMap;
2392 for (
int j = 0; j < featuresNode.size(); ++j )
2394 const QDomElement featureNode = featuresNode.at( j ).toElement();
2395 const QString fid = featureNode.attribute( QStringLiteral(
"id" ) );
2398 if ( expression.isEmpty() )
2400 feature = vl->
getFeature( fid.toLongLong() );
2405 request.setFlags( QgsFeatureRequest::Flag::NoGeometry );
2409 fidMap.insert( feature.
id(), fid );
2414 const QDomNodeList attrs = featureNode.elementsByTagName(
"Attribute" );
2415 for (
int k = 0; k < attrs.count(); k++ )
2417 const QDomElement elm = attrs.at( k ).toElement();
2418 if ( elm.attribute( QStringLiteral(
"name" ) ).compare(
"geometry" ) == 0 )
2420 wkt = elm.attribute(
"value" );
2425 if ( ! wkt.isEmpty() )
2431 features << feature;
2434 if ( !attributes.isEmpty() )
2437 const QDomNodeList attributesNode = featureNode.elementsByTagName( QStringLiteral(
"Attribute" ) );
2438 for (
int k = 0; k < attributesNode.size(); ++k )
2440 const QDomElement attributeElement = attributesNode.at( k ).toElement();
2441 const QString fieldName = attributeElement.
attribute( QStringLiteral(
"name" ) );
2443 attributes << feature.fieldNameIndex( fieldName );
2449 exporter.setAttributeDisplayName(
true );
2450 exporter.setAttributes( attributes );
2451 exporter.setIncludeGeometry( withGeometry );
2452 exporter.setTransformGeometries(
false );
2454 for (
const auto &feature : qgis::as_const( features ) )
2456 const QString
id = QStringLiteral(
"%1.%2" ).arg( layerName ).arg( fidMap.value( feature.id() ) );
2457 json[
"features"].push_back( exporter.exportFeatureToJsonObject( feature, QVariantMap(),
id ) );
2462 auto properties = json::object();
2463 const QDomNodeList attributesNode = layerElem.elementsByTagName( QStringLiteral(
"Attribute" ) );
2464 for (
int j = 0; j < attributesNode.size(); ++j )
2466 const QDomElement attrElmt = attributesNode.at( j ).toElement();
2467 const QString name = attrElmt.attribute( QStringLiteral(
"name" ) );
2469 QString value = attrElmt.attribute( QStringLiteral(
"value" ) );
2470 if ( value.isEmpty() )
2472 value = QStringLiteral(
"null" );
2475 properties[name.toStdString()] = value.toStdString();
2478 json[
"features"].push_back(
2480 {
"type",
"Feature" },
2481 {
"id", layerName.toStdString() },
2482 {
"properties", properties }
2488 return QByteArray::fromStdString( json.dump( 2 ) );
2490 return QByteArray::fromStdString( json.dump() );
2494 QDomElement QgsRenderer::createFeatureGML(
2503 QStringList *attributes )
const
2506 QDomElement typeNameElement = doc.createElement(
"qgs:" +
typeName );
2513 typeNameElement.setAttribute( QStringLiteral(
"fid" ), QStringLiteral(
"%1.%2" ).arg(
typeName, fid ) );
2516 if ( layer && layer->
crs() !=
crs )
2549 QDomElement bbElem = doc.createElement( QStringLiteral(
"gml:boundedBy" ) );
2550 QDomElement boxElem;
2562 boxElem.setAttribute( QStringLiteral(
"srsName" ),
crs.
authid() );
2564 bbElem.appendChild( boxElem );
2565 typeNameElement.appendChild( bbElem );
2577 QDomElement geomElem = doc.createElement( QStringLiteral(
"qgs:geometry" ) );
2578 QDomElement gmlElem;
2588 if ( !gmlElem.isNull() )
2592 gmlElem.setAttribute( QStringLiteral(
"srsName" ),
crs.
authid() );
2594 geomElem.appendChild( gmlElem );
2595 typeNameElement.appendChild( geomElem );
2602 for (
int i = 0; i < fields.
count(); ++i )
2604 QString attributeName = fields.
at( i ).
name();
2611 if ( attributes && !attributes->contains( attributeName ) )
2616 QDomElement fieldElem = doc.createElement(
"qgs:" + attributeName.replace(
' ',
'_' ) );
2617 QString fieldTextString = featureAttributes.at( i ).toString();
2622 QDomText fieldText = doc.createTextNode( fieldTextString );
2623 fieldElem.appendChild( fieldText );
2624 typeNameElement.appendChild( fieldElem );
2632 if ( !mapTip.isEmpty() && mWmsParameters.
withMapTip() )
2635 QDomElement fieldElem = doc.createElement( QStringLiteral(
"qgs:maptip" ) );
2636 QDomText maptipText = doc.createTextNode( fieldTextString );
2637 fieldElem.appendChild( maptipText );
2638 typeNameElement.appendChild( fieldElem );
2642 return typeNameElement;
2645 QString QgsRenderer::replaceValueMapAndRelation(
QgsVectorLayer *vl,
int idx,
const QVariant &attributeVal )
2649 QString value( fieldFormatter->
representValue( vl, idx, setup.
config(), QVariant(), attributeVal ) );
2651 if ( setup.
config().value( QStringLiteral(
"AllowMulti" ) ).toBool() && value.startsWith( QLatin1Char(
'{' ) ) && value.endsWith( QLatin1Char(
'}' ) ) )
2653 value = value.mid( 1, value.size() - 2 );
2665 double mapUnitTolerance = 0.0;
2675 mapUnitTolerance = mapSettings.
extent().
width() / 400.0;
2687 mapUnitTolerance = mapSettings.
extent().
width() / 200.0;
2699 mapUnitTolerance = mapSettings.
extent().
width() / 100.0;
2703 QgsRectangle mapRectangle( infoPoint.
x() - mapUnitTolerance, infoPoint.
y() - mapUnitTolerance,
2704 infoPoint.
x() + mapUnitTolerance, infoPoint.
y() + mapUnitTolerance );
2708 QList<QgsMapLayer *> QgsRenderer::highlightLayers( QList<QgsWmsParametersHighlightLayer> params )
2710 QList<QgsMapLayer *> highlightLayers;
2713 QString
crs = mWmsParameters.
crs();
2714 for (
const QgsWmsParametersHighlightLayer ¶m : params )
2717 QDomDocument sldDoc;
2718 if ( !sldDoc.setContent( param.mSld,
true ) )
2725 std::unique_ptr<QgsFeatureRenderer> renderer;
2726 QDomElement el = sldDoc.documentElement();
2737 if ( ! param.mLabel.isEmpty() )
2739 url +=
"&field=label:string";
2744 std::unique_ptr<QgsVectorLayer> layer = qgis::make_unique<QgsVectorLayer>( url, param.mName, QLatin1String(
"memory" ), options );
2745 if ( !layer->isValid() )
2752 if ( ! param.mLabel.isEmpty() )
2754 fet.setAttribute( 0, param.mLabel );
2763 switch ( param.mGeom.type() )
2768 palSettings.
dist = 2;
2779 QVariant x( pt.
x() );
2783 QVariant y( pt.
y() );
2787 QVariant hali(
"Center" );
2791 QVariant vali(
"Half" );
2798 palSettings.
dist = 2;
2807 if ( param.mColor.isValid() )
2809 textFormat.
setColor( param.mColor );
2812 if ( param.mSize > 0 )
2814 textFormat.
setSize( param.mSize );
2822 if ( ! param.mFont.isEmpty() )
2824 textFormat.
setFont( param.mFont );
2827 if ( param.mBufferColor.isValid() )
2829 bufferSettings.
setColor( param.mBufferColor );
2832 if ( param.mBufferSize > 0 )
2835 bufferSettings.
setSize(
static_cast<double>( param.mBufferSize ) );
2842 layer->setLabeling( simpleLabeling );
2843 layer->setLabelsEnabled(
true );
2845 fet.setGeometry( param.mGeom );
2849 layer->setRenderer( renderer.release() );
2852 if ( layer->isValid() )
2854 highlightLayers.append( layer.release() );
2858 mTemporaryLayers.append( highlightLayers );
2859 return highlightLayers;
2862 void QgsRenderer::removeTemporaryLayers()
2864 qDeleteAll( mTemporaryLayers );
2865 mTemporaryLayers.clear();
2868 QPainter *QgsRenderer::layersRendering(
const QgsMapSettings &mapSettings, QImage &image )
const
2870 QPainter *painter =
nullptr;
2874 #ifdef HAVE_SERVER_PYTHON_PLUGINS
2875 mContext.accessControl()->resolveFilterFeatures( mapSettings.
layers() );
2879 renderJob.render( mapSettings, &image );
2880 painter = renderJob.takePainter();
2882 if ( !renderJob.errors().isEmpty() )
2884 QString layerWMSName;
2885 QString firstErrorLayerId = renderJob.errors().at( 0 ).layerID;
2892 throw QgsException( QStringLiteral(
"Map rendering error in layer '%1'" ).arg( layerWMSName ) );
2898 void QgsRenderer::setLayerOpacity(
QgsMapLayer *layer,
int opacity )
const
2900 if ( opacity >= 0 && opacity <= 255 )
2902 switch ( layer->
type() )
2915 rasterRenderer->
setOpacity( opacity / 255. );
2929 void QgsRenderer::setLayerFilter(
QgsMapLayer *layer,
const QList<QgsWmsParametersFilter> &filters )
2933 QgsVectorLayer *filteredLayer = qobject_cast<QgsVectorLayer *>( layer );
2934 QStringList expList;
2935 for (
const QgsWmsParametersFilter &filter : filters )
2940 QDomDocument filterXml;
2942 if ( !filterXml.setContent( filter.mFilter,
true, &errorMsg ) )
2945 QStringLiteral(
"Filter string rejected. Error message: %1. The XML string was: %2" ).arg( errorMsg, filter.mFilter ) );
2947 QDomElement filterElem = filterXml.firstChildElement();
2952 expList << filterExp->dump();
2958 if ( !testFilterStringSafety( filter.mFilter ) )
2960 throw QgsSecurityException( QStringLiteral(
"The filter string %1"
2961 " has been rejected because of security reasons."
2962 " Note: Text strings have to be enclosed in single or double quotes."
2963 " A space between each word / special character is mandatory."
2964 " Allowed Keywords and special characters are "
2965 " IS,NOT,NULL,AND,OR,IN,=,<,>=,>,>=,!=,',',(,),DMETAPHONE,SOUNDEX."
2966 " Not allowed are semicolons in the filter expression." ).arg(
2970 QString newSubsetString = filter.mFilter;
2973 newSubsetString.prepend(
") AND (" );
2974 newSubsetString.append(
")" );
2975 newSubsetString.prepend( filteredLayer->
subsetString() );
2976 newSubsetString.prepend(
"(" );
2982 expList.append( dimensionFilter( filteredLayer ) );
2986 if ( expList.size() == 1 )
2990 else if ( expList.size() > 1 )
2992 exp = QStringLiteral(
"( %1 )" ).arg( expList.join( QLatin1String(
" ) AND ( " ) ) );
2994 if ( !exp.isEmpty() )
2996 std::unique_ptr<QgsExpression> expression(
new QgsExpression( exp ) );
2999 mFeatureFilter.
setFilter( filteredLayer, *expression );
3005 QStringList QgsRenderer::dimensionFilter(
QgsVectorLayer *layer )
const
3007 QStringList expList;
3010 if ( wmsDims.isEmpty() )
3020 if ( fieldIndex == -1 )
3025 int endFieldIndex = -1;
3026 if ( !dim.endFieldName.isEmpty() )
3028 endFieldIndex = layer->
fields().
indexOf( dim.endFieldName );
3029 if ( endFieldIndex == -1 )
3035 if ( !dimParamValues.contains( dim.name.toUpper() ) )
3045 defValue = dim.referenceValue;
3050 QSet<QVariant> uniqueValues = layer->
uniqueValues( fieldIndex );
3051 if ( endFieldIndex != -1 )
3053 uniqueValues.unite( layer->
uniqueValues( endFieldIndex ) );
3056 QList<QVariant> values = qgis::setToList( uniqueValues );
3057 std::sort( values.begin(), values.end() );
3060 defValue = values.first();
3064 defValue = values.last();
3068 if ( endFieldIndex == -1 )
3074 QStringList expElems;
3079 expList << expElems.join(
' ' );
3087 QString dimParamValue = dimParamValues[dim.name.toUpper()];
3089 QStringList dimExplist;
3091 QStringList dimValues = dimParamValue.split(
',' );
3092 for (
int i = 0; i < dimValues.size(); ++i )
3094 QString dimValue = dimValues[i];
3096 if ( dimValue.size() > 1 )
3098 dimValue = dimValue.trimmed();
3101 if ( dimValue.contains(
'/' ) )
3103 QStringList rangeValues = dimValue.split(
'/' );
3105 if ( rangeValues.size() != 2 )
3110 QVariant rangeMin = QVariant( rangeValues[0] );
3111 QVariant rangeMax = QVariant( rangeValues[1] );
3122 QStringList expElems;
3123 if ( endFieldIndex == -1 )
3143 << QStringLiteral(
")" );
3145 dimExplist << expElems.join(
' ' );
3149 QVariant dimVariant = QVariant( dimValue );
3155 if ( endFieldIndex == -1 )
3164 QStringList expElems;
3169 dimExplist << expElems.join(
' ' );
3174 if ( dimExplist.size() == 1 )
3176 expList << dimExplist;
3178 else if ( dimExplist.size() > 1 )
3180 expList << QStringLiteral(
"( %1 )" ).arg( dimExplist.join( QLatin1String(
" ) OR ( " ) ) );
3187 void QgsRenderer::setLayerSelection(
QgsMapLayer *layer,
const QStringList &fids )
const
3193 for (
const QString &
id : fids )
3203 void QgsRenderer::setLayerAccessControlFilter(
QgsMapLayer *layer )
const
3205 #ifdef HAVE_SERVER_PYTHON_PLUGINS
3223 void QgsRenderer::annotationsRendering( QPainter *painter )
const
3226 const QList< QgsAnnotation * > annotations = annotationManager->
annotations();
3232 if ( !annotation || !annotation->isVisible() )
3235 annotation->render( renderContext );
3239 QImage *QgsRenderer::scaleImage(
const QImage *image )
const
3244 QImage *scaledImage =
nullptr;
3245 const int width = mWmsParameters.
widthAsInt();
3247 if ( width != image->width() || height != image->height() )
3249 scaledImage =
new QImage( image->scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
3255 void QgsRenderer::handlePrintErrors(
const QgsLayout *layout )
const
3261 QList< QgsLayoutItemMap * > mapList;
3264 QList< QgsLayoutItemMap * >::const_iterator mapIt = mapList.constBegin();
3265 for ( ; mapIt != mapList.constEnd(); ++mapIt )
3267 if ( !( *mapIt )->renderingErrors().isEmpty() )
3279 for (
auto layer : layers )
3295 setLayerSld( layer, mContext.
sld( *layer ) );
3299 setLayerStyle( layer, mContext.
style( *layer ) );
3304 setLayerOpacity( layer, param.
mOpacity );
3309 setLayerFilter( layer, param.
mFilter );
3314 setLayerSelection( layer, param.
mSelection );
3319 updateExtent( layer, *settings );
3324 setLayerAccessControlFilter( layer );
3334 void QgsRenderer::setLayerStyle(
QgsMapLayer *layer,
const QString &style )
const
3336 if ( style.isEmpty() )
3345 QStringLiteral(
"Style '%1' does not exist for layer '%2'" ).arg( style, layer->
name() ) );
3349 void QgsRenderer::setLayerSld(
QgsMapLayer *layer,
const QDomElement &sld )
const
3354 QString sldStyleName =
"__sld_style";
3355 while ( styles.contains( sldStyleName ) )
3357 sldStyleName.append(
'@' );
3370 if ( !mWmsParameters.
bbox().isEmpty() )
3374 std::unique_ptr<QImage> tmp( createImage( mContext.
mapSize(
false ) ) );
3375 configureMapSettings( tmp.get(), mapSettings );
Abstract base class for all geometries.
virtual QgsAbstractGeometry * segmentize(double tolerance=M_PI/180., SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a version of the geometry without curves.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
Manages storage of a set of QgsAnnotation annotation objects.
QList< QgsAnnotation * > annotations() const
Returns a list of all annotations contained in the manager.
Abstract base class for annotation items which are drawn over a map.
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters.
Exception thrown in case of malformed request.
This class represents a coordinate reference system (CRS).
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QString authid() const
Returns the authority identifier for the CRS.
Q_GADGET QgsUnitTypes::DistanceUnit mapUnits
bool hasAxisInverted() const
Returns whether axis is inverted (e.g., for WMS 1.3) for the CRS.
Custom exception class for Coordinate Reference System related exceptions.
Defines a QGIS exception class.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Class for parsing and evaluation of expressions (formerly called "search strings").
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required.
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...
static QString createFieldEqualityExpression(const QString &fieldName, const QVariant &value)
Create an expression allowing to evaluate if a field is equal to a value.
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
A filter filter provider grouping several filter providers.
QgsFeatureFilterProviderGroup & addProvider(const QgsFeatureFilterProvider *provider)
Add another filter provider to the group.
void setFilter(const QgsVectorLayer *layer, const QgsExpression &expression)
Set a filter for the given layer.
void filterFeatures(const QgsVectorLayer *layer, QgsFeatureRequest &filterFeatures) const override
Filter the features of the layer.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
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 ...
@ MoreSymbolsPerFeature
May use more than one symbol to render a feature: symbolsForFeature() will return them.
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
@ ExactIntersect
Use exact geometry intersection (slower) instead of bounding boxes.
@ NoGeometry
Geometry is not required. It may still be returned if e.g. required for a filter condition.
QgsCoordinateTransformContext transformContext() const
Returns the transform context, for use when a destinationCrs() has been set and reprojection is requi...
const Flags & flags() const
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
A container for features with the same fields and crs.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
bool setAttribute(int field, const QVariant &attr)
Set an attribute's value by field index.
void initAttributes(int fieldCount)
Initialize this feature with the given number of fields.
void setFields(const QgsFields &fields, bool initAttributes=false)
Assign a field map with the feature to allow attribute access by attribute name.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Encapsulate a field in an attribute table or data source.
bool convertCompatible(QVariant &v, QString *errorMessage=nullptr) const
Converts the provided variant to a compatible format.
ConfigurationFlags configurationFlags
@ HideFromWms
Fields is available if layer is served as WMS from QGIS server.
Container of fields for a vector layer.
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)
int indexFromName(const QString &fieldName) const
Gets the field index from the field name.
int indexOf(const QString &fieldName) const
Gets the field index from the field name.
int count() const
Returns number of items.
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsGeometry pointOnSurface() const
Returns a point guaranteed to lie on the surface of a geometry.
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
QgsWkbTypes::GeometryType type
void set(QgsAbstractGeometry *geometry)
Sets the underlying geometry store.
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.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
QString asWkt(int precision=17) const
Exports the geometry to WKT.
Handles exporting QgsFeature features to GeoJSON features.
void setPlacementFlags(QgsLabeling::LinePlacementFlags flags)
Returns the line placement flags, which dictate how line labels can be placed above or below the line...
QStringList findLayerIds() const
Find layer IDs used in all layer nodes.
QgsLayerTreeLayer * findLayer(QgsMapLayer *layer) const
Find layer node representing the map layer.
void removeChildrenGroupWithoutLayers()
Remove all child group nodes without layers.
Layer tree node points to a map layer.
QgsMapLayer * layer() const
Returns the map layer associated with this node.
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
virtual QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const
Draws symbol on the left side of the item.
The QgsLayerTreeModel class is model implementation for Qt item views framework.
QgsLayerTree * rootGroup() const
Returns pointer to the root node of the layer tree. Always a non nullptr value.
QgsLayerTreeNode * parent()
Gets pointer to the parent. If parent is nullptr, the node is a root node.
Namespace with helper functions for layer tree operations.
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector ...
QgsVectorLayer * coverageLayer() const
Returns the coverage layer used for the atlas features.
bool beginRender() override
Called when rendering begins, before iteration commences.
bool setFilterExpression(const QString &expression, QString &errorString)
Sets the expression used for filtering features in the coverage layer.
QgsLayout * layout() override
Returns the layout associated with the iterator.
bool enabled() const
Returns whether the atlas generation is enabled.
int count() const override
Returns the number of features to iterate over.
void setFilterFeatures(bool filtered)
Sets whether features should be filtered in the coverage layer.
int updateFeatures()
Requeries the current atlas coverage layer and applies filtering and sorting.
Handles rendering and exports of layouts to various formats.
ExportResult exportToSvg(const QString &filePath, const QgsLayoutExporter::SvgExportSettings &settings)
Exports the layout as an SVG to the filePath, using the specified export settings.
ExportResult exportToImage(const QString &filePath, const QgsLayoutExporter::ImageExportSettings &settings)
Exports the layout to the filePath, using the specified export settings.
ExportResult exportToPdf(const QString &filePath, const QgsLayoutExporter::PdfExportSettings &settings)
Exports the layout as a PDF to the filePath, using the specified export settings.
Base class for frame items, which form a layout multiframe item.
A layout multiframe subclass for HTML content.
A layout item subclass for text labels.
A layout item subclass for map legends.
Layout graphical items for displaying a map.
double scale() const
Returns the map scale.
QList< QgsMapLayer * > layers() const
Returns the stored layer set.
QString id() const
Returns the item's ID name.
Manages storage of a set of layouts.
QgsMasterLayoutInterface * layoutByName(const QString &name) const
Returns the layout with a matching name, or nullptr if no matching layouts were found.
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
double length() const
Returns the length of the measurement.
int pageCount() const
Returns the number of pages in the collection.
Stores information relating to the current rendering settings for a layout.
void setFeatureFilterProvider(QgsFeatureFilterProvider *featureFilterProvider)
Sets feature filter provider to featureFilterProvider.
@ FlagDrawSelection
Draw selection.
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
double height() const
Returns the height of the size.
double width() const
Returns the width of the size.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
QgsLayoutPageCollection * pageCollection()
Returns a pointer to the layout's page collection, which stores and manages page items in the layout.
void layoutItems(QList< T * > &itemList) const
Returns a list of layout items of a specific type.
Item model implementation based on layer tree model for layout legend.
The QgsLegendRenderer class handles automatic layout and rendering of legend.
QSizeF minimumSize(QgsRenderContext *renderContext=nullptr)
Runs the layout algorithm and returns the minimum size required for the legend.
QJsonObject exportLegendToJson(const QgsRenderContext &context)
Renders the legend in a json object.
Q_DECL_DEPRECATED void drawLegend(QPainter *painter)
Draws the legend with given painter.
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
Q_DECL_DEPRECATED void setMapScale(double scale)
Sets the legend map scale.
Q_DECL_DEPRECATED void setMapUnitsPerPixel(double mapUnitsPerPixel)
Sets the mmPerMapUnit calculated by mapUnitsPerPixel mostly taken from the map settings.
Q_DECL_DEPRECATED double mmPerMapUnit() const
Q_DECL_DEPRECATED double mapScale() const
Returns the legend map scale.
QStringList styles() const
Returns list of all defined style names.
bool setCurrentStyle(const QString &name)
Set a different style as the current style - will apply it to the layer.
bool addStyleFromLayer(const QString &name)
Add style by cloning the current one.
Base class for all map layer types.
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
virtual QgsRectangle extent() const
Returns the extent of the layer.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
QgsCoordinateReferenceSystem crs
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
Q_INVOKABLE void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
@ Identifiable
If the layer is identifiable using the identify map tool and as a WMS layer.
virtual bool readSld(const QDomNode &node, QString &errorMessage)
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
virtual Q_INVOKABLE QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be nullptr.
The QgsMapSettings class contains configuration for rendering of the map.
QgsPointXY layerToMapCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from layer's CRS to output CRS
void setSelectionColor(const QColor &color)
Sets the color that is used for drawing of selected vector features.
void setLayers(const QList< QgsMapLayer * > &layers)
Sets the list of layers to render in the map.
double scale() const
Returns the calculated map scale.
QgsCoordinateTransform layerTransform(const QgsMapLayer *layer) const
Returns the coordinate transform from layer's CRS to destination CRS.
QgsRectangle layerExtentToOutputExtent(const QgsMapLayer *layer, QgsRectangle extent) const
transform bounding box from layer's CRS to output CRS
QStringList layerIds() const
Returns the list of layer IDs which will be rendered in the map.
@ UseRenderingOptimization
Enable vector simplification and other rendering optimizations.
@ RenderBlocking
Render and load remote sources in the same thread to ensure rendering remote sources (svg and images)...
@ RenderMapTile
Draw map such that there are no problems between adjacent tiles.
void setOutputDpi(double dpi)
Sets the dpi (dots per inch) used for conversion between real world units (e.g.
double mapUnitsPerPixel() const
Returns the distance in geographical coordinates that equals to one pixel in the map.
QSize outputSize() const
Returns the size of the resulting map image, in pixels.
QgsRectangle extent() const
Returns geographical coordinates of the rectangle that should be rendered.
void setExtent(const QgsRectangle &rect, bool magnified=true)
Sets the coordinates of the rectangle which should be rendered.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
QColor selectionColor() const
Returns the color that is used for drawing of selected vector features.
void setExtentBuffer(double buffer)
Sets the buffer in map units to use around the visible extent for rendering symbols whose correspondi...
void setLabelingEngineSettings(const QgsLabelingEngineSettings &settings)
Sets the global configuration of the labeling engine.
QList< QgsMapLayer * > layers() const
Returns the list of layers which will be rendered in the map.
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
void setOutputSize(QSize size)
Sets the size of the resulting map image, in pixels.
QgsPointXY mapToLayerCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from output CRS to layer's CRS
void setBackgroundColor(const QColor &color)
Sets the background color of the map.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
Sets the destination crs (coordinate reference system) for the map render.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
Perform transforms between map coordinates and device coordinates.
double mapUnitsPerPixel() const
Returns current map units per pixel.
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).
static void applyAccessControlLayerFilters(const QgsAccessControl *accessControl, QgsMapLayer *mapLayer, QHash< QgsMapLayer *, QString > &originalLayerFilters)
Apply filter from AccessControl.
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 QDomElement rectangleToGMLEnvelope(QgsRectangle *env, QDomDocument &doc, int precision=17)
Exports the rectangle to GML3 Envelope.
static QgsExpression * expressionFromOgcFilter(const QDomElement &element, QgsVectorLayer *layer=nullptr)
Parse XML with OGC filter into QGIS expression.
static QDomElement rectangleToGMLBox(QgsRectangle *box, QDomDocument &doc, int precision=17)
Exports the rectangle to GML2 Box.
Contains settings for how a map layer will be labeled.
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
bool displayAll
If true, all features will be labelled even when overlaps occur.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label's property collection, used for data defined overrides.
Placement
Placement modes which determine how label candidates are generated for a feature.
@ AroundPoint
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
@ Line
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
int priority
Label priority.
Property
Data definable properties.
@ PositionY
Y-coordinate data defined label position.
@ PositionX
X-coordinate data defined label position.
@ Hali
Horizontal alignment for data defined label position (Left, Center, Right)
@ Vali
Vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
const QgsLabelLineSettings & lineSettings() const
Returns the label line settings, which contain settings related to how the label engine places and fo...
double dist
Distance from feature to the label.
QString fieldName
Name of field (or an expression) to use for label text.
A class to represent a 2D point.
void setX(double x) SIP_HOLDGIL
Sets the x value of the point.
void setY(double y) SIP_HOLDGIL
Sets the y value of the point.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
QgsPrintLayout * clone() const override
Creates a clone of the layout.
A class to describe the version of a project.
static QgsProject * instance()
Returns the QgsProject singleton instance.
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QgsAnnotationManager * annotationManager()
Returns pointer to the project's annotation manager.
QgsCoordinateTransformContext transformContext
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
const QgsLabelingEngineSettings & labelingEngineSettings() const
Returns project's global labeling engine settings.
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
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.
Raster identify results container.
bool isValid() const
Returns true if valid.
QMap< int, QVariant > results() const
Returns the identify results.
@ IdentifyValue
Numerical values.
@ IdentifyFeature
WMS GML -> feature.
virtual int capabilities() const
Returns a bitmask containing the supported capabilities.
Represents a raster layer.
QString bandName(int bandNoInt) const
Returns the name of a band given its number.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
Raster renderer pipe that applies colors to a raster.
void setOpacity(double opacity)
Sets the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1....
A rectangle specified with double values.
bool contains(const QgsRectangle &rect) const
Returns true when rectangle contains other rectangle.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
double height() const SIP_HOLDGIL
Returns the height of the rectangle.
double width() const SIP_HOLDGIL
Returns the width of the rectangle.
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle.
bool isEmpty() const
Returns true if the rectangle is empty.
void invert()
Swap x/y coordinates in the rectangle.
Contains information about the context of a rendering operation.
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
void setCoordinateTransform(const QgsCoordinateTransform &t)
Sets the current coordinate transform for the context.
QgsExpressionContext & expressionContext()
Gets the expression context.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context's map to pixel transform, which transforms between map coordinates and device coordi...
@ Antialiasing
Use antialiasing while drawing.
@ RenderBlocking
Render and load remote sources in the same thread to ensure rendering remote sources (svg and images)...
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
static QgsRenderContext fromQPainter(QPainter *painter)
Creates a default render context given a pixel based QPainter destination.
void setRendererScale(double scale)
Sets the renderer map scale.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
Calculates scale for a given combination of canvas size, map extent, and monitor dpi.
double calculate(const QgsRectangle &mapExtent, double canvasWidth) const
Calculate the scale denominator.
Scoped object for temporary scaling of a QgsRenderContext for millimeter based rendering.
int maxThreads() const
Returns the maximum number of threads to use.
bool parallelRendering() const
Returns parallel rendering setting.
static QString symbolProperties(QgsSymbol *symbol)
Returns a string representing the symbol.
Abstract base class for all rendered symbols.
Container for settings relating to a text buffer.
void setColor(const QColor &color)
Sets the color for the buffer.
void setEnabled(bool enabled)
Sets whether the text buffer will be drawn.
void setSize(double size)
Sets the size of the buffer.
Container for all settings relating to text rendering.
void setColor(const QColor &color)
Sets the color that text will be rendered in.
void setSize(double size)
Sets the size for rendered text.
void setFont(const QFont &font)
Sets the font used for rendering text.
void setBuffer(const QgsTextBufferSettings &bufferSettings)
Sets the text's buffer settings.
This is the base class for vector data providers.
virtual QgsAttributeList pkAttributeIndexes() const
Returns list of indexes of fields that make up the primary key.
const QList< QgsVectorLayerServerProperties::WmsDimensionInfo > wmsDimensions() const
Returns the QGIS Server WMS Dimension list.
Basic implementation of the labeling interface.
Represents a vector layer which manages a vector based data sets.
QString attributeDisplayName(int index) const
Convenience function that returns the attribute alias if defined or the field name else.
Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
QgsVectorLayerServerProperties * serverProperties() const
Returns QGIS Server Properties of the vector layer.
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
void updateFields()
Will regenerate the fields property of this layer by obtaining all fields from the dataProvider,...
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
QgsEditorWidgetSetup editorWidgetSetup(int index) const
The editor widget setup defines which QgsFieldFormatter and editor widget will be used for the field ...
QgsFeature getFeature(QgsFeatureId fid) const
Queries the layer for the feature with the given id.
virtual bool setSubsetString(const QString &subset)
Sets the string (typically sql) used to define a subset of the layer.
QgsAttributeList primaryKeyAttributes() const
Returns the list of attributes which make up the layer's primary keys.
Q_INVOKABLE void selectByIds(const QgsFeatureIds &ids, QgsVectorLayer::SelectBehavior behavior=QgsVectorLayer::SetSelection)
Selects matching features using a list of feature IDs.
QgsEditFormConfig editFormConfig
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const FINAL
Calculates a list of unique values contained within an attribute in the layer.
QgsFeatureRenderer * renderer()
Returns the feature renderer used for rendering the features in the layer in 2D map views.
static QString displayString(Type type) SIP_HOLDGIL
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
static bool isCurvedType(Type type) SIP_HOLDGIL
Returns true if the WKB type is a curved type or can contain curved geometries.
Exception thrown in case of malformed request.
QgsRenderer(const QgsWmsRenderContext &context)
Constructor for QgsRenderer.
QHash< QgsVectorLayer *, SymbolSet > HitTest
QByteArray getPrint()
Returns printed page as binary.
HitTest symbols()
Returns the hit test according to the current context.
std::unique_ptr< QgsDxfExport > getDxf()
Returns the map as DXF data.
QSet< QString > SymbolSet
void configureLayers(QList< QgsMapLayer * > &layers, QgsMapSettings *settings=nullptr)
Configures layers for rendering optionally considering the map settings.
QJsonObject getLegendGraphicsAsJson(QgsLayerTreeModel &model)
Returns the map legend as a JSON object.
QByteArray getFeatureInfo(const QString &version="1.3.0")
Creates an xml document that describes the result of the getFeatureInfo request.
QImage * getLegendGraphics(QgsLayerTreeModel &model)
Returns the map legend as an image (or nullptr in case of error).
QImage * getMap()
Returns the map as an image (or nullptr in case of error).
~QgsRenderer()
Destructor for QgsRenderer.
Exception class for WMS service exceptions.
ExceptionCode
Exception codes as defined in OGC scpecifications for WMS 1.1.1 and WMS 1.3.0.
@ QGIS_InvalidParameterValue
@ QGIS_MissingParameterValue
WMS parameter received from the client.
double dxfScale() const
Returns the DXF SCALE parameter.
bool transparentAsBool() const
Returns TRANSPARENT parameter as a bool or its default value if not defined.
QString x() const
Returns X parameter or an empty string if not defined.
QMap< DxfFormatOption, QString > dxfFormatOptions() const
Returns a map of DXF options defined within FORMAT_OPTIONS parameter.
QString formatAsString() const
Returns FORMAT parameter as a string.
QgsProjectVersion versionAsNumber() const
Returns VERSION parameter if defined or its default value.
QgsWmsParametersComposerMap composerMapParameters(int mapId) const
Returns the requested parameters for a composer map parameter.
QgsRectangle bboxAsRectangle() const
Returns BBOX as a rectangle if defined and valid.
bool withGeometry() const
Returns if the client wants the feature info response with geometry information.
QString pointTolerance() const
Returns FI_POINT_TOLERANCE parameter or an empty string if not defined.
QString filterGeom() const
Returns the filter geometry found in FILTER_GEOM parameter.
QString composerTemplate() const
Returns TEMPLATE parameter or an empty string if not defined.
Format infoFormat() const
Returns infoFormat.
QString y() const
Returns Y parameter or an empty string if not defined.
void dump() const
Dumps parameters.
int pointToleranceAsInt() const
Returns FI_POINT_TOLERANCE parameter as an integer.
bool withMapTip() const
withMapTip
QString polygonTolerance() const
Returns FI_POLYGON_TOLERANCE parameter or an empty string if not defined.
QString i() const
Returns I parameter or an empty string if not defined.
int lineToleranceAsInt() const
Returns FI_LINE_TOLERANCE parameter as an integer.
QString lineTolerance() const
Returns FI_LINE_TOLERANCE parameter or an empty string if not defined.
QString j() const
Returns J parameter or an empty string if not defined.
int xAsInt() const
Returns X parameter as an int or its default value if not defined.
QString bbox() const
Returns BBOX if defined or an empty string.
int heightAsInt() const
Returns HEIGHT parameter as an int or its default value if not defined.
QColor backgroundColorAsColor() const
Returns BGCOLOR parameter as a QColor or its default value if not defined.
Format format() const
Returns format.
QStringList atlasPk() const
Returns the ATLAS_PK parameter.
QList< QgsWmsParametersHighlightLayer > highlightLayersParameters() const
Returns parameters for each highlight layer.
int iAsInt() const
Returns I parameter as an int or its default value if not defined.
int polygonToleranceAsInt() const
Returns FI_POLYGON_TOLERANCE parameter as an integer.
QgsDxfExport::SymbologyExport dxfMode() const
Returns the DXF MODE parameter.
int widthAsInt() const
Returns WIDTH parameter as an int or its default value if not defined.
QString sldBody() const
Returns SLD_body if defined or an empty string.
QString layoutParameter(const QString &id, bool &ok) const
Returns a layout parameter thanks to its id.
bool dxfUseLayerTitleAsName() const
Returns the DXF USE_TITLE_AS_LAYERNAME parameter.
QMap< QString, QString > dimensionValues() const
Returns the dimensions parameter.
int infoFormatVersion() const
Returns the infoFormat version for GML.
QgsLegendSettings legendSettings() const
Returns legend settings.
QStringList dxfLayerAttributes() const
Returns the DXF LAYERATTRIBUTES parameter.
QString crs() const
Returns CRS or an empty string if none is defined.
int featureCountAsInt() const
Returns FEATURE_COUNT as an integer.
int yAsInt() const
Returns Y parameter as an int or its default value if not defined.
Format
Output format for the response.
QStringList filters() const
Returns the list of filters found in FILTER parameter.
QString dpi() const
Returns DPI parameter or an empty string if not defined.
int jAsInt() const
Returns J parameter as an int or its default value if not defined.
QStringList queryLayersNickname() const
Returns nickname of layers found in QUERY_LAYERS parameter.
Rendering context for the WMS renderer.
QSize mapSize(bool aspectRatio=true) const
Returns the size (in pixels) of the map to render, according to width and height WMS parameters as we...
bool isExternalLayer(const QString &name) const
Returns true if the layer is an external layer, false otherwise.
bool isValidGroup(const QString &name) const
Returns true if name is a group.
QStringList flattenedQueryLayers(const QStringList &layerNames) const
Returns a list of query layer names where group names are replaced by the names of their layer compon...
QList< QgsMapLayer * > layersToRender() const
Returns a list of all layers to actually render according to the current configuration.
QgsMapLayer * layer(const QString &nickname) const
Returns the layer corresponding to the nickname, or a nullptr if not found or if the layer do not nee...
bool updateExtent() const
Returns true if the extent has to be updated before the rendering, false otherwise.
const QgsServerSettings & settings() const
Returns settings of the server.
bool isValidWidthHeight() const
Returns true if width and height are valid according to the maximum values defined within the project...
QList< QgsMapLayer * > layersFromGroup(const QString &nickname) const
Returns the group's layers list corresponding to the nickname, or an empty list if not found.
QgsWmsParameters parameters() const
Returns WMS parameters.
void setScaleDenominator(double scaleDenominator)
Sets a custom scale denominator.
QString style(const QgsMapLayer &layer) const
Returns a style's name for a specific layer.
QMap< QString, QList< QgsMapLayer * > > layerGroups() const
Returns a map having layer group names as keys and a list of layers as values.
double mapTileBuffer(int mapWidth) const
Returns the tile buffer in geographical units for the given map width in pixels.
QString layerNickname(const QgsMapLayer &layer) const
Returns the nickname (short name, id or name) of the layer according to the current configuration.
qreal dotsPerMm() const
Returns default dots per mm according to the current configuration.
bool testFlag(Flag flag) const
Returns the status of a rendering flag.
QDomElement sld(const QgsMapLayer &layer) const
Returns a SLD document for a specific layer.
bool isValidLayer(const QString &nickname) const
Returns true if the layer has to be rendered, false otherwise.
const QgsProject * project() const
Returns the project.
int precision() const
Returns the precision to use according to the current configuration.
bool renderMapTiles() const
Returns true if WMS requests should use the QgsMapSettings::RenderMapTile flag, so that no visible ar...
RAII class to restore the rendering context configuration on destruction.
@ PointCloudLayer
Added in 3.18.
@ VectorTileLayer
Added in 3.14.
@ AnnotationLayer
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
SERVER_EXPORT QString getExpressionFromServerFid(const QString &serverFid, const QgsVectorDataProvider *provider)
Returns the expression feature id based on primary keys.
SERVER_EXPORT QString getServerFid(const QgsFeature &feature, const QgsAttributeList &pkAttributes)
Returns the feature id based on primary keys.
SERVER_EXPORT QString wmsFeatureInfoSchema(const QgsProject &project)
Returns the schema URL for XML GetFeatureInfo request.
SERVER_EXPORT bool wmsInfoFormatSia2045(const QgsProject &project)
Returns if the info format is SIA20145.
SERVER_EXPORT QString wmsFeatureInfoDocumentElementNs(const QgsProject &project)
Returns the document element namespace for XML GetFeatureInfo request.
SERVER_EXPORT bool wmsFeatureInfoSegmentizeWktGeometry(const QgsProject &project)
Returns if the geometry has to be segmentize in GetFeatureInfo request.
SERVER_EXPORT bool wmsFeatureInfoUseAttributeFormSettings(const QgsProject &project)
Returns if feature form settings should be considered for the format of the feature info response.
SERVER_EXPORT QHash< QString, QString > wmsFeatureInfoLayerAliasMap(const QgsProject &project)
Returns the mapping between layer name and wms layer name for GetFeatureInfo request.
SERVER_EXPORT bool wmsFeatureInfoAddWktGeometry(const QgsProject &project)
Returns if the geometry is displayed as Well Known Text in GetFeatureInfo request.
SERVER_EXPORT double wmsDefaultMapUnitsPerMm(const QgsProject &project)
Returns the default number of map units per millimeters in case of the scale is not given.
SERVER_EXPORT QString wmsFeatureInfoDocumentElement(const QgsProject &project)
Returns the document element name for XML GetFeatureInfo request.
SERVER_EXPORT int wmsMaxAtlasFeatures(const QgsProject &project)
Returns the maximum number of atlas features which can be printed in a request.
Median cut implementation.
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
#define Q_NOWARN_DEPRECATED_POP
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
#define Q_NOWARN_DEPRECATED_PUSH
QList< QgsFeature > QgsFeatureList
QSet< QgsFeatureId > QgsFeatureIds
#define FID_TO_STRING(fid)
#define STRING_TO_FID(str)
QVector< QgsFeatureStore > QgsFeatureStoreList
QList< int > QgsAttributeList
const QgsCoordinateReferenceSystem & outputCrs
const QgsCoordinateReferenceSystem & crs
Layers and optional attribute index to split into multiple layers using attribute value as layer name...
QPainter * painter
Painter.
Contains settings relating to exporting layouts to raster images.
QList< int > pages
List of specific pages to export, or an empty list to export all pages.
QSize imageSize
Manual size in pixels for output image.
QgsLayoutRenderContext::Flags flags
Layout context flags, which control how the export will be created.
double dpi
Resolution to export layout at. If dpi <= 0 the default layout dpi will be used.
Contains settings relating to exporting layouts to PDF.
bool rasterizeWholeImage
Set to true to force whole layout to be rasterized while exporting.
QgsLayoutRenderContext::Flags flags
Layout context flags, which control how the export will be created.
double dpi
Resolution to export layout at. If dpi <= 0 the default layout dpi will be used.
Contains settings relating to exporting layouts to SVG.
double dpi
Resolution to export layout at. If dpi <= 0 the default layout dpi will be used.
QgsLayoutRenderContext::Flags flags
Layout context flags, which control how the export will be created.
Setting to define QGIS Server WMS Dimension.
@ MaxValue
Modify current selection to include only select features which match.
@ AllValues
Display all values of the dimension.
@ ReferenceValue
Remove from current selection.
@ MinValue
Add selection to current selection.
Setting options for loading vector layers.
QList< QgsWmsParametersLayer > mLayers
QList< QgsWmsParametersHighlightLayer > mHighlightLayers
QList< QgsWmsParametersFilter > mFilter