comparison pkg/imports/wp.go @ 2092:f70f67eaa7aa

Waterway profile import: log warnings if no profile geometry can be found for ISRS code.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 01 Feb 2019 17:03:28 +0100
parents 3f32b18bbd4c
children a9d28c489761
comparison
equal deleted inserted replaced
2091:3f32b18bbd4c 2092:f70f67eaa7aa
26 "path/filepath" 26 "path/filepath"
27 "strconv" 27 "strconv"
28 "strings" 28 "strings"
29 "time" 29 "time"
30 30
31 "github.com/jackc/pgx/pgtype"
32
31 "gemma.intevation.de/gemma/pkg/common" 33 "gemma.intevation.de/gemma/pkg/common"
32 "gemma.intevation.de/gemma/pkg/misc" 34 "gemma.intevation.de/gemma/pkg/misc"
33 "gemma.intevation.de/gemma/pkg/models" 35 "gemma.intevation.de/gemma/pkg/models"
34 "gemma.intevation.de/gemma/pkg/wfs" 36 "gemma.intevation.de/gemma/pkg/wfs"
35 "github.com/jackc/pgx/pgtype"
36 ) 37 )
37 38
38 type WaterwayProfiles struct { 39 type WaterwayProfiles struct {
39 Dir string `json:"dir"` 40 Dir string `json:"dir"`
40 // URL the GetCapabilities URL of the WFS service. 41 // URL the GetCapabilities URL of the WFS service.
124 $9, 125 $9,
125 $10, 126 $10,
126 $11, 127 $11,
127 $12, 128 $12,
128 $13 129 $13
129 ) RETURNING id` 130 ) RETURNING id, geom is NULL`
130 131
131 wpStageDoneSQL = ` 132 wpStageDoneSQL = `
132 UPDATE waterway.waterway_profiles SET staging_done = true 133 UPDATE waterway.waterway_profiles SET staging_done = true
133 WHERE id IN ( 134 WHERE id IN (
134 SELECT key FROM import.track_imports 135 SELECT key FROM import.track_imports
506 } 507 }
507 508
508 source := row[sourceIdx] 509 source := row[sourceIdx]
509 510
510 var id int64 511 var id int64
512 var noGeom bool
513
511 if err := insertStmt.QueryRowContext( 514 if err := insertStmt.QueryRowContext(
512 ctx, 515 ctx,
513 location.CountryCode, 516 location.CountryCode,
514 location.LoCode, 517 location.LoCode,
515 location.FairwaySection, 518 location.FairwaySection,
521 hnwl, 524 hnwl,
522 fe30, 525 fe30,
523 fe100, 526 fe100,
524 dateInfo, 527 dateInfo,
525 source, 528 source,
526 ).Scan(&id); err != nil { 529 ).Scan(&id, &noGeom); err != nil {
527 return nil, err 530 return nil, err
528 } 531 }
529 532
530 if _, err := trackStmt.ExecContext( 533 if _, err := trackStmt.ExecContext(
531 ctx, importID, "waterway.waterway_profiles", id); err != nil { 534 ctx, importID, "waterway.waterway_profiles", id); err != nil {
532 return nil, err 535 return nil, err
533 } 536 }
537
538 if noGeom {
539 feedback.Warn(
540 "No profile geometry found for %s in line %d.", location, line)
541 }
542
534 ids = append(ids, id) 543 ids = append(ids, id)
535 } 544 }
536 if len(ids) == 0 { 545 if len(ids) == 0 {
537 return nil, UnchangedError("No new entries in waterway profiles.") 546 return nil, UnchangedError("No new entries in waterway profiles.")
538 } 547 }