# HG changeset patch # User Sascha L. Teichmann # Date 1543947935 -3600 # Node ID 5df748916fcfbbe8b739ab4ec6589584d6d86066 # Parent b41ad15cc55f9cd17b087dacc9dbb73afb63d069 Finished API docs for sounding result imports. diff -r b41ad15cc55f -r 5df748916fcf pkg/imports/sr.go --- a/pkg/imports/sr.go Tue Dec 04 18:54:50 2018 +0100 +++ b/pkg/imports/sr.go Tue Dec 04 19:25:35 2018 +0100 @@ -40,14 +40,24 @@ "gemma.intevation.de/gemma/pkg/octree" ) +// SoundingResult is a Job to import sounding reults +// from a ZIP file into the database. type SoundingResult struct { + // Dir is the folder in the file system where the + // 'sr.zip' is expect to be. Dir string `json:"dir"` // Override data - Date *models.SoundingResultDate `json:"date,omitempty"` - Bottleneck *string `json:"bottleneck,omitempty"` - EPSG *uint `json:"epsg,omitempty"` - DepthReference *string `json:"depth-reference,omitempty"` + // Date if given overrides the date value from the meta.json. + Date *models.SoundingResultDate `json:"date,omitempty"` + // Date if given overrides the name of the bottleneck from the meta.json. + Bottleneck *string `json:"bottleneck,omitempty"` + // EPSG if given overrides the EPSG code from the meta.json. + // Defaults to WGS84. + EPSG *uint `json:"epsg,omitempty"` + // DepthReference if given overides the DepthReference value + // from the meta.json. + DepthReference *string `json:"depth-reference,omitempty"` } const ( @@ -55,6 +65,7 @@ contourTolerance = 0.1 ) +// SRJobKind is the unique name of a SoundingResult import job. const SRJobKind JobKind = "sr" type srJobCreator struct{} @@ -155,10 +166,13 @@ ` ) +// FromString revives a SoundingResult import from a string. func (sr *SoundingResult) FromString(data string) error { return json.NewDecoder(strings.NewReader(data)).Decode(sr) } +// ToString serializes a SoundingResult import into a string to +// be revived by FromString. func (sr *SoundingResult) ToString() (string, error) { var b strings.Builder if err := json.NewEncoder(&b).Encode(sr); err != nil { @@ -167,6 +181,7 @@ return b.String(), nil } +// Do executes the actual sounding result import. func (sr *SoundingResult) Do( ctx context.Context, importID int64, @@ -313,6 +328,8 @@ return &summary, err } +// CleanUp removes the folder containing the ZIP file with the +// the sounding result import. func (sr *SoundingResult) CleanUp() error { return os.RemoveAll(sr.Dir) }