# HG changeset patch # User Sascha L. Teichmann # Date 1559639673 -7200 # Node ID 479da494bc099eef0a4537c35e8e2e04cfad6d12 # Parent 7b15a6dd4ae56c8aeb4dbe3a964e1f5ccc398e44 SR import: access beam-type parameter supplied by client. TODO: Implement single beam code path. diff -r 7b15a6dd4ae5 -r 479da494bc09 pkg/controllers/srimports.go --- 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 } diff -r 7b15a6dd4ae5 -r 479da494bc09 pkg/imports/sr.go --- 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 } diff -r 7b15a6dd4ae5 -r 479da494bc09 pkg/models/sr.go --- 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"` } )