view schema/updates/1423/01.axis_as_multilinestring.sql @ 5009:e8b2dc771f9e

Store axis as MultiLinestring MultiLinestrings could already be imported but we stored them as multiple Linestrings with identical attributes and even stored Linestrings with self-intersections as multiple single Linestrings with identical attributes. Avoid both by storing as MultiLinestring. In passing, removed unnecessary processing steps in the INSERT statemet for the sys_admin case and ensured that attempts to convert to valid simple features are made after transformation, which might lead to invalid features. Since isrsrange_axis() relies on single Linestrings for linear referencing, add an extra ST_Dump().
author Tom Gottfried <tom@intevation.de>
date Wed, 11 Mar 2020 17:11:23 +0100
parents
children
line wrap: on
line source

-- Cannot alter type of a column used in a trigger definition
DROP TRIGGER waterway_axis_wtwaxs_unique ON waterway.waterway_axis;

ALTER TABLE waterway.waterway_axis
    ALTER wtwaxs TYPE geography(MULTILINESTRING, 4326)
        USING ST_Multi(CAST(wtwaxs AS geometry));

-- Re-create trigger
CREATE CONSTRAINT TRIGGER waterway_axis_wtwaxs_unique
    AFTER INSERT OR UPDATE OF wtwaxs ON waterway.waterway_axis
    FOR EACH ROW EXECUTE FUNCTION prevent_st_equals('wtwaxs');