37 QString format = params.value( QStringLiteral(
"FORMAT" ), QStringLiteral(
"PNG" ) );
44 #ifdef HAVE_SERVER_PYTHON_PLUGINS 53 switch ( outputFormat )
59 contentType =
"image/png";
63 contentType =
"image/jpeg";
68 QString(
"Output format '%1' is not supported in the GetLegendGraphic request" ).arg( format ) );
73 QByteArray content = cacheManager->
getCachedImage( project, request, accessControl );
74 if ( !content.isEmpty() && image.loadFromData( content ) )
76 response.
setHeader( QStringLiteral(
"Content-Type" ), contentType );
77 image.save( response.
io(), qPrintable( saveFormat ) );
82 QgsRenderer renderer( serverIface, project, wmsParameters );
91 QByteArray content = response.
data();
92 if ( !content.isEmpty() )
93 cacheManager->
setCachedImage( &content, project, request, accessControl );
99 QStringLiteral(
"Failed to compute GetLegendGraphics image" ) );
virtual void setHeader(const QString &key, const QString &value)=0
Set Header entry Add Header entry to the response Note that it is usually an error to set Header afte...
bool setCachedImage(const QByteArray *img, const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl) const
Updates or inserts the image in cache like tiles.
int getImageQuality() const
Returns the image quality to use for getMap request.
Exception class for WMS service exceptions.
void writeImage(QgsServerResponse &response, QImage &img, const QString &formatStr, int imageQuality)
Write image response.
QgsServerRequest::Parameters parameters() const
Returns a map of query parameters with keys converted to uppercase.
Provides an interface to retrieve and manipulate WMS parameters received from the client...
QImage * getLegendGraphics()
Returns the map legend as an image (or a null pointer in case of error).
A helper class that centralizes caches accesses given by all the server cache filter plugins...
Reads and writes project states.
void writeGetLegendGraphics(QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response)
Output GetLegendGRaphics response.
Median cut implementation.
virtual QByteArray data() const =0
Gets the data written so far.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins...
Map renderer for WMS requests.
virtual QIODevice * io()=0
Returns the underlying QIODevice.
virtual QgsServerCacheManager * cacheManager() const =0
Gets the registered server cache filters.
A helper class that centralizes restrictions given by all the access control filter plugins...
ImageOutputFormat
Supported image output format.
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
virtual QgsAccessControl * accessControls() const =0
Gets the registered access control filters.
ImageOutputFormat parseImageFormat(const QString &format)
Parse image format parameter.
QMap< QString, QString > Parameters
QByteArray getCachedImage(const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl) const
Returns cached image (or 0 if image not in cache) like tiles.