comparison pkg/models/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 98e2041c7ebf
children 850f5847d18a
comparison
equal deleted inserted replaced
5402:f5063fa7f666 5403:85f19e924a43
23 "io" 23 "io"
24 24
25 "gemma.intevation.de/gemma/pkg/common" 25 "gemma.intevation.de/gemma/pkg/common"
26 ) 26 )
27 27
28 type SurveyType string
29
30 const (
31 SurveyTypeMultiBeam = SurveyType("multi")
32 SurveyTypeSingleBeam = SurveyType("single")
33 SurveyTypeMarking = SurveyType("marking")
34 )
35
28 type ( 36 type (
29 SoundingResultMeta struct { 37 SoundingResultMeta struct {
30 Date Date `json:"date"` 38 Date Date `json:"date"`
31 Bottleneck string `json:"bottleneck"` 39 Bottleneck string `json:"bottleneck"`
32 EPSG uint `json:"epsg"` 40 EPSG uint `json:"epsg"`
33 DepthReference string `json:"depth-reference"` 41 DepthReference string `json:"depth-reference"`
34 SingleBeam bool `json:"single-beam"` 42 SurveyType SurveyType `json:"survey-type"`
35 NegateZ bool `json:"negate-z,omitempty"` 43 NegateZ bool `json:"negate-z,omitempty"`
36 } 44 }
37 ) 45 )
46
47 func (st *SurveyType) UnmarshalJSON(data []byte) error {
48 var s string
49 if err := json.Unmarshal(data, &s); err != nil {
50 return err
51 }
52 switch x := SurveyType(s); x {
53 case SurveyTypeMultiBeam, SurveyTypeSingleBeam, SurveyTypeMarking:
54 *st = x
55 return nil
56 default:
57 return fmt.Errorf("unkown survey type '%s'", s)
58 }
59 }
38 60
39 const ( 61 const (
40 checkDepthReferenceSQL = ` 62 checkDepthReferenceSQL = `
41 SELECT EXISTS(SELECT 1 63 SELECT EXISTS(SELECT 1
42 FROM waterway.bottlenecks bn 64 FROM waterway.bottlenecks bn