Mercurial > gemma
comparison pkg/imports/wa.go @ 4852:046a07a33b19
Fixed the golint issues of the imports package.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 19 Nov 2019 16:08:55 +0100 |
parents | 58642179e896 |
children | 783d0bec86d3 |
comparison
equal
deleted
inserted
replaced
4851:faabfed7f0e9 | 4852:046a07a33b19 |
---|---|
43 User string `json:"user,omitempty"` | 43 User string `json:"user,omitempty"` |
44 // Password is an optional password for Basic Auth. | 44 // Password is an optional password for Basic Auth. |
45 Password string `json:"password,omitempty"` | 45 Password string `json:"password,omitempty"` |
46 } | 46 } |
47 | 47 |
48 // Description gives a short info about relevant facts of this import. | |
48 func (wa *WaterwayArea) Description() (string, error) { | 49 func (wa *WaterwayArea) Description() (string, error) { |
49 return wa.URL + "|" + wa.FeatureType, nil | 50 return wa.URL + "|" + wa.FeatureType, nil |
50 } | 51 } |
51 | 52 |
52 // WAJobKind is the import queue type identifier. | 53 // WAJobKind is the import queue type identifier. |
111 RETURNING id | 112 RETURNING id |
112 ` | 113 ` |
113 ) | 114 ) |
114 | 115 |
115 // Do executes the actual waterway axis import. | 116 // Do executes the actual waterway axis import. |
116 func (wx *WaterwayArea) Do( | 117 func (wa *WaterwayArea) Do( |
117 ctx context.Context, | 118 ctx context.Context, |
118 importID int64, | 119 importID int64, |
119 conn *sql.Conn, | 120 conn *sql.Conn, |
120 feedback Feedback, | 121 feedback Feedback, |
121 ) (interface{}, error) { | 122 ) (interface{}, error) { |
122 | 123 |
123 start := time.Now() | 124 start := time.Now() |
124 | 125 |
125 feedback.Info("Import waterway area") | 126 feedback.Info("Import waterway area") |
126 | 127 |
127 feedback.Info("Loading capabilities from %s", wx.URL) | 128 feedback.Info("Loading capabilities from %s", wa.URL) |
128 caps, err := wfs.GetCapabilities(wx.URL) | 129 caps, err := wfs.GetCapabilities(wa.URL) |
129 if err != nil { | 130 if err != nil { |
130 feedback.Error("Loading capabilities failed: %v", err) | 131 feedback.Error("Loading capabilities failed: %v", err) |
131 return nil, err | 132 return nil, err |
132 } | 133 } |
133 | 134 |
134 ft := caps.FindFeatureType(wx.FeatureType) | 135 ft := caps.FindFeatureType(wa.FeatureType) |
135 if ft == nil { | 136 if ft == nil { |
136 return nil, fmt.Errorf("unknown feature type '%s'", wx.FeatureType) | 137 return nil, fmt.Errorf("unknown feature type '%s'", wa.FeatureType) |
137 } | 138 } |
138 | 139 |
139 feedback.Info("Found feature type '%s", wx.FeatureType) | 140 feedback.Info("Found feature type '%s", wa.FeatureType) |
140 | 141 |
141 epsg, err := wfs.CRSToEPSG(ft.DefaultCRS) | 142 epsg, err := wfs.CRSToEPSG(ft.DefaultCRS) |
142 if err != nil { | 143 if err != nil { |
143 feedback.Error("Unsupported CRS: '%s'", ft.DefaultCRS) | 144 feedback.Error("Unsupported CRS: '%s'", ft.DefaultCRS) |
144 return nil, err | 145 return nil, err |
145 } | 146 } |
146 | 147 |
147 if wx.SortBy != "" { | 148 if wa.SortBy != "" { |
148 feedback.Info("Features will be sorted by '%s'", wx.SortBy) | 149 feedback.Info("Features will be sorted by '%s'", wa.SortBy) |
149 } | 150 } |
150 | 151 |
151 dl, err := wfs.GetFeatures(caps, wx.FeatureType, wx.SortBy) | 152 dl, err := wfs.GetFeatures(caps, wa.FeatureType, wa.SortBy) |
152 if err != nil { | 153 if err != nil { |
153 feedback.Error("Cannot create GetFeature URLs. %v", err) | 154 feedback.Error("Cannot create GetFeature URLs. %v", err) |
154 return nil, err | 155 return nil, err |
155 } | 156 } |
156 | 157 |
177 badProperties int | 178 badProperties int |
178 outside int | 179 outside int |
179 features int | 180 features int |
180 ) | 181 ) |
181 | 182 |
182 if err := dl.Download(wx.User, wx.Password, func(url string, r io.Reader) error { | 183 if err := dl.Download(wa.User, wa.Password, func(url string, r io.Reader) error { |
183 feedback.Info("Get features from: '%s'", url) | 184 feedback.Info("Get features from: '%s'", url) |
184 rfc, err := wfs.ParseRawFeatureCollection(r) | 185 rfc, err := wfs.ParseRawFeatureCollection(r) |
185 if err != nil { | 186 if err != nil { |
186 return fmt.Errorf("parsing GetFeature document failed: %v", err) | 187 return fmt.Errorf("parsing GetFeature document failed: %v", err) |
187 } | 188 } |