I have a Problem. I have a table with a geometry collection (polygon and point).
QGIS can not read the geometry collection, so I want to create a view for the polygon type and the point type. My SQL function for the polygon type looks like this:
CREATE VIEW parcel_polygons AS (
SELECT
row_number() OVER(ORDER BY inspire_local DESC) AS OID
, inspire_local
, inspire_namespace
, label
, nationalcadref
, areavalue
, validfrom
, beginlifespanversion
, zoning
, geom::geometry(Polygon, 25833)
FROM cp_parcel_postgis
WHERE GeometryType(geom) = ‘GEOMETRYCOLLECTION(POLYGON)’
)
I do not get any errors and the view is created. Unfortunately, the view is empty.
What am I doing wrong?
vielen Dank für deine schnelle Antwort. Ich habe das Problem realtiv gelöst mit ST_Dump.
CREATE VIEW parcel_polygons_view AS (
SELECT
row_number() OVER(ORDER BY inspire_local DESC) AS OID
, inspire_local
, inspire_namespace
, label
, nationalcadref
, areavalue
, validfrom
, beginlifespanversion
, zoning
, (st_dump(geom)).geom as geom
FROM ´
WHERE GeometryType(geom) = ‘GEOMETRYCOLLECTION’
)
Jedoch habe ich nun das Problem, dass ich in meiner geom Spalte des Views Geometrietypen Polygon und Point sind und meine ID Spalte (OID) sich die Ziffern doppeln. Wenn ich die Zeilen löschen könnte, wäre das Problem gelöst. Doch wie lösche ich Zeilen in einem View?
Leider hat die folgende Erstellung einer Regel nicht zum erfolg geführt:
CREATE RULE point_delete AS ON DELETE TO parcel_polygons_view DO INSTEAD(
DELETE FROM parcel_polygons_view WHERE GeometryType(geom) = ‘POINT’;
);