[Qgis-developer] Labeling: data-defined fields shifted after new vector API?

Andreas Neumann a.neumann at carto.net
Mon Jan 28 02:12:39 PST 2013


 Hi all,

 Thank you Martin and Jürgen for your explanation. Sounds logical to me.

 As a longer time QGIS user I remember that I had the problem of shifted 
 columns in the field widgets (this was fixed by Jürgen quite some time 
 ago) and that I had troubles with the shifted columns in data-defined 
 labeling and data-defined symbology in the past, partially also because 
 my table design changed after the QGIS project was created. I would 
 assume that I am not the only one who changes table design during the 
 life cycle of a project.

 So a big +1 to change to a name-based index instead of a numerical 
 based index for data-defined columns.

 Andreas

 On Mon, 28 Jan 2013 11:00:09 +0100, Martin Dobias wrote:
> Hi Andreas
>
> On Mon, Jan 28, 2013 at 10:30 AM, Andreas Neumann
> <a.neumann at carto.net> wrote:
>> Hi,
>>
>> In some of my projects data-defined values for labeling (like 
>> font-color,
>> rotation fields) are now failing - the order of the column 
>> assignments are
>> shifted by one column. Perhaps the new Vector API is the cause? My 
>> data
>> comes from the Postgis data provider. I am testing in the version 
>> 74ace4ad21
>> from January 27.
>>
>> I checked with an older version from last week (the version starting 
>> with
>> 298f0c000e from January 25) and the labeling is still working ok.
>>
>> Martin or Marco - could either one of you please have a look what 
>> may be
>> causing this problem?
>
> I have briefly looked into the code and it seems that new labeling
> stores data-defined attributes by index instead of name. If so, 
> that's
> the source of the problem and it should be changed to read/write 
> names
> so that if the order of fields change, the projects work correctly.
> Old labeling should not have this problem as it always saves field
> names.
>
> The source of the problem is that before, it was possible to have
> "holes" in attribute field indices: e.g. three attributes with 
> indices
> 0,2,3. Whether such holes appeared depended on the provider being
> used. The support for holes has been removed for performance and
> simplicity - many developers were not even aware of this thing.
>
> As a quick fix I think you'll need to update your project file. The
> proper fix should change writing of attributes as names in
> data-defined properties (for new labeling).
>
> Regards
> Martin

-- 
 --
 Andreas Neumann
 Böschacherstrasse 10A
 8624 Grüt (Gossau ZH)
 Switzerland


More information about the Qgis-developer mailing list