# HG changeset patch # User Sascha L. Teichmann # Date 1574176135 -3600 # Node ID 046a07a33b19cd15609ee31b711c48d803afef01 # Parent faabfed7f0e957c51a6fb94797ff571714d37293 Fixed the golint issues of the imports package. diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/dma.go --- a/pkg/imports/dma.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/dma.go Tue Nov 19 16:08:55 2019 +0100 @@ -41,6 +41,7 @@ Password string `json:"password,omitempty"` } +// Description gives a short info about relevant facts of this import. func (dma *DistanceMarksAshore) Description() (string, error) { return dma.URL + "|" + dma.FeatureType, nil } diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/dmv.go --- a/pkg/imports/dmv.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/dmv.go Tue Nov 19 16:08:55 2019 +0100 @@ -36,6 +36,7 @@ Insecure bool `json:"insecure"` } +// Description gives a short info about relevant facts of this import. func (dmv *DistanceMarksVirtual) Description() (string, error) { return dmv.URL, nil } diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/dsr.go --- a/pkg/imports/dsr.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/dsr.go Tue Nov 19 16:08:55 2019 +0100 @@ -24,12 +24,13 @@ // DeleteSoundingResult is a Job to delete a sounding result from the database. type DeleteSoundingResult struct { - BottleneckId string `json:"bottleneck-id"` + BottleneckID string `json:"bottleneck-id"` Date models.Date `json:"date-info"` } +// Description gives a short info about relevant facts of this import. func (dsr *DeleteSoundingResult) Description() (string, error) { - return dsr.BottleneckId + "|" + dsr.Date.Format(common.DateFormat), nil + return dsr.BottleneckID + "|" + dsr.Date.Format(common.DateFormat), nil } // DSRJobKind is the import queue type identifier. @@ -106,11 +107,11 @@ defer tx.Rollback() feedback.Info("SR: bottleneck-id: %v, date-info: %v", - dsr.BottleneckId, dsr.Date.Time) + dsr.BottleneckID, dsr.Date.Time) var id int64 if err := tx.QueryRowContext(ctx, dsrFindSQL, - dsr.BottleneckId, dsr.Date.Time).Scan(&id); err != nil { + dsr.BottleneckID, dsr.Date.Time).Scan(&id); err != nil { return nil, err } diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/fa.go --- a/pkg/imports/fa.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/fa.go Tue Nov 19 16:08:55 2019 +0100 @@ -160,6 +160,7 @@ )ON CONFLICT ON CONSTRAINT fa_reference_values_pkey DO NOTHING` ) +// Description gives a short info about relevant facts of this import. func (fa *FairwayAvailability) Description() (string, error) { return fa.URL, nil } diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/fd.go --- a/pkg/imports/fd.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/fd.go Tue Nov 19 16:08:55 2019 +0100 @@ -47,6 +47,7 @@ Password string `json:"password,omitempty"` } +// Description gives a short info about relevant facts of this import. func (fd *FairwayDimension) Description() (string, error) { return strings.Join([]string{ fd.URL, diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/gm.go --- a/pkg/imports/gm.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/gm.go Tue Nov 19 16:08:55 2019 +0100 @@ -40,6 +40,7 @@ Insecure bool `json:"insecure"` } +// Description gives a short info about relevant facts of this import. func (gm *GaugeMeasurement) Description() (string, error) { return gm.URL, nil } diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/isr.go --- a/pkg/imports/isr.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/isr.go Tue Nov 19 16:08:55 2019 +0100 @@ -22,6 +22,8 @@ "gemma.intevation.de/gemma/pkg/mesh" ) +// IsoRefresh is an import job to refresh the pre-calculated +// iso morphology data when the class breaks were changed. type IsoRefresh struct { ClassBreaks string `json:"class-breaks"` } @@ -59,6 +61,7 @@ ` ) +// CleanUp of a iso refresh import is a NOP. func (isr *IsoRefresh) CleanUp() error { return nil } type bottleneckSoundingResults struct { diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/modelconvert.go --- a/pkg/imports/modelconvert.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/modelconvert.go Tue Nov 19 16:08:55 2019 +0100 @@ -178,7 +178,7 @@ DSRJobKind: func(input interface{}) interface{} { dsr := input.(*models.SoundingResultDelete) return &DeleteSoundingResult{ - BottleneckId: dsr.BottleneckId, + BottleneckID: dsr.BottleneckId, Date: dsr.Date, } }, diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/sec.go --- a/pkg/imports/sec.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/sec.go Tue Nov 19 16:08:55 2019 +0100 @@ -34,6 +34,7 @@ Date models.Date `json:"date-info"` } +// Description gives a short info about relevant facts of this import. func (sec *Section) Description() (string, error) { return strings.Join([]string{ sec.Name, diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/sr.go --- a/pkg/imports/sr.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/sr.go Tue Nov 19 16:08:55 2019 +0100 @@ -215,6 +215,7 @@ ` ) +// Description gives a short info about relevant facts of this import. func (sr *SoundingResult) Description() (string, error) { var descs []string diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/stsh.go --- a/pkg/imports/stsh.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/stsh.go Tue Nov 19 16:08:55 2019 +0100 @@ -31,10 +31,12 @@ "gemma.intevation.de/gemma/pkg/models" ) +// StretchShape imports stretches from an uploaded shape file. type StretchShape struct { Dir string `json:"dir"` } +// STSHJobKind is the import queue type identifier. const STSHJobKind JobKind = "stsh" type stshJobCreator struct{} @@ -84,6 +86,7 @@ return stJobCreator{}.StageDone(ctx, tx, id) } +// CleanUp removes the folder with the uploaded shape file. func (stsh *StretchShape) CleanUp() error { return os.RemoveAll(stsh.Dir) } @@ -123,6 +126,7 @@ return countries, nil } +// Do executes the actual stretch import from the shape file. func (stsh *StretchShape) Do( ctx context.Context, importID int64, diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/wa.go --- a/pkg/imports/wa.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/wa.go Tue Nov 19 16:08:55 2019 +0100 @@ -45,6 +45,7 @@ Password string `json:"password,omitempty"` } +// Description gives a short info about relevant facts of this import. func (wa *WaterwayArea) Description() (string, error) { return wa.URL + "|" + wa.FeatureType, nil } @@ -113,7 +114,7 @@ ) // Do executes the actual waterway axis import. -func (wx *WaterwayArea) Do( +func (wa *WaterwayArea) Do( ctx context.Context, importID int64, conn *sql.Conn, @@ -124,19 +125,19 @@ feedback.Info("Import waterway area") - feedback.Info("Loading capabilities from %s", wx.URL) - caps, err := wfs.GetCapabilities(wx.URL) + feedback.Info("Loading capabilities from %s", wa.URL) + caps, err := wfs.GetCapabilities(wa.URL) if err != nil { feedback.Error("Loading capabilities failed: %v", err) return nil, err } - ft := caps.FindFeatureType(wx.FeatureType) + ft := caps.FindFeatureType(wa.FeatureType) if ft == nil { - return nil, fmt.Errorf("unknown feature type '%s'", wx.FeatureType) + return nil, fmt.Errorf("unknown feature type '%s'", wa.FeatureType) } - feedback.Info("Found feature type '%s", wx.FeatureType) + feedback.Info("Found feature type '%s", wa.FeatureType) epsg, err := wfs.CRSToEPSG(ft.DefaultCRS) if err != nil { @@ -144,11 +145,11 @@ return nil, err } - if wx.SortBy != "" { - feedback.Info("Features will be sorted by '%s'", wx.SortBy) + if wa.SortBy != "" { + feedback.Info("Features will be sorted by '%s'", wa.SortBy) } - dl, err := wfs.GetFeatures(caps, wx.FeatureType, wx.SortBy) + dl, err := wfs.GetFeatures(caps, wa.FeatureType, wa.SortBy) if err != nil { feedback.Error("Cannot create GetFeature URLs. %v", err) return nil, err @@ -179,7 +180,7 @@ features int ) - if err := dl.Download(wx.User, wx.Password, func(url string, r io.Reader) error { + if err := dl.Download(wa.User, wa.Password, func(url string, r io.Reader) error { feedback.Info("Get features from: '%s'", url) rfc, err := wfs.ParseRawFeatureCollection(r) if err != nil { diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/wg.go --- a/pkg/imports/wg.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/wg.go Tue Nov 19 16:08:55 2019 +0100 @@ -40,6 +40,7 @@ Insecure bool `json:"insecure"` } +// Description gives a short info about relevant facts of this import. func (wg *WaterwayGauge) Description() (string, error) { return wg.URL, nil } diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/wkb.go --- a/pkg/imports/wkb.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/wkb.go Tue Nov 19 16:08:55 2019 +0100 @@ -30,17 +30,17 @@ polygonSlice [][][]float64 ) -func (l lineSlice) asWKB() []byte { +func (ls lineSlice) asWKB() []byte { - size := 1 + 4 + 4 + len(l)*(2*8) + size := 1 + 4 + 4 + len(ls)*(2*8) buf := bytes.NewBuffer(make([]byte, 0, size)) binary.Write(buf, binary.LittleEndian, wkb.NDR) binary.Write(buf, binary.LittleEndian, wkb.LineString) - binary.Write(buf, binary.LittleEndian, uint32(len(l))) + binary.Write(buf, binary.LittleEndian, uint32(len(ls))) - for _, c := range l { + for _, c := range ls { var lat, lon float64 if len(c) > 0 { lat = c[0] @@ -86,13 +86,13 @@ return buf.Bytes() } -func (p polygonSlice) asWKB() []byte { - if p == nil { +func (ps polygonSlice) asWKB() []byte { + if ps == nil { return nil } // pre-calculate size to avoid reallocations. size := 1 + 4 + 4 - for _, ring := range p { + for _, ring := range ps { size += 4 + len(ring)*2*8 } @@ -100,9 +100,9 @@ binary.Write(buf, binary.LittleEndian, wkb.NDR) binary.Write(buf, binary.LittleEndian, wkb.Polygon) - binary.Write(buf, binary.LittleEndian, uint32(len(p))) + binary.Write(buf, binary.LittleEndian, uint32(len(ps))) - for _, ring := range p { + for _, ring := range ps { binary.Write(buf, binary.LittleEndian, uint32(len(ring))) for _, v := range ring { var lat, lon float64 diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/wp.go --- a/pkg/imports/wp.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/wp.go Tue Nov 19 16:08:55 2019 +0100 @@ -59,6 +59,7 @@ Password string `json:"password,omitempty"` } +// Description gives a short info about relevant facts of this import. func (wp *WaterwayProfiles) Description() (string, error) { return wp.URL + "|" + wp.FeatureType, nil } diff -r faabfed7f0e9 -r 046a07a33b19 pkg/imports/wx.go --- a/pkg/imports/wx.go Tue Nov 19 15:46:16 2019 +0100 +++ b/pkg/imports/wx.go Tue Nov 19 16:08:55 2019 +0100 @@ -44,6 +44,7 @@ Password string `json:"password,omitempty"` } +// Description gives a short info about relevant facts of this import. func (wx *WaterwayAxis) Description() (string, error) { return wx.URL + "|" + wx.FeatureType, nil }