Mercurial > gemma
changeset 5023:776db50c01f0
Fix repairing geometries
ST_Transform() and ST_MakeValid() can both collapse geometries to a
lower dimension than polygonal and the output of ST_Transform() can
be invalid geometries. Respect that in the order in which functions
are stacked here.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Mon, 16 Mar 2020 16:48:17 +0100 |
parents | e8661379a6c5 |
children | 36a3dce20232 |
files | pkg/imports/fd.go |
diffstat | 1 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/imports/fd.go Mon Mar 16 15:24:08 2020 +0100 +++ b/pkg/imports/fd.go Mon Mar 16 16:48:17 2020 +0100 @@ -174,17 +174,16 @@ min_depth, date_info, source_organization) -SELECT ST_Transform(dmp.geom, 4326), $3, $4, $5, $6, $7, $8 +SELECT dmp.geom, $3, $4, $5, $6, $7, $8 FROM ST_GeomFromWKB($1, $2::integer) AS new_fd (new_fd), - ST_Dump( + ST_Dump(ST_CollectionExtract(ST_MakeValid(ST_Transform( CASE WHEN pg_has_role('sys_admin', 'MEMBER') - THEN ST_MakeValid(ST_Transform( - new_fd, best_utm(ST_Transform(new_fd, 4326)))) - ELSE ST_CollectionExtract(ST_Intersection( + THEN new_fd + ELSE ST_Intersection( (SELECT ST_Buffer(a, -0.0001) FROM resp), - ST_MakeValid(ST_Transform(new_fd, (SELECT ST_SRID(a) FROM resp)))), - 3) - END) AS dmp + ST_MakeValid(ST_Transform(new_fd, (SELECT ST_SRID(a) FROM resp)))) + END, + 4326)), 3)) AS dmp RETURNING id, ST_X(ST_Centroid(area::geometry)), ST_Y(ST_Centroid(area::geometry)) @@ -271,6 +270,9 @@ feedback.Info("Using EPSG: %d", epsg) + feedback.Info( + "Found %d features in data source", len(rfc.Features)) + savepoint := Savepoint(ctx, tx, "feature") features: