comparison pkg/imports/wa.go @ 2938:ecb1e34157a3

Fix logging in area import
author Tom Gottfried <tom@intevation.de>
date Thu, 04 Apr 2019 16:25:02 +0200
parents 93fa55bce126
children 4acbee65275d
comparison
equal deleted inserted replaced
2937:0d79f5eec630 2938:ecb1e34157a3
101 best_utm(ST_Transform(new_area, 4326)))) 101 best_utm(ST_Transform(new_area, 4326))))
102 ELSE ST_Intersection((SELECT a FROM resp), 102 ELSE ST_Intersection((SELECT a FROM resp),
103 ST_MakeValid(ST_Transform(new_area, (SELECT ST_SRID(a) FROM resp)))) 103 ST_MakeValid(ST_Transform(new_area, (SELECT ST_SRID(a) FROM resp))))
104 END, 104 END,
105 3), 4326)) AS dmp 105 3), 4326)) AS dmp
106 RETURNING id
106 ` 107 `
107 ) 108 )
108 109
109 // Do executes the actual waterway axis import. 110 // Do executes the actual waterway axis import.
110 func (wx *WaterwayArea) Do( 111 func (wx *WaterwayArea) Do(
167 168
168 var ( 169 var (
169 unsupported = stringCounter{} 170 unsupported = stringCounter{}
170 missingProperties int 171 missingProperties int
171 badProperties int 172 badProperties int
173 outside int
172 features int 174 features int
173 ) 175 )
174 176
175 if err := dl.Download(wx.User, wx.Password, func(url string, r io.Reader) error { 177 if err := dl.Download(wx.User, wx.Password, func(url string, r io.Reader) error {
176 feedback.Info("Get features from: '%s'", url) 178 feedback.Info("Get features from: '%s'", url)
225 case "Polygon": 227 case "Polygon":
226 var p polygonSlice 228 var p polygonSlice
227 if err := json.Unmarshal(*feature.Geometry.Coordinates, &p); err != nil { 229 if err := json.Unmarshal(*feature.Geometry.Coordinates, &p); err != nil {
228 return err 230 return err
229 } 231 }
230 if err := savepoint(func() error { 232 var waid int64
231 _, err := insertStmt.ExecContext( 233 err := savepoint(func() error {
234 err := insertStmt.QueryRowContext(
232 ctx, 235 ctx,
233 p.asWKB(), 236 p.asWKB(),
234 epsg, 237 epsg,
235 catccl, 238 catccl,
236 dirimp, 239 dirimp,
237 ) 240 ).Scan(&waid)
238 return err 241 return err
239 }); err != nil { 242 })
243 switch {
244 case err == sql.ErrNoRows:
245 outside++
246 // ignore -> filtered by responsibility_areas
247 case err != nil:
240 feedback.Warn(handleError(err).Error()) 248 feedback.Warn(handleError(err).Error())
241 } else { 249 default:
242 features++ 250 features++
243 } 251 }
244 default: 252 default:
245 unsupported[feature.Geometry.Type]++ 253 unsupported[feature.Geometry.Type]++
246 } 254 }
258 feedback.Warn("Missing properties: %d", missingProperties) 266 feedback.Warn("Missing properties: %d", missingProperties)
259 } 267 }
260 268
261 if len(unsupported) != 0 { 269 if len(unsupported) != 0 {
262 feedback.Warn("Unsupported types found: %s", unsupported) 270 feedback.Warn("Unsupported types found: %s", unsupported)
271 }
272
273 if outside > 0 {
274 feedback.Info("Features outside responsibility area: %d", outside)
263 } 275 }
264 276
265 if features == 0 { 277 if features == 0 {
266 err := errors.New("No features found") 278 err := errors.New("No features found")
267 feedback.Error("%v", err) 279 feedback.Error("%v", err)