comparison pkg/imports/sr.go @ 5403:85f19e924a43 marking-single-beam

Adjusted the import model to be able to handle marking single beam scans.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 06 Jul 2021 01:20:44 +0200
parents 12a5e128255f
children 850f5847d18a
comparison
equal deleted inserted replaced
5402:f5063fa7f666 5403:85f19e924a43
56 // Defaults to WGS84. 56 // Defaults to WGS84.
57 EPSG *uint `json:"epsg,omitempty"` 57 EPSG *uint `json:"epsg,omitempty"`
58 // DepthReference if given overides the DepthReference value 58 // DepthReference if given overides the DepthReference value
59 // from the meta.json. 59 // from the meta.json.
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 // SurveyType indicates that the sounding is a single beam scan.
62 SingleBeam *bool `json:"single-beam,omitempty"` 62 SurveyType *models.SurveyType `json:"survey-type,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
238 descs = append(descs, "negateZ") 238 descs = append(descs, "negateZ")
239 } 239 }
240 return strings.Join(descs, "|"), nil 240 return strings.Join(descs, "|"), nil
241 } 241 }
242 242
243 func (sr *SoundingResult) singleBeam() bool { 243 func (sr *SoundingResult) surveyType() models.SurveyType {
244 return sr.SingleBeam != nil && *sr.SingleBeam 244 if sr.SurveyType != nil {
245 return *sr.SurveyType
246 }
247 return models.SurveyTypeMultiBeam
245 } 248 }
246 249
247 func (sr *SoundingResult) surtype() string { 250 func (sr *SoundingResult) surtype() string {
248 if sr.singleBeam() { 251 return string(sr.surveyType())
249 return "single"
250 }
251 return "multi"
252 } 252 }
253 253
254 func (sr *SoundingResult) negateZ() bool { 254 func (sr *SoundingResult) negateZ() bool {
255 return sr.NegateZ != nil && *sr.NegateZ 255 return sr.NegateZ != nil && *sr.NegateZ
256 } 256 }
417 xyz mesh.MultiPointZ, 417 xyz mesh.MultiPointZ,
418 boundary polygonSlice, 418 boundary polygonSlice,
419 zpgException bool, 419 zpgException bool,
420 ) (interface{}, error) { 420 ) (interface{}, error) {
421 421
422 if sr.singleBeam() { 422 feedback.Info("Processing as %s beam scan.", sr.surtype())
423 feedback.Info("Processing as single beam scan.")
424 } else {
425 feedback.Info("Processing as multi beam scan.")
426 }
427 423
428 feedback.Info("Reproject XYZ data.") 424 feedback.Info("Reproject XYZ data.")
429 425
430 start := time.Now() 426 start := time.Now()
431 427
530 str.Build(tin) 526 str.Build(tin)
531 527
532 removed = str.Clip(&clippingPolygon) 528 removed = str.Clip(&clippingPolygon)
533 } 529 }
534 530
535 if sr.singleBeam() { 531 switch sr.surveyType() {
532 case models.SurveyTypeMarking:
533 // TODO: Implement me!
534 return nil, errors.New("Not implemented, yet!")
535
536 case models.SurveyTypeSingleBeam:
536 537
537 origDensity := float64(len(xyz)) / polygonArea 538 origDensity := float64(len(xyz)) / polygonArea
538 539
539 feedback.Info("Boundary area: %.2fm²", polygonArea) 540 feedback.Info("Boundary area: %.2fm²", polygonArea)
540 feedback.Info("Original point density: %.2f points/m²", origDensity) 541 feedback.Info("Original point density: %.2f points/m²", origDensity)
710 func (sr *SoundingResult) completeOverride() bool { 711 func (sr *SoundingResult) completeOverride() bool {
711 // sr.EPSG == nil -> WGS84 712 // sr.EPSG == nil -> WGS84
712 return sr.Bottleneck != nil && 713 return sr.Bottleneck != nil &&
713 sr.Date != nil && 714 sr.Date != nil &&
714 sr.DepthReference != nil && 715 sr.DepthReference != nil &&
715 sr.SingleBeam != nil && 716 sr.SurveyType != nil &&
716 sr.NegateZ != nil 717 sr.NegateZ != nil
717 } 718 }
718 719
719 func (sr *SoundingResult) loadMeta(f *zip.File) (*models.SoundingResultMeta, error) { 720 func (sr *SoundingResult) loadMeta(f *zip.File) (*models.SoundingResultMeta, error) {
720 if f == nil { 721 if f == nil {
727 return &models.SoundingResultMeta{ 728 return &models.SoundingResultMeta{
728 Date: *sr.Date, 729 Date: *sr.Date,
729 Bottleneck: *sr.Bottleneck, 730 Bottleneck: *sr.Bottleneck,
730 EPSG: epsg, 731 EPSG: epsg,
731 DepthReference: *sr.DepthReference, 732 DepthReference: *sr.DepthReference,
732 SingleBeam: sr.singleBeam(), 733 SurveyType: sr.surveyType(),
733 NegateZ: sr.negateZ(), 734 NegateZ: sr.negateZ(),
734 }, nil 735 }, nil
735 } 736 }
736 r, err := f.Open() 737 r, err := f.Open()
737 if err != nil { 738 if err != nil {
754 m.EPSG = *sr.EPSG 755 m.EPSG = *sr.EPSG
755 } 756 }
756 if sr.DepthReference != nil { 757 if sr.DepthReference != nil {
757 m.DepthReference = *sr.DepthReference 758 m.DepthReference = *sr.DepthReference
758 } 759 }
759 if sr.SingleBeam != nil { 760 if sr.SurveyType != nil {
760 m.SingleBeam = *sr.SingleBeam 761 m.SurveyType = *sr.SurveyType
761 } 762 }
762 if sr.NegateZ != nil { 763 if sr.NegateZ != nil {
763 m.NegateZ = *sr.NegateZ 764 m.NegateZ = *sr.NegateZ
764 } 765 }
765 766