# HG changeset patch # User Sascha L. Teichmann # Date 1563118381 -7200 # Node ID d668742c89789c2e32af64a3268ce829d923d4fd # Parent 3bdbaf1b282a42a74199b374bd052f64f4176015 SR import: Made `negate-z` flag more symmetrical to `single-beam` flag. diff -r 3bdbaf1b282a -r d668742c8978 pkg/controllers/srimports.go --- a/pkg/controllers/srimports.go Sun Jul 14 17:19:22 2019 +0200 +++ b/pkg/controllers/srimports.go Sun Jul 14 17:33:01 2019 +0200 @@ -107,7 +107,7 @@ default: return fmt.Errorf("Unknown negate-z '%s'", v) } - sr.NegateZ = negateZ + sr.NegateZ = &negateZ } if v := req.FormValue("single-beam"); v != "" { diff -r 3bdbaf1b282a -r d668742c8978 pkg/imports/sr.go --- 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 }