Mercurial > gemma
diff pkg/imports/wa.go @ 2855:8a8a929182f9
Enable import of axis and area independently from areas of responsibility
In preparation of generating the areas of responsibility from
data previously imported by a sys_admin! Having the CTE as an item
in the FROM-list prevents the SELECT from returning any rows if
the CTE returns no rows. Thus, use the CTE only in scalar subqueries
that are relevant only if the statement is executed by somebody
without sys_admin role.
Also introduced an ST_CollectionExtract() in the axis INSERT because here
too, the intersection is not guaranteed to have the right dimensionality.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 28 Mar 2019 17:19:27 +0100 |
parents | 1b6840093eac |
children | 93fa55bce126 |
line wrap: on
line diff
--- a/pkg/imports/wa.go Thu Mar 28 17:19:07 2019 +0100 +++ b/pkg/imports/wa.go Thu Mar 28 17:19:27 2019 +0100 @@ -99,17 +99,16 @@ WHERE country = users.current_user_country() ) INSERT INTO waterway.waterway_area (area, catccl, dirimp) -SELECT ST_Transform(clipped.geom, 4326)::geography, $3, $4 - FROM resp, - ST_CollectionExtract(ST_MakeValid(ST_Transform( - ST_GeomFromWKB($1, $2::integer), t)), 3) AS new_area (new_area), - LATERAL (SELECT (ST_Dump( +SELECT dmp.geom, $3, $4 + FROM ST_GeomFromWKB($1, $2::integer) AS new_area (new_area), + ST_Dump(ST_Transform(ST_CollectionExtract( CASE WHEN pg_has_role('sys_admin', 'MEMBER') - THEN new_area - ELSE ST_Intersection(a, new_area) - END - )).geom AS geom - ) AS clipped + THEN ST_MakeValid(ST_Transform(new_area, + best_utm(ST_Transform(new_area, 4326)))) + ELSE ST_Intersection((SELECT a FROM resp), + ST_MakeValid(ST_Transform(new_area, (SELECT t FROM resp)))) + END, + 3), 4326)) AS dmp ` )