# HG changeset patch # User Tom Gottfried # Date 1554387269 -7200 # Node ID 0d79f5eec63098c00a78c47565477aa5c40457e5 # Parent 70946dc00abdbd43d7718c775feb1b9ab01ca368 Fix logging in axis import diff -r 70946dc00abd -r 0d79f5eec630 pkg/imports/wx.go --- a/pkg/imports/wx.go Thu Apr 04 16:03:28 2019 +0200 +++ b/pkg/imports/wx.go Thu Apr 04 16:14:29 2019 +0200 @@ -183,6 +183,7 @@ unsupported = stringCounter{} missingProperties int badProperties int + outside int features int ) @@ -241,11 +242,12 @@ epsg, props, nobjnam, + &outside, + &features, checkCrossingStmt, insertStmt); err != nil { return err } - features++ case "MultiLineString": var ls []lineSlice if err := json.Unmarshal(*feature.Geometry.Coordinates, &ls); err != nil { @@ -260,11 +262,12 @@ epsg, props, nobjnam, + &outside, + &features, checkCrossingStmt, insertStmt); err != nil { return err } - features++ } default: unsupported[feature.Geometry.Type]++ @@ -287,6 +290,10 @@ feedback.Warn("Unsupported types found: %s", unsupported) } + if outside > 0 { + feedback.Info("Features outside responsibility area: %d", outside) + } + if features == 0 { return nil, errors.New("No features found") } @@ -307,10 +314,11 @@ epsg int, props waterwayAxisProperties, nobjnam sql.NullString, + outside, features *int, checkCrossingStmt, insertStmt *sql.Stmt, ) error { var id int - if err := savepoint(func() error { + err := savepoint(func() error { err := insertStmt.QueryRowContext( ctx, l.asWKB(), @@ -319,22 +327,29 @@ nobjnam, ).Scan(&id) return err - }); err != nil { + }) + switch { + case err == sql.ErrNoRows: + *outside++ + // ignore -> filtered by responsibility_areas + return nil + case err != nil: feedback.Warn(handleError(err).Error()) - } - - var crossing string - switch err := checkCrossingStmt.QueryRowContext( - ctx, - id, - ).Scan(&crossing); { - case err != nil && err != sql.ErrNoRows: - return err - case err == nil: - feedback.Warn( - "Linestring %d crosses previously imported linestring near %s. "+ - "Finding a contiguous axis may not work here", - id, crossing) + default: + *features++ + var crossing string + switch err := checkCrossingStmt.QueryRowContext( + ctx, + id, + ).Scan(&crossing); { + case err != nil && err != sql.ErrNoRows: + return err + case err == nil: + feedback.Warn( + "Linestring %d crosses previously imported linestring near %s. "+ + "Finding a contiguous axis may not work here", + id, crossing) + } } return nil }