75 #include <QStringList> 76 #include <QTemporaryFile> 77 #include <QTextStream> 103 #include <QSvgGenerator> 105 #include <QPaintEngine> 119 if ( legendNode->data( Qt::DisplayRole ).toString() == rule )
132 : mWmsParameters( parameters )
133 #ifdef HAVE_SERVER_PYTHON_PLUGINS
134 , mAccessControl( serverIface->accessControls() )
136 , mSettings( *serverIface->serverSettings() )
137 , mProject( project )
139 mWmsParameters.
dump();
141 initRestrictedLayers();
142 initNicknameLayers();
147 removeTemporaryLayers();
156 QStringLiteral(
"LAYER is mandatory for GetLegendGraphic operation" ) );
158 if ( mWmsParameters.
format() == QgsWmsParameters::Format::NONE )
160 QStringLiteral(
"FORMAT is mandatory for GetLegendGraphic operation" ) );
164 if ( ! mWmsParameters.
bbox().isEmpty() )
166 if ( mWmsParameters.
width().isEmpty() && mWmsParameters.
srcWidth().isEmpty() )
170 if ( mWmsParameters.
height().isEmpty() && mWmsParameters.
srcHeight().isEmpty() )
176 double scaleDenominator = -1;
177 if ( ! mWmsParameters.
scale().isEmpty() )
183 std::unique_ptr<QgsLayerRestorer> restorer;
186 QList<QgsMapLayer *> layers;
189 QString sld = mWmsParameters.
sldBody();
190 if ( !sld.isEmpty() )
191 layers = sldStylizedLayers( sld );
193 layers = stylizedLayers( params );
195 removeUnwantedLayers( layers, scaleDenominator );
196 std::reverse( layers.begin(), layers.end() );
200 checkLayerReadPermissions( ml );
204 std::unique_ptr<QgsLayerTreeModel> legendModel;
205 legendModel.reset( buildLegendTreeModel( layers, scaleDenominator, rootGroup ) );
208 qreal dpmm = dotsPerMm();
209 std::unique_ptr<QImage> image;
210 std::unique_ptr<QPainter> painter;
213 if ( !mWmsParameters.
bbox().isEmpty() )
216 std::unique_ptr<QImage> tmp( createImage( width(), height(),
false ) );
217 configureMapSettings( tmp.get(), mapSettings );
227 if ( !mWmsParameters.
rule().isEmpty() )
229 QString rule = mWmsParameters.
rule();
233 image.reset( createImage( width, height,
false ) );
234 painter.reset(
new QPainter( image.get() ) );
235 painter->setRenderHint( QPainter::Antialiasing,
true );
236 painter->scale( dpmm, dpmm );
244 ctx.
point = QPointF();
245 double itemHeight = height / dpmm;
246 legendNode->
drawSymbol( legendSettings, &ctx, itemHeight );
255 QSize s( minSize.width() * dpmm, minSize.height() * dpmm );
257 image.reset( createImage( s.width(), s.height(), false ) );
258 painter.reset(
new QPainter( image.get() ) );
259 painter->setRenderHint( QPainter::Antialiasing,
true );
260 painter->scale( dpmm, dpmm );
262 legendRendererNew.drawLegend( painter.get() );
267 return image.release();
274 for (
const QString &
id : mapSettings.
layerIds() )
291 runHitTestLayer( vl, usedSymbols, context );
297 std::unique_ptr< QgsFeatureRenderer > r( vl->
renderer()->
clone() );
299 r->startRender( context, vl->
fields() );
307 if ( moreSymbolsPerFeature )
309 for (
QgsSymbol *s : r->originalSymbolsForFeature( f, context ) )
315 r->stopRender( context );
323 if ( templateName.isEmpty() )
326 QStringLiteral(
"The TEMPLATE parameter is required for the GetPrint request" ) );
330 QList<QgsMapLayer *> layers;
335 std::unique_ptr<QImage> image(
new QImage() );
339 configureMapSettings( image.get(), mapSettings );
342 std::unique_ptr<QgsLayerRestorer> restorer;
346 QString sld = mWmsParameters.
sldBody();
347 if ( !sld.isEmpty() )
349 layers = sldStylizedLayers( sld );
353 layers = stylizedLayers( params );
357 removeUnwantedLayers( layers );
360 bool updateMapExtent = mWmsParameters.
bbox().isEmpty();
363 checkLayerReadPermissions( layer );
367 if ( param.mNickname == layerNickname( *layer ) )
369 setLayerOpacity( layer, param.mOpacity );
371 setLayerFilter( layer, param.mFilter );
373 setLayerSelection( layer, param.mSelection );
375 if ( updateMapExtent )
376 updateExtent( layer, mapSettings );
382 setLayerAccessControlFilter( layer );
389 std::reverse( layers.begin(), layers.end() );
397 QStringLiteral(
"Template '%1' is not known" ).arg( templateName ) );
404 QStringLiteral(
"Template '%1' has no pages" ).arg( templateName ) );
407 std::unique_ptr<QgsPrintLayout> layout( sourceLayout->
clone() );
409 configurePrintLayout( layout.get(), mapSettings );
412 QTemporaryFile tempOutputFile( QDir::tempPath() +
'/' + QStringLiteral(
"XXXXXX.%1" ).arg( formatString.toLower() ) );
413 if ( !tempOutputFile.open() )
415 throw QgsServerException( QStringLiteral(
"Could not open temporary file for the GetPrint request." ) );
419 if ( formatString.compare( QLatin1String(
"svg" ), Qt::CaseInsensitive ) == 0 )
423 if ( !mWmsParameters.
dpi().isEmpty() )
426 double dpi( mWmsParameters.
dpi().toDouble( &ok ) );
428 exportSettings.
dpi = dpi;
433 exporter.
exportToSvg( tempOutputFile.fileName(), exportSettings );
435 else if ( formatString.compare( QLatin1String(
"png" ), Qt::CaseInsensitive ) == 0 || formatString.compare( QLatin1String(
"jpg" ), Qt::CaseInsensitive ) == 0 )
440 double dpi( layout->renderContext().dpi( ) );
441 if ( !mWmsParameters.
dpi().isEmpty() )
444 double _dpi = mWmsParameters.
dpi().toDouble( &ok );
448 exportSettings.
dpi = dpi;
452 QgsLayoutSize layoutSize( layout->pageCollection()->page( 0 )->sizeWithUnits() );
453 QgsLayoutMeasurement width( layout->convertFromLayoutUnits( layoutSize.width(), QgsUnitTypes::LayoutUnit::LayoutMillimeters ) );
454 QgsLayoutMeasurement height( layout->convertFromLayoutUnits( layoutSize.height(), QgsUnitTypes::LayoutUnit::LayoutMillimeters ) );
455 exportSettings.
imageSize = QSize( static_cast<int>( width.length() * dpi / 25.4 ), static_cast<int>( height.
length() * dpi / 25.4 ) );
457 exportSettings.
pages.append( 0 );
459 exporter.
exportToImage( tempOutputFile.fileName(), exportSettings );
461 else if ( formatString.compare( QLatin1String(
"pdf" ), Qt::CaseInsensitive ) == 0 )
466 if ( !mWmsParameters.
dpi().isEmpty() )
469 double dpi( mWmsParameters.
dpi().toDouble( &ok ) );
471 exportSettings.
dpi = dpi;
476 exportSettings.
rasterizeWholeImage = layout->customProperty( QStringLiteral(
"rasterize" ),
false ).toBool();
479 exporter.
exportToPdf( tempOutputFile.fileName(), exportSettings );
484 QStringLiteral(
"Output format '%1' is not supported in the GetPrint request" ).arg( formatString ) );
487 return tempOutputFile.readAll();
494 QList<QgsLayoutItemMap *> maps;
499 for (
const auto &map : qgis::as_const( maps ) )
526 if ( cMapParams.
mScale > 0 )
528 map->setScale( cMapParams.
mScale );
534 map->setMapRotation( cMapParams.
mRotation );
537 if ( !map->keepLayerSet() )
539 if ( cMapParams.
mLayers.isEmpty() )
541 map->setLayers( mapSettings.
layers() );
545 QList<QgsMapLayer *> layerSet = stylizedLayers( cMapParams.
mLayers );
547 std::reverse( layerSet.begin(), layerSet.end() );
548 map->setLayers( layerSet );
550 map->setKeepLayerSet(
true );
556 map->grid()->setIntervalX( cMapParams.
mGridX );
557 map->grid()->setIntervalY( cMapParams.
mGridY );
562 QList<QgsLayoutItemLabel *> labels;
564 for (
const auto &label : qgis::as_const( labels ) )
567 const QString labelId = label->
id();
568 const QString labelParam = mWmsParameters.
layoutParameter( labelId, ok );
573 if ( labelParam.isEmpty() )
577 c->removeItem( label );
582 label->setText( labelParam );
586 QList<QgsLayoutItemHtml *> htmls;
588 for (
const auto &html : qgis::as_const( htmls ) )
590 if ( html->frameCount() == 0 )
595 const QString htmlId = htmlFrame->
id();
614 html->setUrl( newUrl );
620 QList<QgsLayoutItemLegend *> legends;
622 for (
const auto &legend : qgis::as_const( legends ) )
624 if ( legend->autoUpdateModel() )
634 legend->setAutoUpdateModel(
false );
638 QStringList layerSet;
639 const QList<QgsMapLayer *> layerList( map->
layers() );
640 for (
const auto &layer : layerList )
641 layerSet << layer->id();
653 for (
const auto &layerId : layerIds )
660 if ( !layerSet.contains( layerId ) )
682 return getMap( mapSettings, hitTest );
688 if ( !checkMaximumWidthHeight() )
691 QStringLiteral(
"The requested map size is too large" ) );
695 QList<QgsMapLayer *> layers;
699 std::unique_ptr<QgsLayerRestorer> restorer;
703 QString sld = mWmsParameters.
sldBody();
704 if ( !sld.isEmpty() )
706 layers = sldStylizedLayers( sld );
710 layers = stylizedLayers( params );
714 removeUnwantedLayers( layers );
717 bool updateMapExtent = mWmsParameters.
bbox().isEmpty();
720 checkLayerReadPermissions( layer );
724 if ( param.mNickname == layerNickname( *layer ) )
726 setLayerOpacity( layer, param.mOpacity );
728 setLayerFilter( layer, param.mFilter );
730 setLayerSelection( layer, param.mSelection );
732 if ( updateMapExtent )
733 updateExtent( layer, mapSettings );
739 setLayerAccessControlFilter( layer );
746 std::unique_ptr<QPainter> painter;
747 std::unique_ptr<QImage> image( createImage() );
750 configureMapSettings( image.get(), mapSettings );
753 std::reverse( layers.begin(), layers.end() );
757 painter.reset( layersRendering( mapSettings, *image, hitTest ) );
760 annotationsRendering( painter.get() );
766 QImage *scaledImage = scaleImage( image.get() );
768 image.reset( scaledImage );
771 return image.release();
783 QList<QgsMapLayer *> layers;
787 std::unique_ptr<QgsLayerRestorer> restorer;
791 QString sld = mWmsParameters.
sldBody();
792 if ( !sld.isEmpty() )
794 layers = sldStylizedLayers( sld );
798 layers = stylizedLayers( params );
802 QStringList layerAttributes;
803 QMap<QString, QString>::const_iterator layerAttributesIt = options.find( QStringLiteral(
"LAYERATTRIBUTES" ) );
804 if ( layerAttributesIt != options.constEnd() )
806 layerAttributes = options.value( QStringLiteral(
"LAYERATTRIBUTES" ) ).split(
',' );
813 QList< QgsDxfExport::DxfLayer > dxfLayers;
820 if ( !wfsLayerIds.contains( layer->id() ) )
823 checkLayerReadPermissions( layer );
827 if ( param.mNickname == layerNickname( *layer ) )
829 setLayerOpacity( layer, param.mOpacity );
831 setLayerFilter( layer, param.mFilter );
837 setLayerAccessControlFilter( layer );
843 int layerAttribute = -1;
844 if ( layerAttributes.size() > layerIdx )
858 QMap<QString, QString>::const_iterator modeIt = options.find( QStringLiteral(
"MODE" ) );
861 if ( modeIt == options.constEnd() )
867 if ( modeIt->compare( QStringLiteral(
"SymbolLayerSymbology" ), Qt::CaseInsensitive ) == 0 )
871 else if ( modeIt->compare( QStringLiteral(
"FeatureSymbology" ), Qt::CaseInsensitive ) == 0 )
883 QMap<QString, QString>::const_iterator scaleIt = options.find( QStringLiteral(
"SCALE" ) );
884 if ( scaleIt != options.constEnd() )
895 if ( i < 0 || i > mapSettings.
outputSize().width() || j < 0 || j > mapSettings.
outputSize().height() )
910 QStringList queryLayers = flattenedQueryLayers();
912 if ( queryLayers.isEmpty() )
914 QString msg = QObject::tr(
"QUERY_LAYERS parameter is required for GetFeatureInfo" );
919 const bool ijDefined = !mWmsParameters.
i().isEmpty() && !mWmsParameters.
j().isEmpty();
920 const bool xyDefined = !mWmsParameters.
x().isEmpty() && !mWmsParameters.
y().isEmpty();
921 const bool filtersDefined = !mWmsParameters.
filters().isEmpty();
922 const bool filterGeomDefined = !mWmsParameters.
filterGeom().isEmpty();
924 if ( !ijDefined && !xyDefined && !filtersDefined && !filterGeomDefined )
927 QStringLiteral(
"I/J parameters are required for GetFeatureInfo" ) );
931 if ( infoFormat == QgsWmsParameters::Format::NONE )
934 QStringLiteral(
"Invalid INFO_FORMAT parameter" ) );
938 QList<QgsMapLayer *> layers;
942 std::unique_ptr<QgsLayerRestorer> restorer;
946 QString sld = mWmsParameters.
sldBody();
947 if ( !sld.isEmpty() )
948 layers = sldStylizedLayers( sld );
950 layers = stylizedLayers( params );
953 for (
const QString &queryLayer : queryLayers )
955 if ( mNicknameLayers.contains( queryLayer )
956 && !layers.contains( mNicknameLayers[queryLayer] ) )
958 layers.append( mNicknameLayers[queryLayer] );
974 std::unique_ptr<QImage> outputImage( createImage( imageWidth, imageHeight ) );
978 bool mandatoryCrsParam =
true;
979 if ( filtersDefined && !ijDefined && !xyDefined && mWmsParameters.
crs().isEmpty() )
981 mandatoryCrsParam =
false;
985 configureMapSettings( outputImage.get(), mapSettings, mandatoryCrsParam );
994 double scaleDenominator = scaleCalc.calculate( mapExtent, outputImage->width() );
997 removeUnwantedLayers( layers, scaleDenominator );
1003 checkLayerReadPermissions( layer );
1007 if ( param.mNickname == layerNickname( *layer ) )
1009 setLayerFilter( layer, param.mFilter );
1015 setLayerAccessControlFilter( layer );
1019 std::reverse( layers.begin(), layers.end() );
1022 QDomDocument result = featureInfoDocument( layers, mapSettings, outputImage.get(), version );
1026 if ( infoFormat == QgsWmsParameters::Format::TEXT )
1027 ba = convertFeatureInfoToText( result );
1028 else if ( infoFormat == QgsWmsParameters::Format::HTML )
1029 ba = convertFeatureInfoToHtml( result );
1031 ba = result.toByteArray();
1036 QImage *QgsRenderer::createImage(
int width,
int height,
bool useBbox )
const 1039 width = this->width();
1042 height = this->height();
1049 if ( !mWmsParameters.
bbox().isEmpty() && mapExtent.
isEmpty() )
1052 QStringLiteral(
"Invalid BBOX parameter" ) );
1055 QString
crs = mWmsParameters.
crs();
1056 if ( crs.compare(
"CRS:84", Qt::CaseInsensitive ) == 0 )
1058 crs = QString(
"EPSG:4326" );
1066 if ( !mapExtent.
isEmpty() && height > 0 && width > 0 )
1068 double mapWidthHeightRatio = mapExtent.
width() / mapExtent.
height();
1069 double imageWidthHeightRatio =
static_cast<double>( width ) / static_cast<double>( height );
1070 if ( !
qgsDoubleNear( mapWidthHeightRatio, imageWidthHeightRatio, 0.0001 ) )
1073 double cellsize = ( mapExtent.
width() /
static_cast<double>( width ) ) * 0.5 + ( mapExtent.
height() /
static_cast<double>( height ) ) * 0.5;
1074 width = mapExtent.
width() / cellsize;
1075 height = mapExtent.
height() / cellsize;
1080 if ( width <= 0 || height <= 0 )
1082 throw QgsException( QStringLiteral(
"createImage: Invalid width / height parameters" ) );
1085 std::unique_ptr<QImage> image;
1093 image = qgis::make_unique<QImage>( width, height, QImage::Format_ARGB32_Premultiplied );
1098 image = qgis::make_unique<QImage>( width, height, QImage::Format_RGB32 );
1103 if ( image->isNull() )
1105 throw QgsException( QStringLiteral(
"createImage: image could not be created, check for out of memory conditions" ) );
1110 double OGC_PX_M = 0.00028;
1111 int dpm = 1 / OGC_PX_M;
1112 if ( !mWmsParameters.
dpi().isEmpty() )
1115 image->setDotsPerMeterX( dpm );
1116 image->setDotsPerMeterY( dpm );
1117 return image.release();
1120 void QgsRenderer::configureMapSettings(
const QPaintDevice *paintDevice,
QgsMapSettings &mapSettings,
bool mandatoryCrsParam )
const 1124 throw QgsException( QStringLiteral(
"configureMapSettings: no paint device" ) );
1127 mapSettings.
setOutputSize( QSize( paintDevice->width(), paintDevice->height() ) );
1128 mapSettings.
setOutputDpi( paintDevice->logicalDpiX() );
1132 if ( !mWmsParameters.
bbox().isEmpty() && mapExtent.
isEmpty() )
1134 throw QgsBadRequestException( QStringLiteral(
"InvalidParameterValue" ), QStringLiteral(
"Invalid BBOX parameter" ) );
1137 QString
crs = mWmsParameters.
crs();
1138 if ( crs.compare(
"CRS:84", Qt::CaseInsensitive ) == 0 )
1140 crs = QString(
"EPSG:4326" );
1143 else if ( crs.isEmpty() && !mandatoryCrsParam )
1145 crs = QString(
"EPSG:4326" );
1155 throw QgsBadRequestException( QStringLiteral(
"InvalidCRS" ), QStringLiteral(
"Could not create output CRS" ) );
1181 else if ( backgroundColor.isValid() )
1198 int myRed = mProject->
readNumEntry(
"Gui",
"/SelectionColorRedPart", 255 );
1199 int myGreen = mProject->
readNumEntry(
"Gui",
"/SelectionColorGreenPart", 255 );
1200 int myBlue = mProject->
readNumEntry(
"Gui",
"/SelectionColorBluePart", 0 );
1201 int myAlpha = mProject->
readNumEntry(
"Gui",
"/SelectionColorAlphaPart", 255 );
1205 QDomDocument QgsRenderer::featureInfoDocument( QList<QgsMapLayer *> &layers,
const QgsMapSettings &mapSettings,
1206 const QImage *outputImage,
const QString &version )
const 1209 const QStringList queryLayers = flattenedQueryLayers( );
1211 bool ijDefined = ( !mWmsParameters.
i().isEmpty() && !mWmsParameters.
j().isEmpty() );
1213 bool xyDefined = ( !mWmsParameters.
x().isEmpty() && !mWmsParameters.
y().isEmpty() );
1215 bool filtersDefined = !mWmsParameters.
filters().isEmpty();
1217 bool filterGeomDefined = !mWmsParameters.
filterGeom().isEmpty();
1220 if ( featureCount < 1 )
1225 int i = mWmsParameters.
iAsInt();
1226 int j = mWmsParameters.
jAsInt();
1227 if ( xyDefined && !ijDefined )
1229 i = mWmsParameters.
xAsInt();
1230 j = mWmsParameters.
yAsInt();
1234 if ( ( i != -1 && j != -1 && width != 0 && height != 0 ) && ( width != outputImage->width() || height != outputImage->height() ) )
1236 i *= ( outputImage->width() /
static_cast<double>( width ) );
1237 j *= ( outputImage->height() /
static_cast<double>( height ) );
1241 std::unique_ptr<QgsRectangle> featuresRect;
1242 std::unique_ptr<QgsGeometry> filterGeom;
1243 std::unique_ptr<QgsPointXY> infoPoint;
1245 if ( i != -1 && j != -1 )
1248 infoPointToMapCoordinates( i, j, infoPoint.get(), mapSettings );
1250 else if ( filtersDefined )
1254 else if ( filterGeomDefined )
1259 QDomDocument result;
1261 QDomElement getFeatureInfoElement;
1263 if ( infoFormat == QgsWmsParameters::Format::GML )
1265 getFeatureInfoElement = result.createElement( QStringLiteral(
"wfs:FeatureCollection" ) );
1266 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:wfs" ), QStringLiteral(
"http://www.opengis.net/wfs" ) );
1267 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:ogc" ), QStringLiteral(
"http://www.opengis.net/ogc" ) );
1268 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:gml" ), QStringLiteral(
"http://www.opengis.net/gml" ) );
1269 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:ows" ), QStringLiteral(
"http://www.opengis.net/ows" ) );
1270 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:xlink" ), QStringLiteral(
"http://www.w3.org/1999/xlink" ) );
1271 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:qgs" ), QStringLiteral(
"http://qgis.org/gml" ) );
1272 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
1273 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" ) );
1278 if ( featureInfoElemName.isEmpty() )
1280 featureInfoElemName = QStringLiteral(
"GetFeatureInfoResponse" );
1283 if ( featureInfoElemNs.isEmpty() )
1285 getFeatureInfoElement = result.createElement( featureInfoElemName );
1289 getFeatureInfoElement = result.createElementNS( featureInfoElemNs, featureInfoElemName );
1293 if ( !featureInfoSchema.isEmpty() )
1295 getFeatureInfoElement.setAttribute( QStringLiteral(
"xmlns:xsi" ), QStringLiteral(
"http://www.w3.org/2001/XMLSchema-instance" ) );
1296 getFeatureInfoElement.setAttribute( QStringLiteral(
"xsi:schemaLocation" ), featureInfoSchema );
1299 result.appendChild( getFeatureInfoElement );
1309 for (
const QString &queryLayer : queryLayers )
1311 bool validLayer =
false;
1312 bool queryableLayer =
true;
1313 for (
QgsMapLayer *layer : qgis::as_const( layers ) )
1315 if ( queryLayer == layerNickname( *layer ) )
1319 if ( !queryableLayer )
1324 QDomElement layerElement;
1325 if ( infoFormat == QgsWmsParameters::Format::GML )
1327 layerElement = getFeatureInfoElement;
1331 layerElement = result.createElement( QStringLiteral(
"Layer" ) );
1332 QString layerName = queryLayer;
1335 QHash<QString, QString>::const_iterator layerAliasIt = layerAliasMap.find( layerName );
1336 if ( layerAliasIt != layerAliasMap.constEnd() )
1338 layerName = layerAliasIt.value();
1341 layerElement.setAttribute( QStringLiteral(
"name" ), layerName );
1342 getFeatureInfoElement.appendChild( layerElement );
1345 layerElement.setAttribute( QStringLiteral(
"id" ), layer->id() );
1354 ( void )featureInfoFromVectorLayer( vectorLayer, infoPoint.get(), featureCount, result, layerElement, mapSettings, renderContext, version, featuresRect.get(), filterGeom.get() );
1374 if ( infoFormat == QgsWmsParameters::Format::GML )
1376 layerElement = result.createElement( QStringLiteral(
"gml:featureMember" ) );
1377 getFeatureInfoElement.appendChild( layerElement );
1380 ( void )featureInfoFromRasterLayer( rasterLayer, mapSettings, &layerInfoPoint, result, layerElement, version );
1385 if ( !validLayer && !mNicknameLayers.contains( queryLayer ) && !mLayerGroups.contains( queryLayer ) )
1387 QString msg = QObject::tr(
"Layer '%1' not found" ).arg( queryLayer );
1390 else if ( ( validLayer && !queryableLayer ) || ( !validLayer && mLayerGroups.contains( queryLayer ) ) )
1392 auto queryLayerName { queryLayer };
1394 bool hasGroupAndQueryable {
false };
1399 for (
const auto &ql : constNicks )
1401 if ( mLayerGroups.contains( ql ) )
1403 const auto &constLayers { mLayerGroups[ql] };
1404 for (
const auto &ml : constLayers )
1406 if ( ( ! ml->shortName().isEmpty() && ml->shortName() == queryLayer ) || ( ml->name() == queryLayer ) )
1408 queryLayerName = ql;
1412 hasGroupAndQueryable =
true;
1421 if ( ! hasGroupAndQueryable )
1423 const QString msg { QObject::tr(
"The layer '%1' is not queryable." ).arg( queryLayerName ) };
1431 if ( infoFormat == QgsWmsParameters::Format::GML )
1433 QDomElement bBoxElem = result.createElement( QStringLiteral(
"gml:boundedBy" ) );
1434 QDomElement boxElem;
1436 if ( gmlVersion < 3 )
1446 if ( crs.isValid() )
1448 boxElem.setAttribute( QStringLiteral(
"srsName" ), crs.authid() );
1450 bBoxElem.appendChild( boxElem );
1451 getFeatureInfoElement.insertBefore( bBoxElem, QDomNode() );
1455 QDomElement bBoxElem = result.createElement( QStringLiteral(
"BoundingBox" ) );
1457 bBoxElem.setAttribute( QStringLiteral(
"minx" ),
qgsDoubleToString( featuresRect->xMinimum(), 8 ) );
1458 bBoxElem.setAttribute( QStringLiteral(
"maxx" ),
qgsDoubleToString( featuresRect->xMaximum(), 8 ) );
1459 bBoxElem.setAttribute( QStringLiteral(
"miny" ),
qgsDoubleToString( featuresRect->yMinimum(), 8 ) );
1460 bBoxElem.setAttribute( QStringLiteral(
"maxy" ),
qgsDoubleToString( featuresRect->yMaximum(), 8 ) );
1461 getFeatureInfoElement.insertBefore( bBoxElem, QDomNode() );
1465 if ( sia2045 && infoFormat == QgsWmsParameters::Format::XML )
1467 convertFeatureInfoToSia2045( result );
1473 bool QgsRenderer::featureInfoFromVectorLayer(
QgsVectorLayer *layer,
1476 QDomDocument &infoDocument,
1477 QDomElement &layerElement,
1480 const QString &version,
1492 std::unique_ptr<QgsGeometry> layerFilterGeom;
1495 layerFilterGeom.reset(
new QgsGeometry( *filterGeom ) );
1509 searchRect = featureInfoSearchRect( layer, mapSettings, renderContext, *infoPoint );
1511 else if ( layerFilterGeom )
1513 searchRect = layerFilterGeom->boundingBox();
1515 else if ( !mWmsParameters.
bbox().isEmpty() )
1517 searchRect = layerRect;
1524 int featureCounter = 0;
1531 bool hasGeometry = addWktGeometry || featureBBox || layerFilterGeom;
1544 if ( layerFilterGeom )
1546 fReq.
setFilterExpression( QString(
"intersects( $geometry, geom_from_wkt('%1') )" ).arg( layerFilterGeom->asWkt() ) );
1549 #ifdef HAVE_SERVER_PYTHON_PLUGINS 1550 mAccessControl->filterFeatures( layer, fReq );
1552 QStringList attributes;
1553 for (
const QgsField &field : fields )
1555 attributes.append( field.name() );
1557 attributes = mAccessControl->layerAttributes( layer, attributes );
1562 std::unique_ptr< QgsFeatureRenderer > r2( layer->
renderer() ? layer->
renderer()->
clone() : nullptr );
1565 r2->startRender( renderContext, layer->
fields() );
1568 bool featureBBoxInitialized =
false;
1577 if ( featureCounter > nFeatures )
1592 bool render = r2->willRenderFeature( feature, renderContext );
1605 if ( !featureBBoxInitialized && featureBBox->
isEmpty() )
1608 featureBBoxInitialized =
true;
1623 if ( mWmsParameters.
infoFormat() == QgsWmsParameters::Format::GML )
1627 QString
typeName = layerNickname( *layer );
1628 QDomElement elem = createFeatureGML(
1629 &feature, layer, infoDocument, outputCrs, mapSettings, typeName, withGeom, gmlVersion
1630 #ifdef HAVE_SERVER_PYTHON_PLUGINS
1634 QDomElement featureMemberElem = infoDocument.createElement( QStringLiteral(
"gml:featureMember" ) );
1635 featureMemberElem.appendChild( elem );
1636 layerElement.appendChild( featureMemberElem );
1641 QDomElement featureElement = infoDocument.createElement( QStringLiteral(
"Feature" ) );
1643 layerElement.appendChild( featureElement );
1647 for (
int i = 0; i < featureAttributes.count(); ++i )
1650 if ( excludedAttributes.contains( fields.at( i ).name() ) )
1654 #ifdef HAVE_SERVER_PYTHON_PLUGINS 1656 if ( !attributes.contains( fields.at( i ).name() ) )
1665 QDomElement attributeElement = infoDocument.createElement( QStringLiteral(
"Attribute" ) );
1666 attributeElement.setAttribute( QStringLiteral(
"name" ), attributeName );
1668 attributeElement.setAttribute( QStringLiteral(
"value" ),
1670 replaceValueMapAndRelation(
1672 featureAttributes[i] ),
1675 featureElement.appendChild( attributeElement );
1680 if ( !mapTip.isEmpty() && mWmsParameters.
withMapTip() )
1682 QDomElement maptipElem = infoDocument.createElement( QStringLiteral(
"Attribute" ) );
1683 maptipElem.setAttribute( QStringLiteral(
"name" ), QStringLiteral(
"maptip" ) );
1685 featureElement.appendChild( maptipElem );
1691 QDomElement bBoxElem = infoDocument.createElement( QStringLiteral(
"BoundingBox" ) );
1692 bBoxElem.setAttribute( version == QLatin1String(
"1.1.1" ) ?
"SRS" :
"CRS", outputCrs.
authid() );
1697 featureElement.appendChild( bBoxElem );
1713 if ( segmentizeWktGeometry )
1721 geom.
set( segmentizedGeom );
1725 QDomElement geometryElement = infoDocument.createElement( QStringLiteral(
"Attribute" ) );
1726 geometryElement.setAttribute( QStringLiteral(
"name" ), QStringLiteral(
"geometry" ) );
1728 geometryElement.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"derived" ) );
1729 featureElement.appendChild( geometryElement );
1736 r2->stopRender( renderContext );
1742 bool QgsRenderer::featureInfoFromRasterLayer(
QgsRasterLayer *layer,
1745 QDomDocument &infoDocument,
1746 QDomElement &layerElement,
1747 const QString &version )
const 1749 Q_UNUSED( version );
1766 QgsRaster::IdentifyFormat::IdentifyFormatFeature :
1767 QgsRaster::IdentifyFormat::IdentifyFormatValue };
1774 if ( ! transform.isValid() )
1776 throw QgsBadRequestException( QStringLiteral(
"InvalidCRS" ), QStringLiteral(
"CRS transform error from %1 to %2 in layer %3" )
1779 .arg( layer->
name() ) );
1788 if ( !identifyResult.
isValid() )
1791 QMap<int, QVariant> attributes = identifyResult.
results();
1793 if ( mWmsParameters.
infoFormat() == QgsWmsParameters::Format::GML )
1799 QString
typeName = layerNickname( *layer );
1805 for (
auto it = attributes.constBegin(); it != attributes.constEnd(); ++it )
1808 feature.
setAttribute( index++, QString::number( it.value().toDouble() ) );
1811 QDomElement elem = createFeatureGML(
1812 &feature,
nullptr, infoDocument, layerCrs, mapSettings, typeName,
false, gmlVersion,
nullptr );
1813 layerElement.appendChild( elem );
1817 const auto values = identifyResult.
results();
1818 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
1820 QVariant value = it.value();
1821 if ( value.type() == QVariant::Bool && !value.toBool() )
1827 if ( value.type() == QVariant::String )
1838 for (
const QgsFeature &feature : storeFeatures )
1840 QDomElement elem = createFeatureGML(
1841 &feature,
nullptr, infoDocument, layerCrs, mapSettings, typeName,
false, gmlVersion,
nullptr );
1842 layerElement.appendChild( elem );
1852 for (
auto it = attributes.constBegin(); it != attributes.constEnd(); ++it )
1854 QDomElement attributeElement = infoDocument.createElement( QStringLiteral(
"Attribute" ) );
1855 attributeElement.setAttribute( QStringLiteral(
"name" ), layer->
bandName( it.key() ) );
1856 attributeElement.setAttribute( QStringLiteral(
"value" ), QString::number( it.value().toDouble() ) );
1857 layerElement.appendChild( attributeElement );
1862 const auto values = identifyResult.
results();
1863 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
1865 QVariant value = it.value();
1866 if ( value.type() == QVariant::Bool && !value.toBool() )
1872 if ( value.type() == QVariant::String )
1882 for (
const QgsFeature &feature : storeFeatures )
1884 for (
const auto &fld : feature.fields() )
1886 const auto val { feature.attribute( fld.name() )};
1887 if ( val.isValid() )
1889 QDomElement attributeElement = infoDocument.createElement( QStringLiteral(
"Attribute" ) );
1890 attributeElement.setAttribute( QStringLiteral(
"name" ), fld.name() );
1891 attributeElement.setAttribute( QStringLiteral(
"value" ), val.toString() );
1892 layerElement.appendChild( attributeElement );
1903 bool QgsRenderer::testFilterStringSafety(
const QString &filter )
const 1906 if ( filter.contains( QLatin1String(
";" ) ) )
1911 QStringList tokens = filter.split(
' ', QString::SkipEmptyParts );
1912 groupStringList( tokens, QStringLiteral(
"'" ) );
1913 groupStringList( tokens, QStringLiteral(
"\"" ) );
1915 for (
auto tokenIt = tokens.constBegin() ; tokenIt != tokens.constEnd(); ++tokenIt )
1918 if ( tokenIt->compare( QLatin1String(
"," ) ) == 0
1919 || tokenIt->compare( QLatin1String(
"(" ) ) == 0
1920 || tokenIt->compare( QLatin1String(
")" ) ) == 0
1921 || tokenIt->compare( QLatin1String(
"=" ) ) == 0
1922 || tokenIt->compare( QLatin1String(
"!=" ) ) == 0
1923 || tokenIt->compare( QLatin1String(
"<" ) ) == 0
1924 || tokenIt->compare( QLatin1String(
"<=" ) ) == 0
1925 || tokenIt->compare( QLatin1String(
">" ) ) == 0
1926 || tokenIt->compare( QLatin1String(
">=" ) ) == 0
1927 || tokenIt->compare( QLatin1String(
"%" ) ) == 0
1928 || tokenIt->compare( QLatin1String(
"IS" ), Qt::CaseInsensitive ) == 0
1929 || tokenIt->compare( QLatin1String(
"NOT" ), Qt::CaseInsensitive ) == 0
1930 || tokenIt->compare( QLatin1String(
"NULL" ), Qt::CaseInsensitive ) == 0
1931 || tokenIt->compare( QLatin1String(
"AND" ), Qt::CaseInsensitive ) == 0
1932 || tokenIt->compare( QLatin1String(
"OR" ), Qt::CaseInsensitive ) == 0
1933 || tokenIt->compare( QLatin1String(
"IN" ), Qt::CaseInsensitive ) == 0
1934 || tokenIt->compare( QLatin1String(
"LIKE" ), Qt::CaseInsensitive ) == 0
1935 || tokenIt->compare( QLatin1String(
"ILIKE" ), Qt::CaseInsensitive ) == 0
1936 || tokenIt->compare( QLatin1String(
"DMETAPHONE" ), Qt::CaseInsensitive ) == 0
1937 || tokenIt->compare( QLatin1String(
"SOUNDEX" ), Qt::CaseInsensitive ) == 0 )
1944 tokenIt->toDouble( &isNumeric );
1953 if ( *tokenIt == QLatin1String(
"''" ) )
1959 if ( tokenIt->size() > 2
1960 && ( *tokenIt )[0] == QChar(
'\'' )
1961 && ( *tokenIt )[tokenIt->size() - 1] == QChar(
'\'' )
1962 && ( *tokenIt )[1] != QChar(
'\'' )
1963 && ( *tokenIt )[tokenIt->size() - 2] != QChar(
'\'' ) )
1969 if ( tokenIt->size() > 2
1970 && ( *tokenIt )[0] == QChar(
'"' )
1971 && ( *tokenIt )[tokenIt->size() - 1] == QChar(
'"' )
1972 && ( *tokenIt )[1] != QChar(
'"' )
1973 && ( *tokenIt )[tokenIt->size() - 2] != QChar(
'"' ) )
1984 void QgsRenderer::groupStringList( QStringList &list,
const QString &groupString )
1987 bool groupActive =
false;
1988 int startGroup = -1;
1989 QString concatString;
1991 for (
int i = 0; i < list.size(); ++i )
1993 QString &str = list[i];
1994 if ( str.startsWith( groupString ) )
1998 concatString.clear();
2003 if ( i != startGroup )
2005 concatString.append(
" " );
2007 concatString.append( str );
2010 if ( str.endsWith( groupString ) )
2013 groupActive =
false;
2015 if ( startGroup != -1 )
2017 list[startGroup] = concatString;
2018 for (
int j = startGroup + 1; j <= endGroup; ++j )
2020 list.removeAt( startGroup + 1 );
2025 concatString.clear();
2031 bool QgsRenderer::checkMaximumWidthHeight()
const 2035 int width = this->width();
2036 if ( wmsMaxWidth != -1 && width > wmsMaxWidth )
2042 int height = this->height();
2043 if ( wmsMaxHeight != -1 && height > wmsMaxHeight )
2056 switch ( mWmsParameters.
format() )
2058 case QgsWmsParameters::Format::JPG:
2064 const int bytes_per_line = ( ( width * depth + 31 ) >> 5 ) << 2;
2066 if ( std::numeric_limits<int>::max() / depth < static_cast<uint>( width )
2067 || bytes_per_line <= 0
2069 || std::numeric_limits<int>::max() /
static_cast<uint
>( bytes_per_line ) < static_cast<uint>( height )
2070 || std::numeric_limits<int>::max() /
sizeof( uchar * ) < static_cast<uint>( height ) )
2076 void QgsRenderer::convertFeatureInfoToSia2045( QDomDocument &doc )
const 2078 QDomDocument SIAInfoDoc;
2079 QDomElement infoDocElement = doc.documentElement();
2080 QDomElement SIAInfoDocElement = SIAInfoDoc.importNode( infoDocElement,
false ).toElement();
2081 SIAInfoDoc.appendChild( SIAInfoDocElement );
2083 QString currentAttributeName;
2084 QString currentAttributeValue;
2085 QDomElement currentAttributeElem;
2086 QString currentLayerName;
2087 QDomElement currentLayerElem;
2088 QDomNodeList layerNodeList = infoDocElement.elementsByTagName( QStringLiteral(
"Layer" ) );
2089 for (
int i = 0; i < layerNodeList.size(); ++i )
2091 currentLayerElem = layerNodeList.at( i ).toElement();
2092 currentLayerName = currentLayerElem.attribute( QStringLiteral(
"name" ) );
2094 QDomElement currentFeatureElem;
2096 QDomNodeList featureList = currentLayerElem.elementsByTagName( QStringLiteral(
"Feature" ) );
2097 if ( featureList.isEmpty() )
2100 QDomNodeList attributeList = currentLayerElem.elementsByTagName( QStringLiteral(
"Attribute" ) );
2101 QDomElement rasterLayerElem;
2102 if ( !attributeList.isEmpty() )
2104 rasterLayerElem = SIAInfoDoc.createElement( currentLayerName );
2106 for (
int j = 0; j < attributeList.size(); ++j )
2108 currentAttributeElem = attributeList.at( j ).toElement();
2109 currentAttributeName = currentAttributeElem.attribute( QStringLiteral(
"name" ) );
2110 currentAttributeValue = currentAttributeElem.attribute( QStringLiteral(
"value" ) );
2111 QDomElement outAttributeElem = SIAInfoDoc.createElement( currentAttributeName );
2112 QDomText outAttributeText = SIAInfoDoc.createTextNode( currentAttributeValue );
2113 outAttributeElem.appendChild( outAttributeText );
2114 rasterLayerElem.appendChild( outAttributeElem );
2116 if ( !attributeList.isEmpty() )
2118 SIAInfoDocElement.appendChild( rasterLayerElem );
2124 QSet<QString> layerPropertyAttributes;
2125 QString currentLayerId = currentLayerElem.attribute( QStringLiteral(
"id" ) );
2126 if ( !currentLayerId.isEmpty() )
2131 QString WMSPropertyAttributesString = currentLayer->
customProperty( QStringLiteral(
"WMSPropertyAttributes" ) ).toString();
2132 if ( !WMSPropertyAttributesString.isEmpty() )
2134 QStringList propertyList = WMSPropertyAttributesString.split( QStringLiteral(
"//" ) );
2135 for (
auto propertyIt = propertyList.constBegin() ; propertyIt != propertyList.constEnd(); ++propertyIt )
2137 layerPropertyAttributes.insert( *propertyIt );
2143 QDomElement propertyRefChild;
2144 for (
int j = 0; j < featureList.size(); ++j )
2146 QDomElement SIAFeatureElem = SIAInfoDoc.createElement( currentLayerName );
2147 currentFeatureElem = featureList.at( j ).toElement();
2148 QDomNodeList attributeList = currentFeatureElem.elementsByTagName( QStringLiteral(
"Attribute" ) );
2150 for (
int k = 0; k < attributeList.size(); ++k )
2152 currentAttributeElem = attributeList.at( k ).toElement();
2153 currentAttributeName = currentAttributeElem.attribute( QStringLiteral(
"name" ) );
2154 currentAttributeValue = currentAttributeElem.attribute( QStringLiteral(
"value" ) );
2155 if ( layerPropertyAttributes.contains( currentAttributeName ) )
2157 QDomElement propertyElem = SIAInfoDoc.createElement( QStringLiteral(
"property" ) );
2158 QDomElement identifierElem = SIAInfoDoc.createElement( QStringLiteral(
"identifier" ) );
2159 QDomText identifierText = SIAInfoDoc.createTextNode( currentAttributeName );
2160 identifierElem.appendChild( identifierText );
2161 QDomElement valueElem = SIAInfoDoc.createElement( QStringLiteral(
"value" ) );
2162 QDomText valueText = SIAInfoDoc.createTextNode( currentAttributeValue );
2163 valueElem.appendChild( valueText );
2164 propertyElem.appendChild( identifierElem );
2165 propertyElem.appendChild( valueElem );
2166 if ( propertyRefChild.isNull() )
2168 SIAFeatureElem.insertBefore( propertyElem, QDomNode() );
2169 propertyRefChild = propertyElem;
2173 SIAFeatureElem.insertAfter( propertyElem, propertyRefChild );
2178 QDomElement SIAAttributeElem = SIAInfoDoc.createElement( currentAttributeName );
2179 QDomText SIAAttributeText = SIAInfoDoc.createTextNode( currentAttributeValue );
2180 SIAAttributeElem.appendChild( SIAAttributeText );
2181 SIAFeatureElem.appendChild( SIAAttributeElem );
2184 SIAInfoDocElement.appendChild( SIAFeatureElem );
2191 QByteArray QgsRenderer::convertFeatureInfoToHtml(
const QDomDocument &doc )
const 2193 QString featureInfoString;
2196 featureInfoString.append(
"<HEAD>\n" );
2197 featureInfoString.append(
"<TITLE> GetFeatureInfo results </TITLE>\n" );
2198 featureInfoString.append(
"<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">\n" );
2199 featureInfoString.append(
"</HEAD>\n" );
2202 featureInfoString.append(
"<BODY>\n" );
2204 QDomNodeList layerList = doc.elementsByTagName( QStringLiteral(
"Layer" ) );
2207 for (
int i = 0; i < layerList.size(); ++i )
2209 QDomElement layerElem = layerList.at( i ).toElement();
2211 featureInfoString.append(
"<TABLE border=1 width=100%>\n" );
2212 featureInfoString.append(
"<TR><TH width=25%>Layer</TH><TD>" + layerElem.attribute( QStringLiteral(
"name" ) ) +
"</TD></TR>\n" );
2213 featureInfoString.append(
"</BR>" );
2216 QDomNodeList featureNodeList = layerElem.elementsByTagName( QStringLiteral(
"Feature" ) );
2217 QDomElement currentFeatureElement;
2219 if ( !featureNodeList.isEmpty() )
2221 for (
int j = 0; j < featureNodeList.size(); ++j )
2223 QDomElement featureElement = featureNodeList.at( j ).toElement();
2224 featureInfoString.append(
"<TABLE border=1 width=100%>\n" );
2225 featureInfoString.append(
"<TR><TH>Feature</TH><TD>" + featureElement.attribute( QStringLiteral(
"id" ) ) +
2229 QDomNodeList attributeNodeList = featureElement.elementsByTagName( QStringLiteral(
"Attribute" ) );
2230 for (
int k = 0; k < attributeNodeList.size(); ++k )
2232 QDomElement attributeElement = attributeNodeList.at( k ).toElement();
2233 featureInfoString.append(
"<TR><TH>" + attributeElement.attribute( QStringLiteral(
"name" ) ) +
2234 "</TH><TD>" + attributeElement.attribute( QStringLiteral(
"value" ) ) +
"</TD></TR>\n" );
2237 featureInfoString.append(
"</TABLE>\n</BR>\n" );
2242 QDomNodeList attributeNodeList = layerElem.elementsByTagName( QStringLiteral(
"Attribute" ) );
2243 for (
int j = 0; j < attributeNodeList.size(); ++j )
2245 QDomElement attributeElement = attributeNodeList.at( j ).toElement();
2246 featureInfoString.append(
"<TR><TH>" + attributeElement.attribute( QStringLiteral(
"name" ) ) +
2247 "</TH><TD>" + attributeElement.attribute( QStringLiteral(
"value" ) ) +
"</TD></TR>\n" );
2251 featureInfoString.append(
"</TABLE>\n<BR></BR>\n" );
2255 featureInfoString.append(
"</BODY>\n" );
2257 return featureInfoString.toUtf8();
2260 QByteArray QgsRenderer::convertFeatureInfoToText(
const QDomDocument &doc )
const 2262 QString featureInfoString;
2265 featureInfoString.append(
"GetFeatureInfo results\n" );
2266 featureInfoString.append(
"\n" );
2268 QDomNodeList layerList = doc.elementsByTagName( QStringLiteral(
"Layer" ) );
2271 for (
int i = 0; i < layerList.size(); ++i )
2273 QDomElement layerElem = layerList.at( i ).toElement();
2275 featureInfoString.append(
"Layer '" + layerElem.attribute( QStringLiteral(
"name" ) ) +
"'\n" );
2278 QDomNodeList featureNodeList = layerElem.elementsByTagName( QStringLiteral(
"Feature" ) );
2279 QDomElement currentFeatureElement;
2281 if ( !featureNodeList.isEmpty() )
2283 for (
int j = 0; j < featureNodeList.size(); ++j )
2285 QDomElement featureElement = featureNodeList.at( j ).toElement();
2286 featureInfoString.append(
"Feature " + featureElement.attribute( QStringLiteral(
"id" ) ) +
"\n" );
2289 QDomNodeList attributeNodeList = featureElement.elementsByTagName( QStringLiteral(
"Attribute" ) );
2290 for (
int k = 0; k < attributeNodeList.size(); ++k )
2292 QDomElement attributeElement = attributeNodeList.at( k ).toElement();
2293 featureInfoString.append( attributeElement.attribute( QStringLiteral(
"name" ) ) +
" = '" +
2294 attributeElement.attribute( QStringLiteral(
"value" ) ) +
"'\n" );
2300 QDomNodeList attributeNodeList = layerElem.elementsByTagName( QStringLiteral(
"Attribute" ) );
2301 for (
int j = 0; j < attributeNodeList.size(); ++j )
2303 QDomElement attributeElement = attributeNodeList.at( j ).toElement();
2304 featureInfoString.append( attributeElement.attribute( QStringLiteral(
"name" ) ) +
" = '" +
2305 attributeElement.attribute( QStringLiteral(
"value" ) ) +
"'\n" );
2309 featureInfoString.append(
"\n" );
2312 return featureInfoString.toUtf8();
2315 QDomElement QgsRenderer::createFeatureGML(
2324 QStringList *attributes )
const 2327 QDomElement typeNameElement = doc.createElement(
"qgs:" + typeName );
2328 typeNameElement.setAttribute( QStringLiteral(
"fid" ), typeName +
"." + QString::number( feat->
id() ) );
2331 if ( layer && layer->
crs() !=
crs )
2354 box = transformedBox;
2362 QDomElement bbElem = doc.createElement( QStringLiteral(
"gml:boundedBy" ) );
2363 QDomElement boxElem;
2375 boxElem.setAttribute( QStringLiteral(
"srsName" ), crs.
authid() );
2377 bbElem.appendChild( boxElem );
2378 typeNameElement.appendChild( bbElem );
2381 if ( withGeom && !geom.
isNull() )
2390 QDomElement geomElem = doc.createElement( QStringLiteral(
"qgs:geometry" ) );
2391 QDomElement gmlElem;
2401 if ( !gmlElem.isNull() )
2405 gmlElem.setAttribute( QStringLiteral(
"srsName" ), crs.
authid() );
2407 geomElem.appendChild( gmlElem );
2408 typeNameElement.appendChild( geomElem );
2415 for (
int i = 0; i < fields.
count(); ++i )
2417 QString attributeName = fields.
at( i ).
name();
2424 if ( attributes && !attributes->contains( attributeName ) )
2429 QDomElement fieldElem = doc.createElement(
"qgs:" + attributeName.replace(
' ',
'_' ) );
2430 QString fieldTextString = featureAttributes.at( i ).toString();
2435 QDomText fieldText = doc.createTextNode( fieldTextString );
2436 fieldElem.appendChild( fieldText );
2437 typeNameElement.appendChild( fieldElem );
2445 if ( !mapTip.isEmpty() && mWmsParameters.
withMapTip() )
2448 QDomElement fieldElem = doc.createElement( QStringLiteral(
"qgs:maptip" ) );
2449 QDomText maptipText = doc.createTextNode( fieldTextString );
2450 fieldElem.appendChild( maptipText );
2451 typeNameElement.appendChild( fieldElem );
2455 return typeNameElement;
2458 QString QgsRenderer::replaceValueMapAndRelation(
QgsVectorLayer *vl,
int idx,
const QVariant &attributeVal )
2462 QString value( fieldFormatter->
representValue( vl, idx, setup.
config(), QVariant(), attributeVal ) );
2464 if ( setup.
config().value( QStringLiteral(
"AllowMulti" ) ).toBool() && value.startsWith( QLatin1String(
"{" ) ) && value.endsWith( QLatin1String(
"}" ) ) )
2466 value = value.mid( 1, value.size() - 2 );
2482 return imageQuality;
2493 if ( WMSPrecisionParameter > -1 )
2494 return WMSPrecisionParameter;
2496 return WMSPrecision;
2506 double mapUnitTolerance = 0.0;
2516 mapUnitTolerance = mapSettings.
extent().
width() / 400.0;
2528 mapUnitTolerance = mapSettings.
extent().
width() / 200.0;
2540 mapUnitTolerance = mapSettings.
extent().
width() / 100.0;
2544 QgsRectangle mapRectangle( infoPoint.
x() - mapUnitTolerance, infoPoint.
y() - mapUnitTolerance,
2545 infoPoint.
x() + mapUnitTolerance, infoPoint.
y() + mapUnitTolerance );
2550 void QgsRenderer::initRestrictedLayers()
2552 mRestrictedLayers.clear();
2558 QStringList restrictedLayersNames;
2561 for (
const QString &l : restricted )
2566 QList<QgsLayerTreeLayer *> groupLayers = group->
findLayers();
2569 restrictedLayersNames.append( treeLayer->name() );
2574 restrictedLayersNames.append( l );
2579 QList<QgsLayerTreeLayer *> layers = root->
findLayers();
2582 if ( restrictedLayersNames.contains( layer->
name() ) )
2584 mRestrictedLayers.append( layerNickname( *layer->layer() ) );
2589 void QgsRenderer::initNicknameLayers()
2593 mNicknameLayers[ layerNickname( *ml ) ] = ml;
2599 initLayerGroupsRecursive( root, rootName.isEmpty() ? mProject->
title() : rootName );
2602 void QgsRenderer::initLayerGroupsRecursive(
const QgsLayerTreeGroup *group,
const QString &groupName )
2604 if ( !groupName.isEmpty() )
2606 mLayerGroups[groupName] = QList<QgsMapLayer *>();
2607 const auto projectLayerTreeRoot { mProject->
layerTreeRoot() };
2608 const auto treeGroupLayers { group->
findLayers() };
2611 if ( ! projectLayerTreeRoot->hasCustomLayerOrder() )
2613 for (
const auto &tl : treeGroupLayers )
2615 mLayerGroups[groupName].push_back( tl->layer() );
2620 const auto projectLayerOrder { projectLayerTreeRoot->layerOrder() };
2622 QList<QgsMapLayer *> groupLayersList;
2623 for (
const auto &tl : treeGroupLayers )
2625 groupLayersList << tl->layer();
2627 for (
const auto &l : projectLayerOrder )
2629 if ( groupLayersList.contains( l ) )
2631 mLayerGroups[groupName].push_back( l );
2641 QString name = child->customProperty( QStringLiteral(
"wmsShortName" ) ).toString();
2643 if ( name.isEmpty() )
2644 name = child->name();
2646 initLayerGroupsRecursive( static_cast<const QgsLayerTreeGroup *>( child ), name );
2652 QString QgsRenderer::layerNickname(
const QgsMapLayer &layer )
const 2659 else if ( name.isEmpty() )
2661 name = layer.
name();
2667 bool QgsRenderer::layerScaleVisibility(
const QgsMapLayer &layer,
double scaleDenominator )
const 2669 bool visible =
false;
2671 bool useScaleConstraint = ( scaleDenominator > 0 && scaleBasedVisibility );
2673 if ( !useScaleConstraint || layer.
isInScaleRange( scaleDenominator ) )
2681 QList<QgsMapLayer *> QgsRenderer::highlightLayers( QList<QgsWmsParametersHighlightLayer> params )
2683 QList<QgsMapLayer *> highlightLayers;
2686 QString crs = mWmsParameters.
crs();
2690 QDomDocument sldDoc;
2691 if ( !sldDoc.setContent( param.mSld,
true ) )
2698 std::unique_ptr<QgsFeatureRenderer> renderer;
2699 QDomElement el = sldDoc.documentElement();
2709 QString url = typeName +
"?crs=" +
crs;
2710 if ( ! param.mLabel.isEmpty() )
2712 url +=
"&field=label:string";
2716 std::unique_ptr<QgsVectorLayer> layer;
2718 if ( !layer->isValid() )
2725 if ( ! param.mLabel.isEmpty() )
2736 switch ( param.mGeom.type() )
2741 palSettings.
dist = 2;
2752 QVariant x( pt.
x() );
2756 QVariant y( pt.
y() );
2760 QVariant hali(
"Center" );
2764 QVariant vali(
"Half" );
2771 palSettings.
dist = 2;
2780 if ( param.mColor.isValid() )
2782 textFormat.
setColor( param.mColor );
2785 if ( param.mSize > 0 )
2787 textFormat.
setSize( param.mSize );
2795 if ( ! param.mFont.isEmpty() )
2797 textFormat.
setFont( param.mFont );
2800 if ( param.mBufferColor.isValid() )
2802 bufferSettings.
setColor( param.mBufferColor );
2805 if ( param.mBufferSize > 0 )
2808 bufferSettings.
setSize( param.mBufferSize );
2815 layer->setLabeling( simpleLabeling );
2816 layer->setLabelsEnabled(
true );
2818 fet.setGeometry( param.mGeom );
2822 layer->setRenderer( renderer.release() );
2825 if ( layer->isValid() )
2827 highlightLayers.append( layer.release() );
2831 mTemporaryLayers.append( highlightLayers );
2832 return highlightLayers;
2835 QList<QgsMapLayer *> QgsRenderer::sldStylizedLayers(
const QString &sld )
const 2837 QList<QgsMapLayer *> layers;
2839 if ( !sld.isEmpty() )
2842 ( void )doc.setContent( sld,
true );
2843 QDomElement docEl = doc.documentElement();
2845 QDomElement root = doc.firstChildElement(
"StyledLayerDescriptor" );
2846 QDomElement namedElem = root.firstChildElement(
"NamedLayer" );
2848 if ( !docEl.isNull() )
2850 QDomNodeList named = docEl.elementsByTagName(
"NamedLayer" );
2851 for (
int i = 0; i < named.size(); ++i )
2853 QDomNodeList names = named.item( i ).toElement().elementsByTagName(
"Name" );
2854 if ( !names.isEmpty() )
2856 QString lname = names.item( 0 ).toElement().text();
2858 if ( mNicknameLayers.contains( lname ) && !mRestrictedLayers.contains( lname ) )
2860 mNicknameLayers[lname]->readSld( namedElem, err );
2861 mNicknameLayers[lname]->setCustomProperty(
"readSLD",
true );
2862 layers.append( mNicknameLayers[lname] );
2864 else if ( mLayerGroups.contains( lname ) )
2868 if ( !mRestrictedLayers.contains( layerNickname( *layer ) ) )
2870 layer->
readSld( namedElem, err );
2872 layers.insert( 0, layer );
2879 QStringLiteral(
"Layer \"%1\" does not exist" ).arg( lname ) );
2889 QList<QgsMapLayer *> QgsRenderer::stylizedLayers(
const QList<QgsWmsParametersLayer> ¶ms )
2891 QList<QgsMapLayer *> layers;
2895 QString nickname = param.mNickname;
2896 QString style = param.mStyle;
2897 if ( nickname.startsWith(
"EXTERNAL_WMS:" ) )
2899 QString externalLayerId = nickname;
2900 externalLayerId.remove( 0, 13 );
2901 QgsMapLayer *externalWMSLayer = createExternalWMSLayer( externalLayerId );
2902 if ( externalWMSLayer )
2904 layers.append( externalWMSLayer );
2905 mNicknameLayers[nickname] = externalWMSLayer;
2906 mTemporaryLayers.append( externalWMSLayer );
2909 else if ( mNicknameLayers.contains( nickname ) && !mRestrictedLayers.contains( nickname ) )
2911 if ( !style.isEmpty() )
2913 bool rc = mNicknameLayers[nickname]->styleManager()->setCurrentStyle( style );
2916 throw QgsMapServiceException( QStringLiteral(
"StyleNotDefined" ), QStringLiteral(
"Style \"%1\" does not exist for layer \"%2\"" ).arg( style, nickname ) );
2920 layers.append( mNicknameLayers[nickname] );
2922 else if ( mLayerGroups.contains( nickname ) )
2925 QList<QgsMapLayer *> layersFromGroup;
2926 for (
QgsMapLayer *layer : mLayerGroups[nickname] )
2928 if ( !mRestrictedLayers.contains( layerNickname( *layer ) ) )
2930 if ( !style.isEmpty() )
2935 throw QgsMapServiceException( QStringLiteral(
"StyleNotDefined" ), QStringLiteral(
"Style \"%1\" does not exist for layer \"%2\"" ).arg( style, layerNickname( *layer ) ) );
2938 layersFromGroup.push_front( layer );
2941 layers.append( layersFromGroup );
2946 QStringLiteral(
"Layer \"%1\" does not exist" ).arg( nickname ) );
2953 QgsMapLayer *QgsRenderer::createExternalWMSLayer(
const QString &externalLayerId )
const 2955 QString wmsUri = mWmsParameters.
externalWMSUri( externalLayerId.toUpper() );
2966 void QgsRenderer::removeTemporaryLayers()
2968 qDeleteAll( mTemporaryLayers );
2969 mTemporaryLayers.clear();
2972 QPainter *QgsRenderer::layersRendering(
const QgsMapSettings &mapSettings, QImage &image,
HitTest *hitTest )
const 2974 QPainter *painter =
nullptr;
2977 runHitTest( mapSettings, *hitTest );
2978 painter =
new QPainter();
2984 #ifdef HAVE_SERVER_PYTHON_PLUGINS 2985 mAccessControl->resolveFilterFeatures( mapSettings.
layers() );
2989 renderJob.
render( mapSettings, &image );
2990 painter = renderJob.takePainter();
2996 void QgsRenderer::setLayerOpacity(
QgsMapLayer *layer,
int opacity )
const 2998 if ( opacity >= 0 && opacity <= 255 )
3000 if ( layer->
type() == QgsMapLayer::LayerType::VectorLayer )
3005 else if ( layer->
type() == QgsMapLayer::LayerType::RasterLayer )
3009 rasterRenderer->
setOpacity( opacity / 255. );
3014 void QgsRenderer::setLayerFilter(
QgsMapLayer *layer,
const QList<QgsWmsParametersFilter> &filters )
3024 QDomDocument filterXml;
3026 if ( !filterXml.setContent( filter.mFilter,
true, &errorMsg ) )
3029 QStringLiteral(
"error message: %1. The XML string was: %2" ).arg( errorMsg, filter.mFilter ) );
3031 QDomElement filterElem = filterXml.firstChildElement();
3036 mFeatureFilter.
setFilter( filteredLayer, *expression );
3042 if ( !testFilterStringSafety( filter.mFilter ) )
3045 QStringLiteral(
"The filter string %1" 3046 " has been rejected because of security reasons." 3047 " Note: Text strings have to be enclosed in single or double quotes." 3048 " A space between each word / special character is mandatory." 3049 " Allowed Keywords and special characters are " 3050 " IS,NOT,NULL,AND,OR,IN,=,<,>=,>,>=,!=,',',(,),DMETAPHONE,SOUNDEX." 3051 " Not allowed are semicolons in the filter expression." ).arg(
3055 QString newSubsetString = filter.mFilter;
3058 newSubsetString.prepend(
") AND (" );
3059 newSubsetString.append(
")" );
3060 newSubsetString.prepend( filteredLayer->
subsetString() );
3061 newSubsetString.prepend(
"(" );
3069 void QgsRenderer::setLayerSelection(
QgsMapLayer *layer,
const QStringList &fids )
const 3075 for (
const QString &
id : fids )
3085 void QgsRenderer::setLayerAccessControlFilter(
QgsMapLayer *layer )
const 3087 #ifdef HAVE_SERVER_PYTHON_PLUGINS 3105 void QgsRenderer::annotationsRendering( QPainter *painter )
const 3108 const QList< QgsAnnotation * > annotations = annotationManager->
annotations();
3113 if ( !annotation || !annotation->isVisible() )
3116 annotation->render( renderContext );
3120 QImage *QgsRenderer::scaleImage(
const QImage *image )
const 3125 QImage *scaledImage =
nullptr;
3126 int width = this->width();
3127 int height = this->height();
3128 if ( width != image->width() || height != image->height() )
3130 scaledImage =
new QImage( image->scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
3136 void QgsRenderer::checkLayerReadPermissions(
QgsMapLayer *layer )
const 3138 #ifdef HAVE_SERVER_PYTHON_PLUGINS 3139 if ( !mAccessControl->layerReadPermission( layer ) )
3141 throw QgsSecurityException( QStringLiteral(
"You are not allowed to access to the layer: %1" ).arg( layer->
name() ) );
3148 void QgsRenderer::removeUnwantedLayers( QList<QgsMapLayer *> &layers,
double scaleDenominator )
const 3150 QList<QgsMapLayer *> wantedLayers;
3154 if ( !layerScaleVisibility( *layer, scaleDenominator ) )
3157 if ( mRestrictedLayers.contains( layerNickname( *layer ) ) )
3160 wantedLayers.append( layer );
3163 layers = wantedLayers;
3166 void QgsRenderer::removeNonIdentifiableLayers( QList<QgsMapLayer *> &layers )
const 3168 QList<QgsMapLayer *>::iterator it = layers.begin();
3169 while ( it != layers.end() )
3172 it = layers.erase( it );
3178 QgsLayerTreeModel *QgsRenderer::buildLegendTreeModel(
const QList<QgsMapLayer *> &layers,
double scaleDenominator,
QgsLayerTree &rootGroup )
3185 bool ruleDefined =
false;
3186 if ( !mWmsParameters.
rule().isEmpty() )
3189 bool contentBasedLegend =
false;
3191 if ( ! mWmsParameters.
bbox().isEmpty() )
3193 contentBasedLegend =
true;
3195 if ( contentBasedLegendExtent.
isEmpty() )
3197 QStringLiteral(
"Invalid BBOX parameter" ) );
3199 if ( !mWmsParameters.
rule().isEmpty() )
3201 QStringLiteral(
"BBOX parameter cannot be combined with RULE" ) );
3206 QList<QgsVectorLayerFeatureCounter *> counters;
3210 lt->
setCustomProperty( QStringLiteral(
"showFeatureCount" ), showFeatureCount );
3212 if ( !ml->
title().isEmpty() )
3222 counters.append( counter );
3227 if ( scaleDenominator > 0 )
3231 if ( contentBasedLegend )
3234 getMap( contentBasedMapSettings, &hitTest );
3245 const SymbolSet &usedSymbols = hitTest[vl];
3251 if ( usedSymbols.contains( sProp ) )
3257 if ( order.isEmpty() )
3268 if ( ! ruleDefined )
3270 QList<QgsLayerTreeNode *> rootChildren = rootGroup.
children();
3281 if ( !drawLegendItemLabel )
3285 legendNode->setUserLabel( QStringLiteral(
" " ) );
3288 else if ( !drawLegendLayerLabel )
3292 if ( legendNode->isEmbeddedInParent() )
3293 legendNode->setEmbeddedInParent(
false );
3302 c->waitForFinished();
3308 qreal QgsRenderer::dotsPerMm()
const 3310 std::unique_ptr<QImage> tmpImage( createImage( 1, 1,
false ) );
3311 return tmpImage->dotsPerMeterX() / 1000.0;
3314 QStringList QgsRenderer::flattenedQueryLayers()
const 3317 std::function <QStringList( const QString &name )> findLeaves = [ & ](
const QString & name ) -> QStringList
3319 QStringList _result;
3320 if ( mLayerGroups.contains( name ) )
3322 const auto &layers { mLayerGroups[ name ] };
3323 for (
const auto &l : layers )
3325 const auto nick { layerNickname( *l ) };
3326 if ( mLayerGroups.contains( nick ) )
3328 _result.append( name );
3332 _result.append( findLeaves( nick ) );
3338 _result.append( name );
3343 for (
const auto &name : constNicks )
3345 result.append( findLeaves( name ) );
3350 int QgsRenderer::height()
const 3352 if ( ( mWmsParameters.
request().compare( QStringLiteral(
"GetLegendGraphic" ), Qt::CaseInsensitive ) == 0 ||
3353 mWmsParameters.
request().compare( QStringLiteral(
"GetLegendGraphics" ), Qt::CaseInsensitive ) == 0 ) &&
3359 int QgsRenderer::width()
const 3361 if ( ( mWmsParameters.
request().compare( QStringLiteral(
"GetLegendGraphic" ), Qt::CaseInsensitive ) == 0 ||
3362 mWmsParameters.
request().compare( QStringLiteral(
"GetLegendGraphics" ), Qt::CaseInsensitive ) == 0 ) &&
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
QgsPrintLayout * clone() const override
Creates a clone of the layout.
static void setNodeLegendStyle(QgsLayerTreeNode *node, QgsLegendStyle::Style style)
QByteArray getFeatureInfo(const QString &version="1.3.0")
Creates an xml document that describes the result of the getFeatureInfo request.
int pageCount() const
Returns the number of pages in the collection.
void updateFields()
Will regenerate the fields property of this layer by obtaining all fields from the dataProvider...
Layer tree group node serves as a container for layers and further groups.
bool isValid() const
Returns true if valid.
Wrapper for iterator of features from vector data provider or vector layer.
A container for features with the same fields and crs.
int widthAsInt() const
Returns WIDTH parameter as an int or its default value if not defined.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
void removeChildrenGroupWithoutLayers()
Remove all child group nodes without layers.
May use more than one symbol to render a feature: symbolsForFeature() will return them...
static QgsLayerTreeLayer * toLayer(QgsLayerTreeNode *node)
Cast node to a layer.
A rectangle specified with double values.
Base class for all map layer types.
void setExtent(const QgsRectangle &rect, bool magnified=true)
Set coordinates of the rectangle which should be rendered.
QgsGeometry pointOnSurface() const
Returns a point guaranteed to lie on the surface of a geometry.
QString title() const
Returns the project's title.
bool isEmpty() const
Returns true if the rectangle is empty.
static void setLegendNodeOrder(QgsLayerTreeLayer *nodeLayer, const QList< int > &order)
QgsVectorLayerFeatureCounter * countSymbolFeatures()
Count features for symbols.
const Flags & flags() const
Item model implementation based on layer tree model for layout legend.
QString sldBody() const
Returns SLD_body if defined or an empty string.
SERVER_EXPORT int wmsMaxWidth(const QgsProject &project)
Returns the maximum width for WMS images defined in a QGIS project.
QSet< QgsFeatureId > QgsFeatureIds
QgsMapLayer::LayerType type() const
Returns the type of the layer.
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters.
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
bool isValid() const
Returns the status of the layer.
QList< QgsAnnotation * > annotations() const
Returns a list of all annotations contained in the manager.
QgsLayerTree * rootGroup() const
Returns pointer to the root node of the layer tree. Always a non-null pointer.
double scale() const
Returns the calculated map scale.
void setFields(const QgsFields &fields, bool initAttributes=false)
Assign a field map with the feature to allow attribute access by attribute name.
Manages storage of a set of QgsAnnotation annotation objects.
bool isNull() const
Returns true if the geometry is null (ie, contains no underlying geometry accessible via geometry() )...
Abstract base class for all rendered symbols.
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
Use exact geometry intersection (slower) instead of bounding boxes.
QgsPointXY layerToMapCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from layer's CRS to output CRS
virtual QgsAttributeList pkAttributeIndexes() const
Returns list of indexes of fields that make up the primary key.
A layout item subclass for text labels.
void setCoordinateTransform(const QgsCoordinateTransform &t)
Sets the current coordinate transform for the context.
QStringList queryLayersNickname() const
Returns nickname of layers found in QUERY_LAYERS parameter.
int getWMSPrecision() const
Returns the precision to use for 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...
ExportResult exportToImage(const QString &filePath, const QgsLayoutExporter::ImageExportSettings &settings)
Exports the layout to the filePath, using the specified export settings.
SERVER_EXPORT QString getServerFid(const QgsFeature &feature, const QgsAttributeList &pkAttributes)
Returns the feature id based on primary keys.
void render(const QgsMapSettings &mapSettings, QImage *image)
Sequential or parallel map rendering.
QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
QgsMapLayer * layer() const
Returns the map layer associated with this node.
int wmsPrecisionAsInt() const
Returns WMS_PRECISION parameter as an int or its default value if not defined.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
QList< QgsWmsParametersLayer > mLayers
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
QList< QgsFeatureStore > QgsFeatureStoreList
QColor selectionColor() const
Gets color that is used for drawing of selected vector features.
QList< QgsFeature > QgsFeatureList
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
Counts the features in a QgsVectorLayer in task.
void setSize(double size)
Sets the size of the buffer.
A class to represent a 2D point.
QgsEditorWidgetSetup editorWidgetSetup(int index) const
The editor widget setup defines which QgsFieldFormatter and editor widget will be used for the field ...
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
bool contains(const QgsRectangle &rect) const
Returns true when rectangle contains other rectangle.
void setFont(const QFont &font)
Sets the font used for rendering text.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QgsWkbTypes::Type wkbType() const
Returns the WKB type of the geometry.
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
SERVER_EXPORT QString wmsFeatureInfoDocumentElement(const QgsProject &project)
Returns the document element name for XML GetFeatureInfo request.
double length() const
Returns the length of the measurement.
void layoutObjects(QList< T * > &objectList) const
Returns a list of layout objects (items and multiframes) of a specific type.
void setOutputDpi(double dpi)
Sets DPI used for conversion between real world units (e.g. mm) and pixels.
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
QString j() const
Returns J parameter or an empty string if not defined.
QgsRenderer(QgsServerInterface *serverIface, const QgsProject *project, QgsWmsParameters ¶meters)
Constructor.
X-coordinate data defined label position.
Container of fields for a vector layer.
SERVER_EXPORT QHash< QString, QString > wmsFeatureInfoLayerAliasMap(const QgsProject &project)
Returns the mapping between layer name and wms layer name for GetFeatureInfo request.
A geometry is the spatial representation of a feature.
void selectByIds(const QgsFeatureIds &ids, SelectBehavior behavior=SetSelection)
Select matching features using a list of feature IDs.
SERVER_EXPORT bool wmsInfoFormatSia2045(const QgsProject &project)
Returns if the info format is SIA20145.
bool setAttribute(int field, const QVariant &attr)
Set an attribute's value by field index.
void removeChildNode(QgsLayerTreeNode *node)
Remove a child node from this group.
Format
Output format for the response.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
QgsUnitTypes::DistanceUnit mapUnits
static QDomElement rectangleToGMLBox(QgsRectangle *box, QDomDocument &doc, int precision=17)
Exports the rectangle to GML2 Box.
QgsPointXY mapToLayerCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from output CRS to layer's CRS
void setSymbologyExport(QgsDxfExport::SymbologyExport e)
Set symbology export mode.
bool withGeometry() const
Returns if the client wants the feature info response with geometry information.
void setMapUnitsPerPixel(double mapUnitsPerPixel)
Sets the mMmPerMapUnit calculated by mapUnitsPerPixel mostly taken from the map settings.
QStringList filters() const
Returns the list of filters found in FILTER parameter.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
Exception thrown in case of malformed request.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsCoordinateTransform layerTransform(const QgsMapLayer *layer) const
Returns the coordinate transform from layer's CRS to destination CRS.
bool ruleLabelAsBool() const
Returns RULELABEL as a bool.
Layers and optional attribute index to split into multiple layers using attribute value as layer name...
const QgsCoordinateReferenceSystem & crs
RAII class to restore layer configuration on destruction (opacity, filters, ...)
QString crs() const
Returns CRS or an empty string if none is defined.
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
QgsLayoutRenderContext & renderContext()
Returns a reference to the layout's render context, which stores information relating to the current ...
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
bool layerTitleAsBool() const
Returns LAYERTITLE as a bool or its default value if not defined.
QPainter * painter
Painter.
QMap< int, QVariant > results() const
Returns the identify results.
QString dpi() const
Returns DPI parameter or an empty string if not defined.
QList< int > pages
List of specific pages to export, or an empty list to export all pages.
int xAsInt() const
Returns X parameter as an int or its default value if not defined.
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
QgsLayerTreeLayer * addLayer(QgsMapLayer *layer)
Append a new layer node for given map layer.
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
Abstract base class for annotation items which are drawn over a map.
QString bbox() const
Returns BBOX if defined or an empty string.
The QgsMapSettings class contains configuration for rendering of the map.
void layoutItems(QList< T * > &itemList) const
Returns a list of layout items of a specific type.
SERVER_EXPORT bool wmsFeatureInfoAddWktGeometry(const QgsProject &project)
Returns if the geometry is displayed as Well Known Text in GetFeatureInfo request.
Raster identify results container.
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
QList< QgsMapLayer * > layers() const
Gets list of layers for map rendering The layers are stored in the reverse order of how they are rend...
void dump() const
Dumps parameters.
QImage * getMap(HitTest *hitTest=nullptr)
Returns the map as an image (or a null pointer in case of error).
static void applyAccessControlLayerFilters(const QgsAccessControl *accessControl, QgsMapLayer *mapLayer, QHash< QgsMapLayer *, QString > &originalLayerFilters)
Apply filter from AccessControl.
QList< QgsWmsParametersHighlightLayer > highlightLayersParameters() const
Returns parameters for each highlight layer.
Format format() const
Returns format.
The QgsLayerTreeModel class is model implementation for Qt item views framework.
QHash< QgsVectorLayer *, SymbolSet > HitTest
QSize imageSize
Manual size in pixels for output image.
bool withMapTip() const
withMapTip
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages compositions within the project.
bool transparentAsBool() const
Returns TRANSPARENT parameter as a bool or its default value if not defined.
QgsRasterDataProvider * dataProvider() override
Returns the layer's data provider.
Property
Data definable properties.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
Format infoFormat() const
Returns infoFormat.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
QString srcHeight() const
Returns SRCHEIGHT parameter or an empty string if not defined.
Layout graphical items for displaying a map.
void setOutputSize(QSize size)
Sets the size of the resulting map image.
QByteArray getPrint(const QString &formatString)
Returns printed page as binary.
QgsDxfExport getDxf(const QMap< QString, QString > &options)
Returns the map as DXF data.
bool displayAll
If true, all features will be labelled even when overlaps occur.
void setSize(double size)
Sets the size for rendered text.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
QList< QgsLayerTreeNode * > children()
Gets list of children of the node. Children are owned by the parent.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
#define STRING_TO_FID(str)
bool showFeatureCountAsBool() const
Returns SHOWFEATURECOUNT as a bool.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
QgsRasterRenderer * renderer() const
Namespace with helper functions for layer tree operations.
virtual QgsAbstractGeometry * segmentize(double tolerance=M_PI/180., SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a version of the geometry without curves.
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
QSize outputSize() const
Returns the size of the resulting map image.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
SERVER_EXPORT QString wmsFeatureInfoDocumentElementNs(const QgsProject &project)
Returns the document element namespace for XML GetFeatureInfo request.
virtual QgsRectangle extent() const
Returns the extent of the layer.
double dpi
Resolution to export layout at. If dpi <= 0 the default layout dpi will be used.
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
int heightAsInt() const
Returns HEIGHT parameter as an int or its default value if not defined.
QgsLayoutPageCollection * pageCollection()
Returns a pointer to the layout's page collection, which stores and manages page items in the layout...
A class to describe the version of a project.
void initAttributes(int fieldCount)
Initialize this feature with the given number of fields.
Provides an interface to retrieve and manipulate WMS parameters received from the client...
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
QImage * getLegendGraphics()
Returns the map legend as an image (or a null pointer in case of error).
QList< QgsLayerTreeLayer * > findLayers() const
Find all layer nodes.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setMapScale(double scale)
Sets the legend map scale.
QgsLayerTreeNode * parent()
Gets pointer to the parent. If parent is a null pointer, the node is a root node. ...
virtual QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const
Draws symbol on the left side of the item.
QString request() const
Returns REQUEST parameter as a string or an empty string if not defined.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
bool rasterizeWholeImage
Set to true to force whole layout to be rasterized while exporting.
void setY(double y)
Sets the y value of the point.
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
SERVER_EXPORT bool wmsFeatureInfoSegmentizeWktGeometry(const QgsProject &project)
Returns if the geometry has to be segmentize in GetFeatureInfo request.
void setEnabled(bool enabled)
Sets whether the text buffer will be drawn.
QStringList layerIds() const
Gets list of layer IDs for map rendering The layers are stored in the reverse order of how they are r...
static QgsRenderContext fromQPainter(QPainter *painter)
Creates a default render context given a pixel based QPainter destination.
void setFilter(const QgsVectorLayer *layer, const QgsExpression &expression)
Set a filter for the given layer.
QString filterGeom() const
Returns the filter geometry found in FILTER_GEOM parameter.
Horizontal alignment for data defined label position (Left, Center, Right)
void clear()
Clear any information from this layer tree.
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
void setColor(const QColor &color)
Sets the color that text will be rendered in.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
void setSelectionColor(const QColor &color)
Sets color that is used for drawing of selected vector features.
QList< QgsWmsParametersHighlightLayer > mHighlightLayers
int infoFormatVersion() const
Returns the infoFormat version for GML.
int polygonToleranceAsInt() const
Returns FI_POLYGON_TOLERANCE parameter as an integer.
double mapUnitsPerPixel() const
Returns the distance in geographical coordinates that equals to one pixel in the map.
void removeMultiFrame(QgsLayoutMultiFrame *multiFrame)
Removes a multiFrame from the layout (but does not delete it).
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
static bool isLayer(const QgsLayerTreeNode *node)
Check whether the node is a valid layer node.
This class is a base class for nodes in a layer tree.
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false) ...
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
Reads and writes project states.
void setLegendFilterByScale(double scale)
Force only display of legend nodes which are valid for a given scale.
int count() const
Returns number of items.
double mapUnitsPerPixel() const
Returns current map units per pixel.
QgsFeatureRenderer * renderer()
Returns renderer.
int srcWidthAsInt() const
Returns SRCWIDTH parameter as an int or its default value if not defined.
ExportResult exportToSvg(const QString &filePath, const QgsLayoutExporter::SvgExportSettings &settings)
Exports the layout as an SVG to the filePath, using the specified export settings.
Encapsulate a field in an attribute table or data source.
QString pointTolerance() const
Returns FI_POINT_TOLERANCE parameter or an empty string if not defined.
double dpiAsDouble() const
Returns DPI parameter as an int or its default value if not defined.
QString lineTolerance() const
Returns FI_LINE_TOLERANCE parameter or an empty string if not defined.
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
Abstract base class for all geometries.
QgsLayoutRenderContext::Flags flags
Layout context flags, which control how the export will be created.
QList< QgsWmsParametersLayer > layersParameters() const
Returns parameters for each layer found in LAYER/LAYERS.
Manages storage of a set of layouts.
Keeps the number of features and export symbology per feature (using the first symbol level) ...
virtual bool readSld(const QDomNode &node, QString &errorMessage)
QSizeF minimumSize()
Run the layout algorithm and determine the size required for legend.
QString layoutParameter(const QString &id, bool &ok) const
Returns a layout parameter thanks to its id.
QString attributeDisplayName(int index) const
Convenience function that returns the attribute alias if defined or the field name else...
QgsAnnotationManager * annotationManager()
Returns pointer to the project's annotation manager.
void setX(double x)
Sets the x value of the point.
QgsCoordinateTransformContext transformContext() const
Returns the transform context, for use when a destinationCrs() has been set and reprojection is requi...
int indexFromName(const QString &fieldName) const
Gets the field index from the field name.
Exception base class for server exceptions.
void setName(const QString &n) override
Sets the layer's name.
int readNumEntry(const QString &scope, const QString &key, int def=0, bool *ok=nullptr) const
int featureCountAsInt() const
Returns FEATURE_COUNT as an integer.
Median cut implementation.
void refreshLayerLegend(QgsLayerTreeLayer *nodeLayer)
Force a refresh of legend nodes of a layer node.
QStringList allLayersNickname() const
Returns nickname of layers found in LAYER and LAYERS parameters.
virtual int capabilities() const
Returns a bitmask containing the supported capabilities.
QgsExpressionContext & expressionContext()
Gets the expression context.
Calculates scale for a given combination of canvas size, map extent, and monitor dpi.
Handles rendering and exports of layouts to various formats.
static QString symbolProperties(QgsSymbol *symbol)
Returns a string representing the symbol.
unsigned int placementFlags
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle...
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
Placement
Placement modes which determine how label candidates are generated for a feature. ...
QSet< QString > SymbolSet
int jAsInt() const
Returns J parameter as an int or its default value if not defined.
Contains settings relating to exporting layouts to PDF.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
void setBackgroundColor(const QColor &color)
Sets the background color of the map.
void setSymbologyScale(double scale)
Set reference scale for output.
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins...
Special style, item is hidden including margins around.
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
void setLabelingEngineSettings(const QgsLabelingEngineSettings &settings)
Sets the global configuration of the labeling engine.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
Contains information about the context of a rendering operation.
Contains settings relating to exporting layouts to raster images.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object...
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
QString asWkt(int precision=17) const
Exports the geometry to WKT.
int srcHeightAsInt() const
Returns SRCHEIGHT parameter as an int or its default value if not defined.
QSet< QString > excludeAttributesWms() const
A set of attributes that are not advertised in WMS requests with QGIS server.
QString i() const
Returns I parameter or an empty string if not defined.
void removeLayoutItem(QgsLayoutItem *item)
Removes an item from the layout.
void setLayerTitleAsName(bool layerTitleAsName)
Enable use of title (where set) instead of layer name, when attribute index of corresponding layer in...
QList< QgsMapLayer * > layers() const
Returns the stored layer set.
QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
void setSelectionColor(const QColor &color)
Sets color that is used for drawing of selected vector features.
const QgsLabelingEngineSettings & labelingEngineSettings() const
Returns project's global labeling engine settings.
QPointF point
Top-left corner of the legend item.
void setExtent(const QgsRectangle &r)
Set extent of area to export.
double dpi
Resolution to export layout at. If dpi <= 0 the default layout dpi will be used.
static bool isCurvedType(Type type)
Returns true if the WKB type is a curved type or can contain curved geometries.
SERVER_EXPORT int wmsFeatureInfoPrecision(const QgsProject &project)
Returns the geometry precision for GetFeatureInfo request.
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 ...
QStringList findLayerIds() const
Find layer IDs used in all layer nodes.
Container for settings relating to a text buffer.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
QgsLayerTreeGroup * findGroup(const QString &name)
Find group node with specified name.
ExportResult exportToPdf(const QString &filePath, const QgsLayoutExporter::PdfExportSettings &settings)
Exports the layout as a PDF to the filePath, using the specified export settings. ...
Exception thrown when data access violates access controls.
Proxy for sequential or parallel map render job.
double dist
Distance from feature to the label.
QString externalWMSUri(const QString &id) const
Returns the external WMS uri.
double scaleAsDouble() const
Returns SCALE as a double.
SERVER_EXPORT QStringList wfsLayerIds(const QgsProject &project)
Returns the Layer ids list defined in a QGIS project as published in WFS.
This class represents a coordinate reference system (CRS).
QgsFeatureFilterProviderGroup & addProvider(const QgsFeatureFilterProvider *provider)
Add another filter provider to the group.
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.
QgsMasterLayoutInterface * layoutByName(const QString &name) const
Returns the layout with a matching name, or nullptr if no matching layouts were found.
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.
QgsRectangle layerExtentToOutputExtent(const QgsMapLayer *layer, QgsRectangle extent) const
transform bounding box from layer's CRS to output CRS
QgsRectangle extent() const
Returns geographical coordinates of the rectangle that should be rendered.
QString authid() const
Returns the authority identifier for the CRS.
static QString displayString(Type type)
Returns a display string type for a WKB type, e.g., the geometry name used in WKT geometry representa...
virtual bool setSubsetString(const QString &subset)
Set the string (typically sql) used to define a subset of the layer.
static QDomElement rectangleToGMLEnvelope(QgsRectangle *env, QDomDocument &doc, int precision=17)
Exports the rectangle to GML3 Envelope.
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
QString bandName(int bandNoInt) const
Returns the name of a band given its number.
const QgsCoordinateReferenceSystem & outputCrs
int pointToleranceAsInt() const
Returns FI_POINT_TOLERANCE parameter as an integer.
int yAsInt() const
Returns Y parameter as an int or its default value if not defined.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
Basic implementation of the labeling interface.
QList< QgsLayerTreeModelLegendNode * > layerLegendNodes(QgsLayerTreeLayer *nodeLayer, bool skipNodeEmbeddedInParent=false)
Returns filtered list of active legend nodes attached to a particular layer node (by default it retur...
QgsLegendSettings legendSettings() const
Returns legend settings.
QString id() const
Returns the item's ID name.
void setBuffer(const QgsTextBufferSettings &bufferSettings)
Sets the text's buffer settings.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Query the layer for features specified in request.
double scale() const
Returns the map scale.
Enable vector simplification and other rendering optimizations.
QgsRectangle bboxAsRectangle() const
Returns BBOX as a rectangle if defined and valid.
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
void setOpacity(double opacity)
Sets the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1...
Custom exception class for Coordinate Reference System related exceptions.
QString polygonTolerance() const
Returns FI_POLYGON_TOLERANCE parameter or an empty string if not defined.
SERVER_EXPORT QString wmsFeatureInfoSchema(const QgsProject &project)
Returns the schema URL for XML GetFeatureInfo request.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider.
QgsLayerTree * layerTreeRoot() const
Returns pointer to the root (invisible) node of the project's layer tree.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
QString srcWidth() const
Returns SRCWIDTH parameter or an empty string if not defined.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
A layout item subclass for map legends.
Y-coordinate data defined label position.
bool nextFeature(QgsFeature &f)
SERVER_EXPORT QStringList wmsRestrictedLayers(const QgsProject &project)
Returns the restricted layer name list.
Container of other groups and layers.
Container for all settings relating to text rendering.
QgsLayoutRenderContext::Flags flags
Layout context flags, which control how the export will be created.
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
SERVER_EXPORT QString wmsRootName(const QgsProject &project)
Returns the WMS root layer name defined in a QGIS project.
Geometry is not required. It may still be returned if e.g. required for a filter condition.
void set(QgsAbstractGeometry *geometry)
Sets the underlying geometry store.
double width() const
Returns the width of the rectangle.
QString y() const
Returns Y parameter or an empty string if not defined.
static QgsExpression * expressionFromOgcFilter(const QDomElement &element, QgsVectorLayer *layer=nullptr)
Parse XML with OGC filter into QGIS expression.
bool parallelRendering() const
Returns parallel rendering setting.
double dpi
Resolution to export layout at. If dpi <= 0 the default layout dpi will be used.
int iAsInt() const
Returns I parameter as an int or its default value if not defined.
Exception class for WMS service exceptions (for compatibility only).
Represents a vector layer which manages a vector based data sets.
double labelXOffset
offset from the left side where label should start
QgsLayerTreeLayer * findLayer(QgsMapLayer *layer) const
Find layer node representing the map layer.
Contains settings relating to exporting layouts to SVG.
QString x() const
Returns X parameter or an empty string if not defined.
Base class for frame items, which form a layout multiframe item.
QgsWkbTypes::GeometryType type() const
Returns type of the geometry as a QgsWkbTypes::GeometryType.
QgsProjectVersion versionAsNumber() const
Returns VERSION parameter if defined or its default value.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
A layout multiframe subclass for HTML content.
Vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top) ...
Defines a QGIS exception class.
WMS parameter received from the client.
int getImageQuality() const
Returns the image quality to use for getMap request.
QMap< QString, QgsMapLayer * > mapLayers() const
Returns a map of all registered layers by layer ID.
void addLayers(const QList< QgsDxfExport::DxfLayer > &layers)
Add layers to export.
void setColor(const QColor &color)
Sets the color for the buffer.
int priority
Label priority.
If the layer is identifiable using the identify map tool and as a WMS layer.
QgsWmsParametersComposerMap composerMapParameters(int mapId) const
Returns the requested parameters for a composer map parameter.
Raster renderer pipe that applies colors to a raster.
QString scale() const
Returns SCALE parameter or an empty string if none is defined.
QString imageQuality() const
Returns IMAGE_QUALITY parameter or an empty string if not defined.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
A filter filter provider grouping several filter providers.
bool setCurrentStyle(const QString &name)
Set a different style as the current style - will apply it to the layer.
QString height() const
Returns HEIGHT parameter or an empty string if not defined.
QgsCoordinateReferenceSystem crs
bool hasAxisInverted() const
Returns whether axis is inverted (e.g., for WMS 1.3) for the CRS.
QString rule() const
Returns RULE parameter or an empty string if none is defined.
QString width() const
Returns WIDTH parameter or an empty string if not defined.
bool infoFormatIsImage() const
Checks if INFO_FORMAT parameter is one of the image formats (PNG, JPG).
SERVER_EXPORT int wmsImageQuality(const QgsProject &project)
Returns the quality for WMS images defined in a QGIS project.
double height() const
Returns the height of the rectangle.
void invert()
Swap x/y coordinates in the rectangle.
int imageQualityAsInt() const
Returns IMAGE_QUALITY parameter as an integer.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label's property collection, used for data defined overrides.
QString composerTemplate() const
Returns TEMPLATE parameter or an empty string if not defined.
void setCustomProperty(const QString &key, const QVariant &value)
Sets a custom property for the node. Properties are stored in a map and saved in project file...
Layer tree node points to a map layer.
The QgsLegendRenderer class handles automatic layout and rendering of legend.
QgsLayoutRenderContext::Flags flags
Layout context flags, which control how the export will be created.
int lineToleranceAsInt() const
Returns FI_LINE_TOLERANCE parameter as an integer.
SERVER_EXPORT int wmsMaxHeight(const QgsProject &project)
Returns the maximum height for WMS images defined in a QGIS project.
static QString replaceExpressionText(const QString &action, const QgsExpressionContext *context, const QgsDistanceArea *distanceArea=nullptr)
This function replaces each expression between [% and %] in the string with the result of its evaluat...
void setLayers(const QList< QgsMapLayer * > &layers)
Set list of layers for map rendering.
QColor backgroundColorAsColor() const
Returns BGCOLOR parameter as a QColor or its default value if not defined.
QString fieldName
Name of field (or an expression) to use for label text.
SERVER_EXPORT bool wmsUseLayerIds(const QgsProject &project)
Returns if layer ids are used as name in WMS.
Exports one feature per symbol layer (considering symbol levels)
int maxThreads() const
Returns the maximum number of threads to use.
void setOpacity(double opacity)
Sets the opacity for the vector layer, where opacity is a value between 0 (totally transparent) and 1...