changeset 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 7a96321be219
children d45d5fafdc5b
files pkg/imports/sr.go
diffstat 1 files changed, 19 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/imports/sr.go	Wed Jul 14 17:52:32 2021 +0200
+++ b/pkg/imports/sr.go	Thu Jul 15 15:38:18 2021 +0200
@@ -253,23 +253,12 @@
 	if sr.NegateZ != nil && *sr.NegateZ {
 		descs = append(descs, "negateZ")
 	}
-	if sr.surveyType != nil {
+	if sr.SurveyType != nil {
 		descs = append(descs, string(*sr.SurveyType))
 	}
 	return strings.Join(descs, "|"), nil
 }
 
-func (sr *SoundingResult) surveyType() models.SurveyType {
-	if sr.SurveyType != nil {
-		return *sr.SurveyType
-	}
-	return models.SurveyTypeMultiBeam
-}
-
-func (sr *SoundingResult) surtype() string {
-	return string(sr.surveyType())
-}
-
 func (sr *SoundingResult) negateZ() bool {
 	return sr.NegateZ != nil && *sr.NegateZ
 }
@@ -438,7 +427,7 @@
 	zpgException bool,
 ) (interface{}, error) {
 
-	feedback.Info("Processing as %s beam scan.", sr.surtype())
+	feedback.Info("Processing as %s beam scan.", m.SurveyType)
 
 	feedback.Info("Reproject XYZ data.")
 
@@ -545,7 +534,7 @@
 		removed = str.Clip(&clippingPolygon)
 	}
 
-	if sr.surveyType() == models.SurveyTypeSingleBeam {
+	if m.SurveyType == models.SurveyTypeSingleBeam {
 
 		origDensity := float64(len(xyz)) / polygonArea
 
@@ -619,7 +608,7 @@
 
 	final := mesh.STRTree{Entries: 16}
 
-	if sr.surveyType() != models.SurveyTypeMarking {
+	if m.SurveyType != models.SurveyTypeMarking {
 
 		start = time.Now()
 		tin := tri.Tin()
@@ -672,7 +661,7 @@
 		nil,
 		clippingPolygonWKB,
 		epsg,
-		sr.surtype(),
+		m.SurveyType,
 		zpgException,
 	).Scan(
 		&id,
@@ -690,7 +679,7 @@
 		return nil, err
 	}
 
-	if sr.surveyType() != models.SurveyTypeMarking {
+	if m.SurveyType != models.SurveyTypeMarking {
 
 		index, err := final.Bytes()
 		if err != nil {
@@ -751,7 +740,7 @@
 	return sr.Bottleneck != nil &&
 		sr.Date != nil &&
 		sr.DepthReference != nil &&
-		sr.SurveyType != nil &&
+		(sr.SingleBeam != nil || sr.SurveyType != nil) &&
 		sr.NegateZ != nil
 }
 
@@ -763,12 +752,21 @@
 		} else {
 			epsg = models.WGS84
 		}
+
+		st := models.SurveyTypeMultiBeam
+		if sr.SingleBeam != nil && *sr.SingleBeam {
+			st = models.SurveyTypeSingleBeam
+		}
+		if sr.SurveyType != nil {
+			st = *sr.SurveyType
+		}
+
 		return &models.SoundingResultMeta{
 			Date:           *sr.Date,
 			Bottleneck:     *sr.Bottleneck,
 			EPSG:           epsg,
 			DepthReference: *sr.DepthReference,
-			SurveyType:     sr.surveyType(),
+			SurveyType:     st,
 			NegateZ:        sr.negateZ(),
 		}, nil
 	}
@@ -801,13 +799,13 @@
 		if *sr.SingleBeam {
 			m.SurveyType = models.SurveyTypeSingleBeam
 		} else {
-			m.SurveyType = models.SurveyTypeSingleBeam
+			m.SurveyType = models.SurveyTypeMultiBeam
 		}
 	}
-
 	if sr.SurveyType != nil {
 		m.SurveyType = *sr.SurveyType
 	}
+
 	if sr.NegateZ != nil {
 		m.NegateZ = *sr.NegateZ
 	}