view schema/updates/1204/01.create-iso-areas.sql @ 5030:737d7859dd86

Store fairway dimensions as MultiPolygon This avoids storing a single invalid geometry from the data source as multiple valid geometries with duplicate attribute sets. The previous behaviour was not correctly handled in import tracking, because only the ID of the first item in a set of multiple geometries generated from a single entry from the data source was tracked.
author Tom Gottfried <tom@intevation.de>
date Wed, 18 Mar 2020 18:42:30 +0100
parents 26e9846ed69f
children
line wrap: on
line source

CREATE TABLE waterway.sounding_results_iso_areas (
    sounding_result_id int NOT NULL REFERENCES waterway.sounding_results
        ON DELETE CASCADE,
    height numeric NOT NULL,
    areas geography(MULTIPOLYGON, 4326) NOT NULL,
    -- TODO: generate valid simple features and add constraint:
        -- CHECK(ST_IsSimple(CAST(areas AS geometry))),
    PRIMARY KEY (sounding_result_id, height)
);

CREATE TABLE caching.sounding_differences_iso_areas (
    sounding_differences_id int NOT NULL REFERENCES caching.sounding_differences(id)
                                ON DELETE CASCADE,
    height numeric NOT NULL,
    areas  geography(MULTIPOLYGON, 4326) NOT NULL,
    PRIMARY KEY (sounding_differences_id, height)
);

GRANT INSERT, UPDATE, DELETE ON waterway.sounding_results_iso_areas
    TO waterway_admin;

GRANT SELECT ON waterway.sounding_results_iso_areas
    TO waterway_user;

GRANT SELECT, UPDATE, DELETE, INSERT ON caching.sounding_differences_iso_areas
    TO waterway_user;