changeset 3652:f415c5ed60f6 single-beam

Another attempt to fix the ST_IsValid check contstraint problem ... and also failed.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 13 Jun 2019 16:36:21 +0200
parents c368a9a20478
children 955e2371cf28
files pkg/imports/sr.go
diffstat 1 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/imports/sr.go	Thu Jun 13 16:04:46 2019 +0200
+++ b/pkg/imports/sr.go	Thu Jun 13 16:36:21 2019 +0200
@@ -128,7 +128,7 @@
     CASE WHEN $5::bytea IS NULL THEN
       ST_Transform(ST_ConcaveHull(ST_Force2D(ST_GeomFromWKB($4, $6::integer)), 0.7), 4326)::geography
     ELSE
-      ST_Transform(ST_GeomFromWKB($5, $6::integer), 4326)::geography
+      ST_MakeValid(ST_Transform(ST_GeomFromWKB($5, $6::integer), 4326))::geography
     END)
 RETURNING
   id,
@@ -151,6 +151,9 @@
   ST_AsBinary(ST_Buffer(ST_MakeValid(ST_GeomFromWKB($1, $2::integer)), 0.0)),
   ST_AsBinary(ST_Buffer(ST_MakeValid(ST_GeomFromWKB($1, $2::integer)), 0.1))`
 
+	whatsWrongSQL = `
+SELECT ST_IsValidReason(CAST(ST_Transform(ST_GeomFromWKB($1, $2::integer), 4326)::geography AS geometry))`
+
 	insertContourSQL = `
 INSERT INTO waterway.sounding_results_contour_lines (
   sounding_result_id,
@@ -388,6 +391,18 @@
 
 		clippingPolygon.FromLineStringZ(polygon)
 
+		var wrong string
+		if err := tx.QueryRowContext(
+			ctx,
+			whatsWrongSQL,
+			clippingPolygon.AsWKB(),
+			epsg,
+		).Scan(&wrong); err != nil {
+			return nil, err
+		}
+
+		log.Printf("!!!!!!!!: whats wrong: %s\n", wrong)
+
 		var repaired, buffered []byte
 
 		if err := tx.QueryRowContext(