comparison 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
comparison
equal deleted inserted replaced
3945:3bdbaf1b282a 3946:d668742c8978
60 DepthReference *string `json:"depth-reference,omitempty"` 60 DepthReference *string `json:"depth-reference,omitempty"`
61 // SingleBeam indicates that the sounding is a single beam scan. 61 // SingleBeam indicates that the sounding is a single beam scan.
62 SingleBeam *bool `json:"single-beam,omitempty"` 62 SingleBeam *bool `json:"single-beam,omitempty"`
63 // NegateZ indicated that the Z values of thy XYZ input should be 63 // NegateZ indicated that the Z values of thy XYZ input should be
64 // multiplied by -1. 64 // multiplied by -1.
65 NegateZ bool `json:"negate-z,omitempty"` 65 NegateZ *bool `json:"negate-z,omitempty"`
66 } 66 }
67 67
68 const ( 68 const (
69 contourStepWidth = 0.1 69 contourStepWidth = 0.1
70 contourTolerance = 0.1 70 contourTolerance = 0.1
207 best_utm(CAST(ST_Transform(ST_GeomFromWKB($1, $2::integer), 4326) AS geography)))), 207 best_utm(CAST(ST_Transform(ST_GeomFromWKB($1, $2::integer), 4326) AS geography)))),
208 best_utm(CAST(ST_Transform(ST_GeomFromWKB($1, $2::integer), 4326) AS geography)) 208 best_utm(CAST(ST_Transform(ST_GeomFromWKB($1, $2::integer), 4326) AS geography))
209 ` 209 `
210 ) 210 )
211 211
212 func (sr *SoundingResult) isSingleBeam() bool { 212 func (sr *SoundingResult) singleBeam() bool {
213 return sr.SingleBeam != nil && *sr.SingleBeam 213 return sr.SingleBeam != nil && *sr.SingleBeam
214 }
215
216 func (sr *SoundingResult) negateZ() bool {
217 return sr.NegateZ != nil && *sr.NegateZ
214 } 218 }
215 219
216 // Do executes the actual sounding result import. 220 // Do executes the actual sounding result import.
217 func (sr *SoundingResult) Do( 221 func (sr *SoundingResult) Do(
218 ctx context.Context, 222 ctx context.Context,
250 feedback.Info("Bottleneck: %s", m.Bottleneck) 254 feedback.Info("Bottleneck: %s", m.Bottleneck)
251 feedback.Info("Survey date: %s", m.Date.Format(common.DateFormat)) 255 feedback.Info("Survey date: %s", m.Date.Format(common.DateFormat))
252 256
253 var xform vertexTransform 257 var xform vertexTransform
254 258
255 if m.NegateZ { 259 if sr.negateZ() {
256 xform = negateZTransform 260 xform = negateZTransform
257 } else { 261 } else {
258 xform = identityTransform 262 xform = identityTransform
259 } 263 }
260 264
328 } 332 }
329 defer tx.Rollback() 333 defer tx.Rollback()
330 334
331 var summary interface{} 335 var summary interface{}
332 336
333 if sr.isSingleBeam() { 337 if sr.singleBeam() {
334 summary, err = sr.processScan( 338 summary, err = sr.processScan(
335 ctx, 339 ctx,
336 tx, 340 tx,
337 feedback, 341 feedback,
338 true, 342 true,
664 func (sr *SoundingResult) completeOverride() bool { 668 func (sr *SoundingResult) completeOverride() bool {
665 // sr.EPSG == nil -> WGS84 669 // sr.EPSG == nil -> WGS84
666 return sr.Bottleneck != nil && 670 return sr.Bottleneck != nil &&
667 sr.Date != nil && 671 sr.Date != nil &&
668 sr.DepthReference != nil && 672 sr.DepthReference != nil &&
669 sr.SingleBeam != nil 673 sr.SingleBeam != nil &&
674 sr.NegateZ != nil
670 } 675 }
671 676
672 func (sr *SoundingResult) loadMeta(f *zip.File) (*models.SoundingResultMeta, error) { 677 func (sr *SoundingResult) loadMeta(f *zip.File) (*models.SoundingResultMeta, error) {
673 if f == nil { 678 if f == nil {
674 var epsg uint 679 var epsg uint
680 return &models.SoundingResultMeta{ 685 return &models.SoundingResultMeta{
681 Date: *sr.Date, 686 Date: *sr.Date,
682 Bottleneck: *sr.Bottleneck, 687 Bottleneck: *sr.Bottleneck,
683 EPSG: epsg, 688 EPSG: epsg,
684 DepthReference: *sr.DepthReference, 689 DepthReference: *sr.DepthReference,
690 SingleBeam: sr.singleBeam(),
691 NegateZ: sr.negateZ(),
685 }, nil 692 }, nil
686 } 693 }
687 r, err := f.Open() 694 r, err := f.Open()
688 if err != nil { 695 if err != nil {
689 return nil, err 696 return nil, err
707 if sr.DepthReference != nil { 714 if sr.DepthReference != nil {
708 m.DepthReference = *sr.DepthReference 715 m.DepthReference = *sr.DepthReference
709 } 716 }
710 if sr.SingleBeam != nil { 717 if sr.SingleBeam != nil {
711 m.SingleBeam = *sr.SingleBeam 718 m.SingleBeam = *sr.SingleBeam
719 }
720 if sr.NegateZ != nil {
721 m.NegateZ = *sr.NegateZ
712 } 722 }
713 723
714 return &m, nil 724 return &m, nil
715 } 725 }
716 726