[Qgis-developer] qgis web
Mohammed Rashad
mohammedrashadkm at gmail.com
Sun Feb 13 06:40:50 EST 2011
On Sun, Feb 13, 2011 at 4:36 PM, Richard Duivenvoorde
<rdmailings at duif.net>wrote:
> Mohammed Rashad wrote:
>
>> How to render a shapefile to an image file so that it can be reused on a
>> web page.
>> Anyone please send a me a minimal code or tell me where and what to
>> modify. I looked src/mapserver folder but I cant get the code for it
>>
>> Atleast please tell me the file to modify to render a vector file(shape)
>> to an image file
>>
>
> Hi,
>
> you're not very clear what exactly you want.
>
I am trying to build an online shapefile viewer using qgis as a backend. for
that i need to render qgis output to a image(.png) file
I cannot use QgsMapCanvas class because it requires QApplication I cannot
use any class from qgis_gui
but qgis_core can be used.
QgsVectorLayer * mypLayer = new QgsVectorLayer(myLayerPath,
myLayerBaseName, myProviderName);
QgsSingleSymbolRenderer *mypRenderer = new
QgsSingleSymbolRenderer(mypLayer->geometryType());
QList<QgsMapCanvasLayer> myLayerSet;
mypLayer->setRenderer(mypRenderer);
if (mypLayer->isValid())
{
cout << "Layer is valid";
}
else
{
cout << "Layer is NOT valid";
return;
}
the following code works for me in Wt. It prints layer is valid or invalid
according to the parameters to QgsVectorLayer()
can I set mypLayer->setRenderer of the above code to an image file so that
rendering occurs on a image file of my choice?
It hope now the problem is clear.Now can you help me?
>
> But, if you want a one time imagefile of a map from a shapefile, use 'Save
> as Image' from the File menu.
>
> If you want to do some python coding for a plugin, please have a look in to
> for example the "Html Image Map plugin", that one saves an image from
> current map. Minimal code from Python console in a running qgis:
>
> qgis.utils.iface.mapCanvas().saveAsImage("/tmp/mymap.png")
>
> If you want a server process generating maps from the (changing?)
> shapefile, you need a WMS (Web Mapping Server). You can use QGIS mapserver
> for that: http://karlinapp.ethz.ch/qgis_wms/. But even more famous ones
> like Minnesote Mapserver (mapserver.org), or Geoserver (geoserver.org).
>
>
> Regards,
>
> Richard Duivenvoorde
>
--
Thanks && Regards
Rashad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20110213/fb1e6d9e/attachment.html
More information about the Qgis-developer
mailing list