# HG changeset patch # User Fadi Abbud # Date 1584522061 -3600 # Node ID 89834f645de31ab8bfd4430192ab27fd45e8507d # Parent faa1521e597bfb294fc0ae611cb1092cb5779198# Parent 36a3dce202321eb28e556cd05c10d5993d7bc763 merge default into time-sliding branch diff -r faa1521e597b -r 89834f645de3 pkg/imports/fd.go --- a/pkg/imports/fd.go Mon Mar 16 18:20:41 2020 +0100 +++ b/pkg/imports/fd.go Wed Mar 18 10:01:01 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: @@ -353,7 +355,9 @@ } if outside > 0 { - feedback.Info("Features outside responsibility area: %d", outside) + feedback.Info( + "Features outside responsibility area or no valid polygon: %d", + outside) } if features == 0 { diff -r faa1521e597b -r 89834f645de3 pkg/imports/wx.go --- a/pkg/imports/wx.go Mon Mar 16 18:20:41 2020 +0100 +++ b/pkg/imports/wx.go Wed Mar 18 10:01:01 2020 +0100 @@ -61,6 +61,9 @@ ), t AS ( UPDATE waterway.waterway_axis SET last_found = current_timestamp + -- The first condition is just to help the PostgreSQL query planner + -- to avoid evaluating more costly conditions including those + -- introduced by row level security policies: WHERE (SELECT new_ax FROM g) IS NOT NULL AND validity @> current_timestamp AND ( diff -r faa1521e597b -r 89834f645de3 schema/updates/1426/01.historicise_axis.sql --- a/schema/updates/1426/01.historicise_axis.sql Mon Mar 16 18:20:41 2020 +0100 +++ b/schema/updates/1426/01.historicise_axis.sql Wed Mar 18 10:01:01 2020 +0100 @@ -3,9 +3,10 @@ CHECK (NOT isempty(validity)), ADD last_found timestamp with time zone NOT NULL DEFAULT current_timestamp; --- Assume existing entries have been valid since last import +-- Assume existing entries have been valid since last successful import UPDATE waterway.waterway_axis SET validity = tstzrange( - (SELECT max(changed) FROM import.imports WHERE kind = 'wx'), + (SELECT max(changed) FROM import.imports + WHERE kind = 'wx' AND state = CAST('accepted' AS import_state)), NULL); DROP TRIGGER waterway_axis_wtwaxs_unique ON waterway.waterway_axis;