view schema/updates/1204/03.geoserver-views.sql @ 5560:f2204f91d286

Join the log lines of imports to the log exports to recover data from them. Used in SR export to extract information that where in the meta json but now are only found in the log.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 09 Feb 2022 18:34:40 +0100
parents 0b01fd83bc3b
children
line wrap: on
line source

CREATE OR REPLACE VIEW waterway.sounding_results_areas_geoserver AS
  SELECT bottleneck_id,
         date_info,
         height,
         CAST(areas AS geometry(multipolygon, 4326)) as areas
  FROM waterway.sounding_results_iso_areas ia
  JOIN waterway.sounding_results sr ON sr.id = ia.sounding_result_id;

CREATE OR REPLACE VIEW waterway.sounding_differences AS
    SELECT
        sd.id           AS id,
        bn.objnam       AS objnam,
        srm.date_info   AS minuend,
        srs.date_info   AS subtrahend,
        sdia.height     AS height,
        CAST(sdia.areas AS geometry(multipolygon, 4326)) AS areas
    FROM caching.sounding_differences sd
        JOIN caching.sounding_differences_iso_areas sdia
            ON sd.id = sdia.sounding_differences_id
        JOIN waterway.sounding_results srm
            ON sd.minuend = srm.id
        JOIN waterway.sounding_results srs
            ON sd.subtrahend = srs.id
        JOIN waterway.bottlenecks bn
            ON srm.bottleneck_id = bn.bottleneck_id
                AND srm.date_info::timestamptz <@ bn.validity;

GRANT SELECT ON ALL TABLES IN SCHEMA public, users, waterway TO waterway_user;