Mercurial > gemma
comparison pkg/imports/dma.go @ 2933:a5642ee4c6d0
Let sys_admin import distance marks ashore without restriction
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 04 Apr 2019 14:08:01 +0200 |
parents | 074f2bb85584 |
children | 78affd725ba5 |
comparison
equal
deleted
inserted
replaced
2932:173ce013a021 | 2933:a5642ee4c6d0 |
---|---|
78 deleteDistanceMarksSQL = ` | 78 deleteDistanceMarksSQL = ` |
79 WITH resp AS ( | 79 WITH resp AS ( |
80 SELECT users.current_user_area_utm() AS a | 80 SELECT users.current_user_area_utm() AS a |
81 ) | 81 ) |
82 DELETE FROM waterway.distance_marks | 82 DELETE FROM waterway.distance_marks |
83 WHERE ST_Covers( | 83 WHERE pg_has_role('sys_admin', 'MEMBER') |
84 (SELECT a FROM resp), | 84 OR ST_Covers((SELECT a FROM resp), |
85 ST_Transform(geom::geometry, (SELECT ST_SRID(a) FROM resp))) | 85 ST_Transform(geom::geometry, (SELECT ST_SRID(a) FROM resp))) |
86 ` | 86 ` |
87 insertDistanceMarksSQL = ` | 87 insertDistanceMarksSQL = ` |
88 WITH resp AS ( | 88 WITH resp AS ( |
89 SELECT users.current_user_area_utm() AS a | 89 SELECT users.current_user_area_utm() AS a |
90 ) | 90 ) |
91 INSERT INTO waterway.distance_marks (geom, catdis) | 91 INSERT INTO waterway.distance_marks (geom, catdis) |
92 SELECT ST_Transform(clipped.geom, 4326)::geography, $3 FROM ( | 92 SELECT ST_Transform( |
93 SELECT (ST_Dump( | 93 CASE WHEN pg_has_role('sys_admin', 'MEMBER') |
94 ST_Intersection( | 94 THEN new_dma |
95 (SELECT a FROM resp), | 95 ELSE ST_Intersection((SELECT a FROM resp), |
96 ST_Transform( | 96 ST_Transform(new_dma, (SELECT ST_SRID(a) FROM resp))) |
97 ST_GeomFromWKB($1, $2::integer), | 97 END, |
98 (SELECT ST_SRID(a) FROM resp) | 98 4326), |
99 ) | 99 $3 |
100 ) | 100 FROM ST_GeomFromWKB($1, $2::integer) AS new_dma (new_dma) |
101 )).geom AS geom | |
102 ) AS clipped | |
103 WHERE clipped.geom IS NOT NULL | |
104 RETURNING id | 101 RETURNING id |
105 ` | 102 ` |
106 ) | 103 ) |
107 | 104 |
108 // Do executes the actual fairway dimension import. | 105 // Do executes the actual fairway dimension import. |