diff pkg/imports/sr.go @ 3946:d668742c8978

SR import: Made `negate-z` flag more symmetrical to `single-beam` flag.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 14 Jul 2019 17:33:01 +0200
parents 3bdbaf1b282a
children e467159d04cc
line wrap: on
line diff
--- a/pkg/imports/sr.go	Sun Jul 14 17:19:22 2019 +0200
+++ b/pkg/imports/sr.go	Sun Jul 14 17:33:01 2019 +0200
@@ -62,7 +62,7 @@
 	SingleBeam *bool `json:"single-beam,omitempty"`
 	// NegateZ indicated that the Z values of thy XYZ input should be
 	// multiplied by -1.
-	NegateZ bool `json:"negate-z,omitempty"`
+	NegateZ *bool `json:"negate-z,omitempty"`
 }
 
 const (
@@ -209,10 +209,14 @@
 `
 )
 
-func (sr *SoundingResult) isSingleBeam() bool {
+func (sr *SoundingResult) singleBeam() bool {
 	return sr.SingleBeam != nil && *sr.SingleBeam
 }
 
+func (sr *SoundingResult) negateZ() bool {
+	return sr.NegateZ != nil && *sr.NegateZ
+}
+
 // Do executes the actual sounding result import.
 func (sr *SoundingResult) Do(
 	ctx context.Context,
@@ -252,7 +256,7 @@
 
 	var xform vertexTransform
 
-	if m.NegateZ {
+	if sr.negateZ() {
 		xform = negateZTransform
 	} else {
 		xform = identityTransform
@@ -330,7 +334,7 @@
 
 	var summary interface{}
 
-	if sr.isSingleBeam() {
+	if sr.singleBeam() {
 		summary, err = sr.processScan(
 			ctx,
 			tx,
@@ -666,7 +670,8 @@
 	return sr.Bottleneck != nil &&
 		sr.Date != nil &&
 		sr.DepthReference != nil &&
-		sr.SingleBeam != nil
+		sr.SingleBeam != nil &&
+		sr.NegateZ != nil
 }
 
 func (sr *SoundingResult) loadMeta(f *zip.File) (*models.SoundingResultMeta, error) {
@@ -682,6 +687,8 @@
 			Bottleneck:     *sr.Bottleneck,
 			EPSG:           epsg,
 			DepthReference: *sr.DepthReference,
+			SingleBeam:     sr.singleBeam(),
+			NegateZ:        sr.negateZ(),
 		}, nil
 	}
 	r, err := f.Open()
@@ -710,6 +717,9 @@
 	if sr.SingleBeam != nil {
 		m.SingleBeam = *sr.SingleBeam
 	}
+	if sr.NegateZ != nil {
+		m.NegateZ = *sr.NegateZ
+	}
 
 	return &m, nil
 }