comparison pkg/imports/gm.go @ 4813:0644c2b3af54

Check for mandatory measurement value in GM import.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 29 Oct 2019 17:42:51 +0100
parents 8ab1e60b7f31
children 8c46b845b406
comparison
equal deleted inserted replaced
4812:8ab1e60b7f31 4813:0644c2b3af54
388 feedback.Info("'Unit' not specified. Assuming 'cm'") 388 feedback.Info("'Unit' not specified. Assuming 'cm'")
389 unit = "cm" 389 unit = "cm"
390 } else { 390 } else {
391 unit = string(*measure.Unit) 391 unit = string(*measure.Unit)
392 } 392 }
393
394 if measure.Value == nil {
395 feedback.Warn("Missing mandatory value at %s. Ignored (bad service)",
396 measure.Measuredate.Format(time.RFC3339))
397 continue
398 }
399
393 convert, err := rescale(unit) 400 convert, err := rescale(unit)
394 if err != nil { 401 if err != nil {
395 return nil, err 402 return nil, err
396 } 403 }
397 convert(measure.Value) 404 convert(measure.Value)
398 convert(measure.Value_min) 405 convert(measure.Value_min)
399 convert(measure.Value_max) 406 convert(measure.Value_max)
400 407
401 // -99999 is used by some gauges to signal an error 408 // -99999 is used by some gauges to signal an error
402 if measure.Value != nil && *measure.Value == -99999 { 409 if *measure.Value == -99999 {
403 badValue++ 410 badValue++
404 continue 411 continue
405 } 412 }
406 413
407 var dummy int 414 var dummy int
451 feedback.Error(pgxutils.ReadableError{Err: err}.Error()) 458 feedback.Error(pgxutils.ReadableError{Err: err}.Error())
452 default: 459 default:
453 newP++ 460 newP++
454 } 461 }
455 } else { 462 } else {
456 if measure.Value == nil {
457 feedback.Info("Missing value at %s. Ignored",
458 measure.Measuredate.Format(time.RFC3339))
459 continue
460 }
461 err = insertGMStmt.QueryRowContext( 463 err = insertGMStmt.QueryRowContext(
462 ctx, 464 ctx,
463 currIsrs.CountryCode, 465 currIsrs.CountryCode,
464 currIsrs.LoCode, 466 currIsrs.LoCode,
465 currIsrs.FairwaySection, 467 currIsrs.FairwaySection,