# HG changeset patch # User Raimund Renkert # Date 1547816285 -3600 # Node ID 8a56a64e441096260582e0e98de43f2836998402 # Parent 5f2510523b9cabcfbb5f173d74ec1340ec167dec Summarize the result of fairway dimension import for review. diff -r 5f2510523b9c -r 8a56a64e4410 pkg/imports/fd.go --- a/pkg/imports/fd.go Fri Jan 18 12:17:07 2019 +0100 +++ b/pkg/imports/fd.go Fri Jan 18 13:58:05 2019 +0100 @@ -104,6 +104,12 @@ HydroSorDat fdTime `json:"hydro_sordat"` } +type fdSummary struct { + Lat float64 `json:"lat"` + Lon float64 `json:"lon"` + ID int64 `json:"id"` +} + const ( fdStageDoneSQL = ` UPDATE waterway.fairway_dimensions SET staging_done = true @@ -147,7 +153,10 @@ )).geom AS geom ) AS clipped WHERE clipped.geom IS NOT NULL -RETURNING id` +RETURNING id, + ST_X(ST_Centroid(area::geometry)), + ST_Y(ST_Centroid(area::geometry)) + ` ) // Do executes the actual fairway dimension import. @@ -206,6 +215,7 @@ missingProperties int badProperties int features int + fds []fdSummary ) if err := wfs.DownloadURLs(urls, func(r io.Reader) error { @@ -247,6 +257,7 @@ return err } var fdid int64 + var lat, lon float64 if err := insertStmt.QueryRowContext( ctx, p.asWKB(), @@ -257,7 +268,7 @@ fd.Depth, props.HydroSorDat.Time, fd.SourceOrganization, - ).Scan(&fdid); err != nil { + ).Scan(&fdid, &lat, &lon); err != nil { feedback.Error("error: %s", err) return err } @@ -265,6 +276,7 @@ if err = track(ctx, tx, importID, "waterway.fairway_dimensions", fdid); err != nil { return err } + fds = append(fds, fdSummary{ID: fdid, Lat: lat, Lon: lon}) features++ default: @@ -300,5 +312,16 @@ features, time.Since(start)) } - return nil, err + summary := struct { + Date time.Time `json:"date"` + LOS int `json:"los"` + SourceOrganization string `json:"source-organization"` + FdArea []fdSummary `json:"fd-area"` + }{ + Date: time.Now(), + LOS: fd.LOS, + SourceOrganization: fd.SourceOrganization, + FdArea: fds, + } + return &summary, err }