diff pkg/imports/sr.go @ 4629:7acb03e8a737

SR import: Store in sounding_result table if import is single or multi beam.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 10 Oct 2019 17:23:00 +0200
parents c657dec6b0fa
children 0ed1489af8b6
line wrap: on
line diff
--- a/pkg/imports/sr.go	Thu Oct 10 17:10:14 2019 +0200
+++ b/pkg/imports/sr.go	Thu Oct 10 17:23:00 2019 +0200
@@ -124,7 +124,8 @@
   bottleneck_id,
   date_info,
   depth_reference,
-  area
+  area,
+  surtyp
 ) SELECT
   bottleneck_id,
   $2::date,
@@ -134,7 +135,8 @@
       ST_Transform(ST_ConcaveHull(ST_Force2D(ST_GeomFromWKB($4, $6::integer)), 0.7), 4326)::geography
     ELSE
       ST_MakeValid(ST_Transform(ST_GeomFromWKB($5, $6::integer), 4326))::geography
-    END)
+    END),
+  $7
 FROM waterway.bottlenecks
 WHERE objnam = $1 AND validity @> CAST($2 AS timestamptz)
 RETURNING
@@ -214,6 +216,13 @@
 	return sr.SingleBeam != nil && *sr.SingleBeam
 }
 
+func (sr *SoundingResult) surtype() string {
+	if sr.singleBeam() {
+		return "single"
+	}
+	return "multi"
+}
+
 func (sr *SoundingResult) negateZ() bool {
 	return sr.NegateZ != nil && *sr.NegateZ
 }
@@ -333,31 +342,15 @@
 	}
 	defer tx.Rollback()
 
-	var summary interface{}
-
-	if sr.singleBeam() {
-		summary, err = sr.processScan(
-			ctx,
-			tx,
-			feedback,
-			true,
-			importID,
-			m,
-			xyz,
-			boundary,
-		)
-	} else {
-		summary, err = sr.processScan(
-			ctx,
-			tx,
-			feedback,
-			false,
-			importID,
-			m,
-			xyz,
-			boundary,
-		)
-	}
+	summary, err := sr.processScan(
+		ctx,
+		tx,
+		feedback,
+		importID,
+		m,
+		xyz,
+		boundary,
+	)
 	if err != nil {
 		return nil, err
 	}
@@ -378,14 +371,13 @@
 	ctx context.Context,
 	tx *sql.Tx,
 	feedback Feedback,
-	singleBeam bool,
 	importID int64,
 	m *models.SoundingResultMeta,
 	xyz octree.MultiPointZ,
 	boundary polygonSlice,
 ) (interface{}, error) {
 
-	if singleBeam {
+	if sr.singleBeam() {
 		feedback.Info("Processing as single beam scan.")
 	} else {
 		feedback.Info("Processing as multi beam scan.")
@@ -498,7 +490,7 @@
 		removed = str.Clip(&clippingPolygon)
 	}
 
-	if singleBeam {
+	if sr.singleBeam() {
 
 		// Build the first mesh to generate random points on.
 
@@ -604,6 +596,7 @@
 		nil,
 		clippingPolygonWKB,
 		epsg,
+		sr.surtype(),
 	).Scan(
 		&id,
 		&lat,