3liz / lizmap-web-client

Transfer a QGIS project on a server, Lizmap is providing the web interface to browse it
https://www.lizmap.com
Mozilla Public License 2.0
260 stars 143 forks source link

Advanced form, filter: expression like "intersects($geometry, centroid(@current_geometry))" does not work #3930

Closed gioman closed 1 year ago

gioman commented 1 year ago

What is the bug?

Following the example here https://docs.lizmap.com/current/en/publish/layer_properties/attributes_form.html for a value relation/filter, and when the layer being edited is a point layer the example provided works.

When trying with a polygon and its centroid it doesn't work, the combobox remains unpopulated (works in QGIS):

intersects($geometry, centroid(@current_geometry))

Steps to reproduce the issue

Follow the example for a value relation/filter as described here https://docs.lizmap.com/current/en/publish/layer_properties/attributes_form.html but use a polygon layer instead of a point one, and this expression

intersects($geometry, centroid(@current_geometry))

Versions

LMWC 3.6.6

Check Lizmap plugin

QGIS server version, only if the section above doesn't mention the QGIS Server version

3.28..1

Operating system

Ubuntu 22.04

Browsers

Firefox, Chrome

Browsers version

Latest updates

Relevant log output

No response

Gustry commented 1 year ago

Can you check your QGIS server logs ? You should see the expression being evaluated. Maybe it gives an hint.

Gustry commented 1 year ago

It works well on the test project form_edition_value_relation_field.qgs

2023-10-18 13:52:19,680 DEBUG   [57]    Qgis: Lizmap: Fetching /srv/projects/tests/form_edition_value_relation_field.qgs.cfg cfg file with last modified timestamp : 1697636723.2394717
2023-10-18 13:52:19,680 DEBUG   [57]    Qgis: Lizmap: No acl defined in Lizmap config
2023-10-18 13:52:19,680 DEBUG   [57]    Qgis: Server: FIELDS:code,label
2023-10-18 13:52:19,680 DEBUG   [57]    Qgis: Server: FILTER:intersects($geometry, centroid(@current_geometry))
2023-10-18 13:52:19,680 DEBUG   [57]    Qgis: Server: FORM_FEATURE:{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[0.305070750024655,47.89601575850115],[1.5291213472474636,47.53621582892768],[0.9111540554456543,46.776610723827396],[0.305070750024655,47.89601575850115]]]},"properties":[]}

Versions :

gioman commented 1 year ago

@Gustry

15:12:05 INFO Server[3596]: FIELDS:distrito,distrito
15:12:05 INFO Server[3596]: FILTER:intersects($geometry, centroid(@current_geometry))
15:12:05 INFO Server[3596]: FORM_FEATURE:{"type":"Feature","geometry":null,"properties":[]}
15:12:05 INFO Server[3596]: LAYER:distritos
15:12:05 INFO Server[3596]: LIZMAP_OVERRIDE_FILTER:1
15:12:05 INFO Server[3596]: LIZMAP_USER:admin
15:12:05 INFO Server[3596]: LIZMAP_USER_GROUPS:admins
15:12:05 INFO Server[3596]: MAP:/mnt/lm_repos/repo1/teste2.qgs
15:12:05 INFO Server[3596]: REQUEST:getFeatureWithFormScope
15:12:05 INFO Server[3596]: SERVICE:EXPRESSION
15:12:05 INFO Lizmap[3596]: Request headers provided
15:12:05 INFO Lizmap[3596]: No lizmap user groups in request headers
15:12:05 INFO Lizmap[3596]: Lizmap user groups in parameters : admins
15:12:05 INFO Lizmap[3596]: Request headers provided
15:12:05 INFO Lizmap[3596]: No lizmap user login in request headers
15:12:05 INFO Lizmap[3596]: Lizmap user login in parameters : admin
15:12:05 INFO WfsOutputExtension[3596]: responseComplete ran in 0.0s
15:12:05 INFO Server[3596]: Request finished in 225 ms
gioman commented 1 year ago

Version 3.6.6 Date 2023-10-04 QGIS Server Version Number 3.28.11 Name Firenze Commit ID b02458a196 Py-QGIS-Server not used Plugins Plugin Version atlasprint 3.3.2 Lizmap server 2.8.1 wfsOutputExtension 1.8.0

Gustry commented 1 year ago

15:12:05 INFO Server[3596]: FILTER:intersects($geometry, centroid(@current_geometry)) 15:12:05 INFO Server[3596]: FORM_FEATURE:{"type":"Feature","geometry":null,"properties":[]}

So indeed, the geometry is not sent (null) to QGIS server for evaluation

But I was not able to replicate with dataset provided in #3931

gioman commented 1 year ago

But I was not able to replicate with dataset provided in #3931

@Gustry I tried with the table quartiers and sousquartiers as defined here (but both on epsg 2154 as in your dataset quartiers is in 4326 and so the expression would anyway fail without transforming the features)

https://raw.githubusercontent.com/3liz/lizmap-web-client/2338bce7cef0e4cda04df96d7c7dbab3a025d1aa/tests/qgis-projects/tests/tests_dataset.sql

and I see the same (means the combo-box is not populated). Seems there is something else at play. Would you mind share your .qgs and .cfg (I can do manually the necessary changes)?

Gustry commented 1 year ago

Would you mind share your .qgs and .cfg (I can do manually the necessary changes)?

It's in the PR, which is based on my fork : https://github.com/Gustry/lizmap-web-client/tree/centroid

It's this test project : https://demo.snap.lizmap.com/lizmap_3_7/index.php/view/map?repository=testsrepository&project=form_edition_value_relation_field

But I haven't transfered the new polygon layer from the PR #3931

Gustry commented 1 year ago

I can give it a try on 3.6, sorry.

gioman commented 1 year ago

It's in the PR, which is based on my fork : https://github.com/Gustry/lizmap-web-client/tree/centroid

@Gustry your data and my data work with your project, so I'm definitely lost as I can't see any major difference in the project configs and .cfg configs.

gioman commented 1 year ago

I'll close because is definitely something on my side (does not means there is anything wrong with my installation, but there is something interfering at a project level).

Gustry commented 1 year ago

No problem, it's not easy to debug and/or to hit the bottleneck sometimes.

At least, I could try the polygon with a centroid, which should be a common use case.