I am working with a point layer which has a set of field where are stored some information about a rectangular geometry. This information is width, length and rotation of the shortest side of the rectangle. Given that the point is always placed on the centroid of the rectangle, is it possible for QGIS to automatically draw a polygon on another layer every time one point is inserted? Is there a way to implement this function in a QField project?
1 Answer
As Babel commented, either geometry generator (for visualisation only) or a virtual layer. If you are using a format such as GeoPackage or PostGIS that suports triggers, that would work as well.
The virtual layer SQL would look something like the below, replacing myWidth, myLength, myRotation, and myLayer with your attribute and layer names.
select
rotate(
geom_from_wkt ('POLYGON(('||
x(geometry) - "myWidth" / 2 ||' '|| y(geometry) - "myLength" / 2 ||','||
x(geometry) - "myWidth" / 2 ||' '|| y(geometry) + "myLength" / 2 ||','||
x(geometry) + "myWidth" / 2 ||' '|| y(geometry) + "myLength" / 2 ||','||
x(geometry) + "myWidth" / 2 ||' '|| y(geometry) - "myLength" / 2 ||','||
x(geometry) - "myWidth" / 2 ||' '|| y(geometry) - "myLength" / 2 ||'))
'),
"myRotation") as geometry
from myLayer