changeset 3585:479da494bc09

SR import: access beam-type parameter supplied by client. TODO: Implement single beam code path.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 04 Jun 2019 11:14:33 +0200
parents 7b15a6dd4ae5
children b9adb0ea4c41
files pkg/controllers/srimports.go pkg/imports/sr.go pkg/models/sr.go
diffstat 3 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/controllers/srimports.go	Tue Jun 04 09:50:24 2019 +0200
+++ b/pkg/controllers/srimports.go	Tue Jun 04 11:14:33 2019 +0200
@@ -23,6 +23,7 @@
 	"os"
 	"path/filepath"
 	"strconv"
+	"strings"
 	"sync"
 	"time"
 
@@ -96,6 +97,19 @@
 		sr.Bottleneck = &v
 	}
 
+	if v := req.FormValue("beam-type"); v != "" {
+		var singleBeam bool
+		switch strings.ToLower(v) {
+		case "multibeam":
+			singleBeam = false
+		case "singlebeam":
+			singleBeam = true
+		default:
+			return fmt.Errorf("Unknown beam-type '%s'", v)
+		}
+		sr.SingleBeam = &singleBeam
+	}
+
 	return nil
 }
 
--- a/pkg/imports/sr.go	Tue Jun 04 09:50:24 2019 +0200
+++ b/pkg/imports/sr.go	Tue Jun 04 11:14:33 2019 +0200
@@ -58,6 +58,8 @@
 	// DepthReference if given overides the DepthReference value
 	// from the meta.json.
 	DepthReference *string `json:"depth-reference,omitempty"`
+	// SingleBeam indicates that the sounding is a single beam scan.
+	SingleBeam *bool `json:"single-beam,omitempty"`
 }
 
 const (
@@ -174,6 +176,10 @@
 `
 )
 
+func (sr *SoundingResult) isSingleBeam() bool {
+	return sr.SingleBeam != nil && *sr.SingleBeam
+}
+
 // Do executes the actual sounding result import.
 func (sr *SoundingResult) Do(
 	ctx context.Context,
@@ -250,6 +256,14 @@
 		return nil, errors.New("XYZ does not contain any vertices")
 	}
 
+	if sr.isSingleBeam() {
+		feedback.Info("Processing as single beam scan.")
+	} else {
+		feedback.Info("Processing as multi beam scan.")
+	}
+
+	// TODO: Implement single beam code path.
+
 	// Is there a boundary shapefile in the ZIP archive?
 	polygon, err := loadBoundary(z)
 	if err != nil {
@@ -454,6 +468,9 @@
 	if sr.DepthReference != nil {
 		m.DepthReference = *sr.DepthReference
 	}
+	if sr.SingleBeam != nil {
+		m.SingleBeam = *sr.SingleBeam
+	}
 
 	return &m, nil
 }
--- a/pkg/models/sr.go	Tue Jun 04 09:50:24 2019 +0200
+++ b/pkg/models/sr.go	Tue Jun 04 11:14:33 2019 +0200
@@ -31,6 +31,7 @@
 		Bottleneck     string `json:"bottleneck"`
 		EPSG           uint   `json:"epsg"`
 		DepthReference string `json:"depth-reference"`
+		SingleBeam     bool   `json:"single-beam"`
 	}
 )