changeset 5081:89834f645de3 time-sliding

merge default into time-sliding branch
author Fadi Abbud <fadi.abbud@intevation.de>
date Wed, 18 Mar 2020 10:01:01 +0100
parents faa1521e597b (current diff) 36a3dce20232 (diff)
children c4ebb6ccc588
files
diffstat 3 files changed, 19 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- 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 {
--- 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 (
--- 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;