Mercurial > gemma
changeset 1498:5df748916fcf
Finished API docs for sounding result imports.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 04 Dec 2018 19:25:35 +0100 |
parents | b41ad15cc55f |
children | 811497a8092f |
files | pkg/imports/sr.go |
diffstat | 1 files changed, 21 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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) }