comparison pkg/imports/wa.go @ 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 5062ccb2381d
children 046a07a33b19
comparison
equal deleted inserted replaced
4843:42e7088824be 4844:58642179e896
99 SELECT users.current_user_area_utm() AS a 99 SELECT users.current_user_area_utm() AS a
100 ) 100 )
101 INSERT INTO waterway.waterway_area (area, catccl, dirimp) 101 INSERT INTO waterway.waterway_area (area, catccl, dirimp)
102 SELECT dmp.geom, $3, $4 102 SELECT dmp.geom, $3, $4
103 FROM ST_GeomFromWKB($1, $2::integer) AS new_area (new_area), 103 FROM ST_GeomFromWKB($1, $2::integer) AS new_area (new_area),
104 ST_Dump(ST_Transform(ST_CollectionExtract( 104 ST_Dump(ST_CollectionExtract(ST_MakeValid(ST_Transform(
105 CASE WHEN pg_has_role('sys_admin', 'MEMBER') 105 CASE WHEN pg_has_role('sys_admin', 'MEMBER')
106 THEN ST_MakeValid(ST_Transform(new_area, 106 THEN new_area
107 best_utm(ST_Transform(new_area, 4326))))
108 ELSE ST_Intersection((SELECT a FROM resp), 107 ELSE ST_Intersection((SELECT a FROM resp),
109 ST_MakeValid(ST_Transform(new_area, (SELECT ST_SRID(a) FROM resp)))) 108 ST_MakeValid(ST_Transform(new_area, (SELECT ST_SRID(a) FROM resp))))
110 END, 109 END,
111 3), 4326)) AS dmp 110 4326)), 3)) AS dmp
112 RETURNING id 111 RETURNING id
113 ` 112 `
114 ) 113 )
115 114
116 // Do executes the actual waterway axis import. 115 // Do executes the actual waterway axis import.