[Qgis-developer] Access labels properties from python?

HAUBOURG regis.haubourg at eau-adour-garonne.fr
Wed Feb 5 03:26:53 PST 2014


Hi Larry, thanks for all this.
There is no urgency, keep focused on your actual work! You give an excellent technical analysis for next releases roadmap.


De : larry at shafferinteractive.com [mailto:larry at shafferinteractive.com] De la part de Larry Shaffer
Envoyé : mercredi 5 février 2014 12:12
À : HAUBOURG
Cc : QGIS Developer List
Objet : Re: [Qgis-developer] Access labels properties from python?

Hi Régis,

On Tue, Feb 4, 2014 at 1:07 PM, Régis Haubourg <regis.haubourg at eau-adour-garonne.fr<mailto:regis.haubourg at eau-adour-garonne.fr>> wrote:
Hi there,
I would like to explore the possibilities to extend EasyCustomLabeling to
handle correctly curved labeling on lines, and maybe also labeling on the
border of polygons.
My idea is to make PAL engine compute curved labels, get label path and
convert it to a linestring, a sort of label path.
Is there any way in the python API to access label properties once computed
by PAL? If not, does C++ API allows that?

The label information available, after labeling is completed, is stored in QgsLabelPostion, used by the interactive labeling tools [0]. These are retrieved from a search tree via QgsLabelingEngineInterface's::labelsAtPosition(QgsPoint) and ::labelsWithinRect (QgsRectangle) [1]. All of that should already have bindings.
QgsLabelPostion has limited label component info, only the minimum needed for working with the interactive tools, e.g. just a bounding rectangle and corner points for geometries.

However, there are several outstanding bugs (and the advent of labeling styles) that could benefit from a new full label class that maintains as much information about the label *before* sending only the needed bits to PAL.  The label class properties would be resolved as needed to reduce overhead. This also means that if the registered label classes persist during PAL registration and solution, and rendering, then any new properties calculated along the way can be appended.
The stored result, accessed like QgsLabelPostion, could possibly contain all initial settings and resolved properties, as well as any geometries calculated during rendering, i.e. the "label path" you were referring to. It also means that additional lightweight geometries can be stored within it, like a data defined destination point for leader (call out) lines.

I have taken the next week off from my job to work solely on labeling issues. I'm pretty sure I will not have enough time to do such a large refactoring before the release, since squashing as many bugs as possible and finishing a full unit test suite should come first.

[0] http://www.qgis.org/api/classQgsLabelPosition.html
[1] http://www.qgis.org/api/classQgsLabelingEngineInterface.html
Regards,
Larry

Thanks for your hints.
Cheers
Régis





--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Access-labels-properties-from-python-tp5101930.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
_______________________________________________
Qgis-developer mailing list
Qgis-developer at lists.osgeo.org<mailto:Qgis-developer at lists.osgeo.org>
http://lists.osgeo.org/mailman/listinfo/qgis-developer

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140205/4d47a736/attachment.html>


More information about the Qgis-developer mailing list