view schema/updates/1438/01.remove_duplicate_fairway_areas.sql @ 5559:ce9a9a1bf92f

Make invalid output of ISRSrange_area() less likely, next try Since ST_MakeValid() might return a collection of lower-to-equal dimension geometries, distill only the polygons from it. This should prevent respective errors when trying to save the result to a column of type MultiPolygon.
author Tom Gottfried <tom@intevation.de>
date Thu, 02 Dec 2021 12:37:33 +0100
parents 20f338cb4d48
children
line wrap: on
line source

-- Remove entries that do not suffice the requirements set out by the
-- constraint trigger on fairway_dimensions, but that could be left over
-- from an import run before the constraint trigger was in place
DELETE FROM waterway.fairway_dimensions fd
    USING waterway.fairway_dimensions fd_self
    WHERE ST_Equals(CAST(fd.area AS geometry), CAST(fd_self.area AS geometry))
        AND fd.validity && fd_self.validity
        AND fd.staging_done = fd_self.staging_done
        AND fd.id < fd_self.id