Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: correct attribute form setup for area calculations? (area($geometry) #3883

Closed
1 task done
timbo-barnes opened this issue Sep 20, 2023 · 5 comments
Closed
1 task done

Comments

@timbo-barnes
Copy link

timbo-barnes commented Sep 20, 2023

What is the question?

I've tried every combination of attribute form layout to try and write the area value of an added or edited polygon to the attribute table without success.
My layer is a multipolygon with a column called area_ha of double (int8) type. The attribute form for this field uses a Text Edit widget.
I've set up layer edition (editing) on this layer in the plugin- All the other editing tasks work fine (i.e. adding/editing geometry, changing other attributes)

  • The issue isn't adding attributes themselves (other fields works, including date input to a date field using/setting the default to now())
  • The area calculations work fine in QGIS
  • I've tried different methods (i.e. format_number(area($geometry)/10000,2) vs round($area/10000,2))
  • I've tried an 'editable' field in the form and not
  • I've tried 'Apply default value on update' or not.

Nothing works- Has anyone had this working?

Data is in Postgis as a multipolygon, 2193 (New Zealand Transverse Mercator)

Versions

Versions :

  • Lizmap Web Client : 3.6.3
  • Lizmap plugin : 3.16.4
  • QGIS Desktop : 3.30.1
  • QGIS Server : 3.30.3
  • Py-QGIS-Server : not used
  • QGIS Server plugin atlasprint : 3.3.2
  • QGIS Server plugin lizmap_server : 2.7.1
  • QGIS Server plugin wfsOutputExtension : 1.7.1

Check Lizmap plugin

  • I have done the step just before in the Lizmap QGIS desktop plugin before opening this ticket. Otherwise, my ticket is not considered valid and might get closed.

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

No response

Operating system

Ubuntu Linux 22.04.2

Browsers

Chrome

Browsers version

Chrome Version 117.0.5938.89 (Official Build) (64-bit)

Relevant log output

No response

@gioman
Copy link
Contributor

gioman commented Sep 20, 2023

Nothing works- Has anyone had this working?

@timbo-barnes my understanding is that doesn't work because the attribute dialog form is shown before the geometry is actually drawn and finished (while in QGIS the user always first draws a feature and then the attributes dialog shows up).

@Gustry
Copy link
Member

Gustry commented Sep 20, 2023

For sure "Apply on update" is not supported.

Please have a look to the discussion #3226

Some documentation is needed to write what is supported in LWC about expressions in forms.

@Gustry
Copy link
Member

Gustry commented Sep 20, 2023

Both in your web browser and QGIS server, check HTTP requests, you should see the "SERVICE=EXPRESSIONS" requests to evaluate expressions.

@timbo-barnes
Copy link
Author

OK, I've got around this by using a database trigger on insert or update which works- Perhaps the documentation could be updated to note that use of geom field and/or Apply on Update isn't supported currently?

@Gustry
Copy link
Member

Gustry commented Sep 22, 2023

Perhaps the documentation could be updated to note that use of geom field and/or Apply on Update isn't supported currently?

Yes of course, the documentation is on GitHub as well https://github.com/3liz/lizmap-documentation 😉
Feel free to provide a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants