changeset 4844:58642179e896

Fix possibly invalid geometry output from transformation Transformation to the final SRS (EPSG:4326) might as well generate invalid geometries. Thus, fix the geometries afterwards. The inner ST_MakeValid is still needed to get correct intersection results, but the intermediate transformation to some UTM projection without any further processing is useless.
author Tom Gottfried <tom@intevation.de>
date Wed, 13 Nov 2019 13:51:10 +0100
parents 42e7088824be
children 8c46b845b406
files pkg/imports/wa.go
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/imports/wa.go	Wed Nov 13 10:56:51 2019 +0100
+++ b/pkg/imports/wa.go	Wed Nov 13 13:51:10 2019 +0100
@@ -101,14 +101,13 @@
 INSERT INTO waterway.waterway_area (area, catccl, dirimp)
 SELECT dmp.geom, $3, $4
   FROM ST_GeomFromWKB($1, $2::integer) AS new_area (new_area),
-    ST_Dump(ST_Transform(ST_CollectionExtract(
+    ST_Dump(ST_CollectionExtract(ST_MakeValid(ST_Transform(
       CASE WHEN pg_has_role('sys_admin', 'MEMBER')
-        THEN ST_MakeValid(ST_Transform(new_area,
-          best_utm(ST_Transform(new_area, 4326))))
+        THEN new_area
         ELSE ST_Intersection((SELECT a FROM resp),
           ST_MakeValid(ST_Transform(new_area, (SELECT ST_SRID(a) FROM resp))))
         END,
-      3), 4326)) AS dmp
+      4326)), 3)) AS dmp
 RETURNING id
 `
 )