[QGIS-Developer] Labelling misplaced

Régis Haubourg regis.haubourg at gmail.com
Mon Nov 11 09:42:28 PST 2019


Oh ok, expression taken from label connector plugin :)

Be aware that it can be slow with big geometries and that it is a
temporary approach before having a native one in core (which I'd be
pleased to have implemented if anyone supports it).

So it seems you have something messing the unique id's that auxiliary
storage database uses to link your data and qgis projected data when
you add a new feature. Are you sure your ID's and foreign keys beahve
like expected on the database side? For the auxiliary storage, a new
feature shouldn't have any x-y value and thus the label should fall
back to the automatic labeling options. In your case, it seems the
newly created feature inherits from the id of another feature. This is
a common case in labeling, and I remember the famous Mapinfo label
callout mix ups that occured when compressing datasets, just because
it didn't use real id's, but line number to identify features.


Régis

Le lun. 11 nov. 2019 à 17:33, Luís Miguel Royo Pérez
<luis.miguel.royo at gmail.com> a écrit :
>
> Of course, here is:
>
> case when "auxiliary_storage_labeling_positionx" < $x and "auxiliary_storage_labeling_positiony" > $y and abs("auxiliary_storage_labeling_positiony"-$y) < abs("auxiliary_storage_labeling_positionx"-$x) THEN
>  make_line($geometry, make_point($x-abs("auxiliary_storage_labeling_positiony"-$y),"auxiliary_storage_labeling_positiony"),make_point("auxiliary_storage_labeling_positionx", "auxiliary_storage_labeling_positiony"))
> when  "auxiliary_storage_labeling_positionx" < $x and "auxiliary_storage_labeling_positiony" > $y and abs("auxiliary_storage_labeling_positiony"-$y) >= abs("auxiliary_storage_labeling_positionx"-$x) then
>   make_line($geometry, make_point($x,abs("auxiliary_storage_labeling_positionx"-$x)+$y),make_point("auxiliary_storage_labeling_positionx", "auxiliary_storage_labeling_positiony"))
> when "auxiliary_storage_labeling_positionx" < $x and "auxiliary_storage_labeling_positiony" < $y and abs("auxiliary_storage_labeling_positiony"-$y) < abs("auxiliary_storage_labeling_positionx"-$x) THEN
>   make_line($geometry, make_point($x-abs("auxiliary_storage_labeling_positiony"-$y),"auxiliary_storage_labeling_positiony"),make_point("auxiliary_storage_labeling_positionx", "auxiliary_storage_labeling_positiony"))
> when  "auxiliary_storage_labeling_positionx" < $x and "auxiliary_storage_labeling_positiony" < $y and abs("auxiliary_storage_labeling_positiony"-$y) >= abs("auxiliary_storage_labeling_positionx"-$x) then
>   make_line($geometry, make_point($x,$y-abs("auxiliary_storage_labeling_positionx"-$x)),make_point("auxiliary_storage_labeling_positionx", "auxiliary_storage_labeling_positiony"))
> when "auxiliary_storage_labeling_positionx" >= $x and "auxiliary_storage_labeling_positiony" > $y and abs("auxiliary_storage_labeling_positiony"-$y) > abs("auxiliary_storage_labeling_positionx"-$x) then --quadrant ur alternatif
>   make_line($geometry, make_point($x,"auxiliary_storage_labeling_positiony"-abs("auxiliary_storage_labeling_positionx"-$x)),make_point("auxiliary_storage_labeling_positionx", "auxiliary_storage_labeling_positiony"))
> when "auxiliary_storage_labeling_positionx" >= $x and "auxiliary_storage_labeling_positiony" > $y and abs("auxiliary_storage_labeling_positiony"-$y) < abs("auxiliary_storage_labeling_positionx"-$x) then
>    make_line($geometry, make_point($x+abs("auxiliary_storage_labeling_positiony"-$y),"auxiliary_storage_labeling_positiony"),make_point("auxiliary_storage_labeling_positionx", "auxiliary_storage_labeling_positiony"))
> when "auxiliary_storage_labeling_positionx" >= $x and "auxiliary_storage_labeling_positiony" <= $y and abs("auxiliary_storage_labeling_positiony"-$y) > abs("auxiliary_storage_labeling_positionx"-$x) THEN
>   make_line($geometry, make_point($x,$y-abs("auxiliary_storage_labeling_positionx"-$x)),make_point("auxiliary_storage_labeling_positionx", "auxiliary_storage_labeling_positiony"))
> when "auxiliary_storage_labeling_positionx" >= $x and "auxiliary_storage_labeling_positiony" <= $y and abs("auxiliary_storage_labeling_positiony"-$y) < abs("auxiliary_storage_labeling_positionx"-$x) THEN
>  make_line($geometry, make_point($x+abs("auxiliary_storage_labeling_positiony"-$y),"auxiliary_storage_labeling_positiony"),make_point("auxiliary_storage_labeling_positionx", "auxiliary_storage_labeling_positiony"))
>    END
>
>
>
>
> El lun., 11 nov. 2019 17:15, Régis Haubourg <regis.haubourg at gmail.com> escribió:
>>
>> Hi Luis, can you share your geometry generator expression please?
>> regards
>> Régis
>>
>> Le lun. 11 nov. 2019 à 09:04, Luís Miguel Royo Pérez
>> <luis.miguel.royo at gmail.com> a écrit :
>> >
>> > Hello everyone,
>> >
>> > I'm developing a QGIS plugin along with PostGIS and I'm facing some problems with labeling. This plugin creates several layers and tables. Some of these layers are views  (labeling layers), so if I edit the one fo the source layer the view changes and then the label. I explain more detailed:
>> >
>> > I have the following:
>> >
>> > One layer. Let's call it layer1.
>> > One none spatial table. Let's call it table1.
>> > One spatial view from these other two layers layer1 and table1 meant for labeling. Let's call it labelView1.
>> >
>> > The point is this, when I edit table1 adding a new element linked by a foreign key with layer1. The label position in labelView1 changes into a messy thing. The Style of labelView1 is the following:
>> >
>> > Symbol is a geometry generator. Since I want to create callouts from label to the geometry, wich is a point.
>> > The position of the label is saved on project. In the qgd file.
>> >
>> > I have seen this behaviour in Windows10 and in Ubuntu. The QGIS version is 3.4, but I tried to move to the new 3.10 version of QGIS, with the callouts new feature, but is the same result.
>> >
>> > As well I tried to reproduce it in a much simple way, but without succed, that's why I want to share a link with a GIF file showing this issue:
>> >
>> > https://gifyu.com/image/vMY7
>> >
>> > I've done the same but without fixed position,and the labels don't move, but the geometry_generator does.
>> >
>> > Is this a bug? Is there any way to prevent it?
>> >
>> > Thanks.
>> > --
>> > Luís Miguel Royo Pérez.
>> > Analista-Programador GIS
>> > C/ Antic Regne de Valencia nº 4. Manises (Valencia)
>> > Teléfono:+34  679846103
>> > webs:
>> > inisig.com
>> > geofibra.com
>> >
>> >
>> > _______________________________________________
>> > QGIS-Developer mailing list
>> > QGIS-Developer at lists.osgeo.org
>> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the QGIS-Developer mailing list