QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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  QgsDxfExport dxf = renderer.getDxf();
42  response.setHeader( "Content-Type", "application/dxf" );
43  dxf.writeToFile( response.io(), parameters.dxfCodec() );
44  }
45 } // namespace QgsWms
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...
void writeAsDxf(QgsServerInterface *serverIface, const QgsProject *project, const QString &, const QgsServerRequest &request, QgsServerResponse &response)
Output GetMap response in DXF format.
QString dxfCodec() const
Returns the DXF CODEC parameter.
QgsDxfExport getDxf()
Returns the map as DXF data.
void setFlag(Flag flag, bool on=true)
Sets or unsets a rendering flag according to the on value.
void setParameters(const QgsWmsParameters &parameters)
Sets WMS parameters.
int writeToFile(QIODevice *d, const QString &codec)
Export to a dxf file in the given encoding.
Provides an interface to retrieve and manipulate WMS parameters received from the client...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
Definition: qgsproject.h:89
Median cut implementation.
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.
Rendering context for the WMS renderer.
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...