37 QString format = params.value( QStringLiteral(
"FORMAT" ), QStringLiteral(
"PNG" ) );
42 #ifdef HAVE_SERVER_PYTHON_PLUGINS 50 switch ( outputFormat )
56 contentType =
"image/png";
60 contentType =
"image/jpeg";
65 QString(
"Output format '%1' is not supported in the GetLegendGraphic request" ).arg( format ) );
70 QByteArray content = cacheManager->
getCachedImage( project, request, accessControl );
71 if ( !content.isEmpty() && image.loadFromData( content ) )
73 response.
setHeader( QStringLiteral(
"Content-Type" ), contentType );
74 image.save( response.
io(), qPrintable( saveFormat ) );
80 QgsRenderer renderer( serverIface, project, wmsParameters );
87 #ifdef HAVE_SERVER_PYTHON_PLUGINS 90 QByteArray content = response.
data();
91 if ( !content.isEmpty() )
92 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.
QByteArray getCachedImage(const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl) const
Returns cached image (or 0 if image not in cache) like tiles.
Exception class for WMS service exceptions.
void writeImage(QgsServerResponse &response, QImage &img, const QString &formatStr, int imageQuality)
Write image response.
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.
QgsServerRequest::Parameters parameters() const
Returns a map of query parameters with keys converted to uppercase.
int getImageQuality() const
Returns the image quality to use for getMap request.
ImageOutputFormat parseImageFormat(const QString &format)
Parse image format parameter.
QMap< QString, QString > Parameters