QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
qgsdxfwriter.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdxfexport.cpp
3  -------------------------------------------------------------------
4 Date : 20 December 2016
5 Copyright : (C) 2015 by
6 email : marco.hugentobler at sourcepole dot com (original code)
7 Copyright : (C) 2016 by
8 email : 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 
22 namespace QgsWms
23 {
24  void writeAsDxf( QgsServerInterface *serverIface, const QgsProject *project,
25  const QString &, const QgsServerRequest &request,
26  QgsServerResponse &response )
27  {
28  // get wms parameters from query
29  QgsWmsParameters parameters( QUrlQuery( request.url() ) );
30 
31  // prepare render context
32  QgsWmsRenderContext context( project, serverIface );
37  context.setParameters( parameters );
38 
39  // Write output
40  QgsRenderer renderer( context );
41  std::unique_ptr<QgsDxfExport> dxf = renderer.getDxf();
42  response.setHeader( "Content-Type", "application/dxf" );
43  dxf->writeToFile( response.io(), parameters.dxfCodec() );
44  }
45 } // namespace QgsWms
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:99
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
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.
Provides an interface to retrieve and manipulate WMS parameters received from the client.
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.
Median cut implementation.
void writeAsDxf(QgsServerInterface *serverIface, const QgsProject *project, const QString &, const QgsServerRequest &request, QgsServerResponse &response)
Output GetMap response in DXF format.