Mercurial > gemma
comparison pkg/imports/sr.go @ 5458:e00b3296fc02
Fixed SR import: use meta.json for marking scans correctly.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 15 Jul 2021 15:38:18 +0200 |
parents | aa199f280f64 |
children | 93af8d1ea09f |
comparison
equal
deleted
inserted
replaced
5447:7a96321be219 | 5458:e00b3296fc02 |
---|---|
251 descs = append(descs, (*sr).Date.Format(common.DateFormat)) | 251 descs = append(descs, (*sr).Date.Format(common.DateFormat)) |
252 } | 252 } |
253 if sr.NegateZ != nil && *sr.NegateZ { | 253 if sr.NegateZ != nil && *sr.NegateZ { |
254 descs = append(descs, "negateZ") | 254 descs = append(descs, "negateZ") |
255 } | 255 } |
256 if sr.surveyType != nil { | 256 if sr.SurveyType != nil { |
257 descs = append(descs, string(*sr.SurveyType)) | 257 descs = append(descs, string(*sr.SurveyType)) |
258 } | 258 } |
259 return strings.Join(descs, "|"), nil | 259 return strings.Join(descs, "|"), nil |
260 } | |
261 | |
262 func (sr *SoundingResult) surveyType() models.SurveyType { | |
263 if sr.SurveyType != nil { | |
264 return *sr.SurveyType | |
265 } | |
266 return models.SurveyTypeMultiBeam | |
267 } | |
268 | |
269 func (sr *SoundingResult) surtype() string { | |
270 return string(sr.surveyType()) | |
271 } | 260 } |
272 | 261 |
273 func (sr *SoundingResult) negateZ() bool { | 262 func (sr *SoundingResult) negateZ() bool { |
274 return sr.NegateZ != nil && *sr.NegateZ | 263 return sr.NegateZ != nil && *sr.NegateZ |
275 } | 264 } |
436 xyz mesh.MultiPointZ, | 425 xyz mesh.MultiPointZ, |
437 boundary polygonSlice, | 426 boundary polygonSlice, |
438 zpgException bool, | 427 zpgException bool, |
439 ) (interface{}, error) { | 428 ) (interface{}, error) { |
440 | 429 |
441 feedback.Info("Processing as %s beam scan.", sr.surtype()) | 430 feedback.Info("Processing as %s beam scan.", m.SurveyType) |
442 | 431 |
443 feedback.Info("Reproject XYZ data.") | 432 feedback.Info("Reproject XYZ data.") |
444 | 433 |
445 start := time.Now() | 434 start := time.Now() |
446 | 435 |
543 str.Build(tin) | 532 str.Build(tin) |
544 | 533 |
545 removed = str.Clip(&clippingPolygon) | 534 removed = str.Clip(&clippingPolygon) |
546 } | 535 } |
547 | 536 |
548 if sr.surveyType() == models.SurveyTypeSingleBeam { | 537 if m.SurveyType == models.SurveyTypeSingleBeam { |
549 | 538 |
550 origDensity := float64(len(xyz)) / polygonArea | 539 origDensity := float64(len(xyz)) / polygonArea |
551 | 540 |
552 feedback.Info("Boundary area: %.2fm²", polygonArea) | 541 feedback.Info("Boundary area: %.2fm²", polygonArea) |
553 feedback.Info("Original point density: %.2f points/m²", origDensity) | 542 feedback.Info("Original point density: %.2f points/m²", origDensity) |
617 | 606 |
618 multibeam: | 607 multibeam: |
619 | 608 |
620 final := mesh.STRTree{Entries: 16} | 609 final := mesh.STRTree{Entries: 16} |
621 | 610 |
622 if sr.surveyType() != models.SurveyTypeMarking { | 611 if m.SurveyType != models.SurveyTypeMarking { |
623 | 612 |
624 start = time.Now() | 613 start = time.Now() |
625 tin := tri.Tin() | 614 tin := tri.Tin() |
626 tin.EPSG = epsg | 615 tin.EPSG = epsg |
627 | 616 |
670 m.Date.Time, | 659 m.Date.Time, |
671 m.DepthReference, | 660 m.DepthReference, |
672 nil, | 661 nil, |
673 clippingPolygonWKB, | 662 clippingPolygonWKB, |
674 epsg, | 663 epsg, |
675 sr.surtype(), | 664 m.SurveyType, |
676 zpgException, | 665 zpgException, |
677 ).Scan( | 666 ).Scan( |
678 &id, | 667 &id, |
679 &lat, | 668 &lat, |
680 &lon, | 669 &lon, |
688 "no matching bottleneck of given name or time available: %v", err) | 677 "no matching bottleneck of given name or time available: %v", err) |
689 case err != nil: | 678 case err != nil: |
690 return nil, err | 679 return nil, err |
691 } | 680 } |
692 | 681 |
693 if sr.surveyType() != models.SurveyTypeMarking { | 682 if m.SurveyType != models.SurveyTypeMarking { |
694 | 683 |
695 index, err := final.Bytes() | 684 index, err := final.Bytes() |
696 if err != nil { | 685 if err != nil { |
697 return nil, err | 686 return nil, err |
698 } | 687 } |
749 func (sr *SoundingResult) completeOverride() bool { | 738 func (sr *SoundingResult) completeOverride() bool { |
750 // sr.EPSG == nil -> WGS84 | 739 // sr.EPSG == nil -> WGS84 |
751 return sr.Bottleneck != nil && | 740 return sr.Bottleneck != nil && |
752 sr.Date != nil && | 741 sr.Date != nil && |
753 sr.DepthReference != nil && | 742 sr.DepthReference != nil && |
754 sr.SurveyType != nil && | 743 (sr.SingleBeam != nil || sr.SurveyType != nil) && |
755 sr.NegateZ != nil | 744 sr.NegateZ != nil |
756 } | 745 } |
757 | 746 |
758 func (sr *SoundingResult) loadMeta(f *zip.File) (*models.SoundingResultMeta, error) { | 747 func (sr *SoundingResult) loadMeta(f *zip.File) (*models.SoundingResultMeta, error) { |
759 if f == nil { | 748 if f == nil { |
761 if sr.EPSG != nil { | 750 if sr.EPSG != nil { |
762 epsg = *sr.EPSG | 751 epsg = *sr.EPSG |
763 } else { | 752 } else { |
764 epsg = models.WGS84 | 753 epsg = models.WGS84 |
765 } | 754 } |
755 | |
756 st := models.SurveyTypeMultiBeam | |
757 if sr.SingleBeam != nil && *sr.SingleBeam { | |
758 st = models.SurveyTypeSingleBeam | |
759 } | |
760 if sr.SurveyType != nil { | |
761 st = *sr.SurveyType | |
762 } | |
763 | |
766 return &models.SoundingResultMeta{ | 764 return &models.SoundingResultMeta{ |
767 Date: *sr.Date, | 765 Date: *sr.Date, |
768 Bottleneck: *sr.Bottleneck, | 766 Bottleneck: *sr.Bottleneck, |
769 EPSG: epsg, | 767 EPSG: epsg, |
770 DepthReference: *sr.DepthReference, | 768 DepthReference: *sr.DepthReference, |
771 SurveyType: sr.surveyType(), | 769 SurveyType: st, |
772 NegateZ: sr.negateZ(), | 770 NegateZ: sr.negateZ(), |
773 }, nil | 771 }, nil |
774 } | 772 } |
775 r, err := f.Open() | 773 r, err := f.Open() |
776 if err != nil { | 774 if err != nil { |
799 // Kept in for compat | 797 // Kept in for compat |
800 if sr.SingleBeam != nil { | 798 if sr.SingleBeam != nil { |
801 if *sr.SingleBeam { | 799 if *sr.SingleBeam { |
802 m.SurveyType = models.SurveyTypeSingleBeam | 800 m.SurveyType = models.SurveyTypeSingleBeam |
803 } else { | 801 } else { |
804 m.SurveyType = models.SurveyTypeSingleBeam | 802 m.SurveyType = models.SurveyTypeMultiBeam |
805 } | 803 } |
806 } | 804 } |
807 | |
808 if sr.SurveyType != nil { | 805 if sr.SurveyType != nil { |
809 m.SurveyType = *sr.SurveyType | 806 m.SurveyType = *sr.SurveyType |
810 } | 807 } |
808 | |
811 if sr.NegateZ != nil { | 809 if sr.NegateZ != nil { |
812 m.NegateZ = *sr.NegateZ | 810 m.NegateZ = *sr.NegateZ |
813 } | 811 } |
814 | 812 |
815 return &m, nil | 813 return &m, nil |