[Qgis-developer] Is it possible to re-use print composer code to build a web service ?

Martin Dobias wonder.sk at gmail.com
Mon Dec 20 09:31:51 EST 2010


On Mon, Dec 20, 2010 at 3:19 PM, Alessandro Pasotti <apasotti at gmail.com> wrote:
> 2010/12/20 Martin Dobias <wonder.sk at gmail.com>
>> http://www.qgis.org/pyqgis-cookbook/composer.html#output-using-map-composer
>
> Thanks Martin,
> I have already found your example, but it is for a plugin, isn't it ?
> I remember I tried to make it work from outside qgis (standalone) without
> success.

Yes that code should work from python console in qgis or within a
plugin. You can also make it working from outside of qgis application
as a command line tool, you will just have to do some bootstrapping:
initialize qgis libraries (QgsApplication: setPrefixPath, initQgis),
load some layers, construct and set up a map renderer
(QgsMapRenderer). The example code omits that for simplicity and uses
map renderer from canvas.


> What I would like to achieve is a CGI-style application which takes WMS-like
> parameters (like qgis-mapserver does) and a printcomposer template to
> generate a (vectorial) PDF.

This is indeed possible - one just has to initialize all the machinery
as briefly described above.

Regards
Martin


More information about the Qgis-developer mailing list