[Qgis-developer] QgsFeatureRendererV2.startRender deprecated ...

Martin Dobias wonder.sk at gmail.com
Mon Sep 12 20:26:48 PDT 2016


Hi Chris

On Mon, Sep 12, 2016 at 10:18 AM, Chris Crook <ccrook at linz.govt.nz> wrote:
> Hi All
>
>
>
> I see that the version of QgsFeatureRendererV2.startRender taking a
> QgsVectorLayer as a second parameter is deprecated in favour of a version
> taking a field list.

Yes it has been deprecated because since 2.4 rendering is normally
done in a worker thread and having direct access to the layer would be
unsafe.


> In particular I want to get the layer CRS in order to determine the
> relationship between true north and projection north, so that I can apply
> this rotation to the symbol.   It is not clear to me where I can get this
> from once the deprecated implementation of startRender is removed.  Possibly
> this could be added to the QGS render context?  I can access coordinate
> transformations there, but I don't see that as a guaranteed API for getting
> the source CRS.  Any suggestions?

One can get source CRS from the coordinate transform (from render
context): context.coordinateTransform().sourceCrs() - why isn't that a
guaranteed API?

An alternative would be to pass layer's CRS to the renderer object
when the renderer is created.

Regards
Martin


More information about the Qgis-developer mailing list