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

Chris Crook ccrook at linz.govt.nz
Thu Sep 15 18:01:35 PDT 2016


I've found that the context.coordinateTransform() can be null, so it is not a way of determining the layer CRS.

I'm not sure how well setting the CRS on renderer creation will work either, as it can be created from the UI, from paste style, from loading a style directly, etc...
It may be possible to catch a signal from layer changes (for all layers) to identify this.  Likewise a similar approach may be needed to access the map CRS :-(

Cheers
Chris

> -----Original Message-----
> From: Martin Dobias [mailto:wonder.sk at gmail.com]
> Sent: Tuesday, 13 September 2016 3:27 p.m.
> To: Chris Crook
> Cc: qgis-developer at lists.osgeo.org
> Subject: Re: [Qgis-developer] QgsFeatureRendererV2.startRender
> deprecated ...
>
> 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

This message contains information, which may be in confidence and may be subject to legal privilege. If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message. If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message. LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ. Thank You.


More information about the Qgis-developer mailing list