Not entirely sure what kind of rules does QGIS need to consume SQL views
So I've had some success in using an id column and a geometry column but now that I'm doing something a bit more complex, it's just not working at all, returning the error that the layer is not valid and cannot be added to the map
Now when I do an export of my view, and then add it to QGIS as a layer using the "add delimited text layer", it just works fine, so this really makes it confusing for me
My query is:
CREATE OR REPLACE VIEW build.project_area AS WITH hulls(hull, units, id, name) AS ( SELECT st_concavehull(st_collect(pt.geom), 0.99::double precision) AS hull, count(*) AS units, pt.id, name FROM pt JOIN table2 USING (id) GROUP BY id, name ) SELECT hulls.id, st_geometrytype(hulls.hull) AS hull_type, CASE WHEN st_geometrytype(hulls.hull) = 'ST_Polygon'::text THEN hulls.hull::geometry(Polygon,27700) ELSE st_buffer(hulls.hull, 25::double precision)::geometry(Polygon,27700) END AS geom, hulls.units, hulls.name FROM hulls;
Basically this query turns points that have the same attribute into a concavehull.
In case points are not a polygon, then it turns the points into a buffer.
How to make this work on QGIS?
EDIT: apparently changing from st_concavehull to st_convexhull makes the whole view work. I'll delete this if there's no input to this soon