[Qgis-developer] Change symbol \\ using jpeg image \\ and proj(delimited text)

Martin Dobias wonder.sk at gmail.com
Wed Oct 4 19:48:09 EDT 2006


On 10/4/06, Schalk Snyman <snymans at wbs.co.za> wrote:
> 1. I want to change the symbols displayed on my map. e.g. to the car
> symbol. My current code looks like this:
>
> // Change symbol
> QString strSymbolName = "car"; ////
> QgsSymbol * syCar = new QgsSymbol; ////
> syCar->setNamedPointSymbol(strSymbolName); ////
> syCar->setPointSize(6);
> //............................................
> QgsVectorLayer * mypLayerPoints = new QgsVectorLayer(uri, "results",
> "delimitedtext");
> QgsSingleSymbolRenderer *mypRendererPoints = new
> QgsSingleSymbolRenderer(mypLayerPoints->vectorType());
> mypRendererPoints->addSymbol(syCar); ////
>
> Unfortunately the symbols are not displayed then :-(
> Should I specify the path to the svg folder?

You have to use a class derived from QgsSymbol - in your case it's
QgsMarkerSymbol. To specify the picture to be displayed use
setPicture(QString) function and pass the full path of the SVG as an
argument.

> ----------------------------------------------------------------------
> 2. Also: is it possible to display a jpeg file as a map in QGIS? If
> possible will the projection def's be similar to those for shape files?

Yes it's possible, it depends on whether you have jpeg support
compiled in GDAL library. QGIS currently doesn't support projections
for raster layers.

> ----------------------------------------------------------------------
> 3. How can I change the projection used for the delimited text file
> layer?

Changing projection of the vector layer can be done with:
layer->coordinateTransform()->sourceSRS().createFromSrsId(srsid);
layer->coordinateTransform()->initialise();

For creating SRS you can use some other functions, e.g.:
createFromWkt, createFromEpsg, ...
(see QgsSpatialRefSys header for more information)


I haven't tried the code I've written here so maybe they won't work...
it's just how I think they should work :-)

Martin



More information about the Qgis-developer mailing list