QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsdxfwriter.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsdxfexport.cpp
3 -------------------------------------------------------------------
4Date : 20 December 2016
5Copyright : (C) 2015 by
6email : marco.hugentobler at sourcepole dot com (original code)
7Copyright : (C) 2016 by
8email : david dot marteau at 3liz dot com
9 ***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#include "qgsmodule.h"
18#include "qgsdxfwriter.h"
19#include "qgsdxfexport.h"
20#include "qgswmsrenderer.h"
21
22namespace QgsWms
23{
24 void writeAsDxf( QgsServerInterface *serverIface, const QgsProject *project,
25 const QgsWmsRequest &request,
26 QgsServerResponse &response )
27 {
28 // prepare render context
29 QgsWmsRenderContext context( project, serverIface );
34 context.setParameters( request.wmsParameters() );
35
36 // Write output
37 QgsRenderer renderer( context );
38 std::unique_ptr<QgsDxfExport> dxf = renderer.getDxf();
39 response.setHeader( "Content-Type", "application/dxf" );
40 dxf->writeToFile( response.io(), request.wmsParameters().dxfCodec() );
41 }
42} // namespace QgsWms
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:104
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins.
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
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...
virtual QIODevice * io()=0
Returns the underlying QIODevice.
Map renderer for WMS requests.
std::unique_ptr< QgsDxfExport > getDxf()
Returns the map as DXF data.
QString dxfCodec() const
Returns the DXF CODEC parameter.
Rendering context for the WMS renderer.
void setParameters(const QgsWmsParameters &parameters)
Sets WMS parameters.
void setFlag(Flag flag, bool on=true)
Sets or unsets a rendering flag according to the on value.
Class defining request interface passed to WMS service.
Definition: qgswmsrequest.h:35
const QgsWmsParameters & wmsParameters() const
Returns the parameters interpreted for the WMS service.
Median cut implementation.
void writeAsDxf(QgsServerInterface *serverIface, const QgsProject *project, const QgsWmsRequest &request, QgsServerResponse &response)
Output GetMap response in DXF format.