Mercurial > gemma
changeset 4978:35a3dc12050f
Give better names to generalized WFS feature downloaders.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 03 Mar 2020 18:12:18 +0100 |
parents | 4bf6cde2d996 |
children | ee12730acd73 |
files | pkg/imports/fm.go pkg/imports/pointwfs.go |
diffstat | 2 files changed, 44 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/imports/fm.go Tue Mar 03 18:05:33 2020 +0100 +++ b/pkg/imports/fm.go Tue Mar 03 18:12:18 2020 +0100 @@ -209,7 +209,7 @@ func init() { RegisterJobCreator(BCNLATHYDROJobKind, - &GeometryWFSJobCreator{ + &WFSFeatureJobCreator{ description: "fairway marks bcnlat (HYDRO)", depends: [2][]string{{"fairway_marks_bcnlat_hydro"}, {}}, newConsumer: newSQLConsumer( @@ -224,7 +224,7 @@ }) RegisterJobCreator(BCNLATIENCJobKind, - &GeometryWFSJobCreator{ + &WFSFeatureJobCreator{ description: "fairway marks bcnlat (IENC)", depends: [2][]string{{"fairway_marks_bcnlat_ienc"}, {}}, newConsumer: newSQLConsumer( @@ -240,7 +240,7 @@ }) RegisterJobCreator(BOYLATHYDROJobKind, - &GeometryWFSJobCreator{ + &WFSFeatureJobCreator{ description: "fairway marks boylat (HYDRO)", depends: [2][]string{{"fairway_marks_boylat_hydro"}, {}}, newConsumer: newSQLConsumer( @@ -256,7 +256,7 @@ }) RegisterJobCreator(BOYLATIENCJobKind, - &GeometryWFSJobCreator{ + &WFSFeatureJobCreator{ description: "fairway marks boylat (IENC)", depends: [2][]string{{"fairway_marks_boylat_ienc"}, {}}, newConsumer: newSQLConsumer( @@ -272,7 +272,7 @@ }) RegisterJobCreator(BOYCARJobKind, - &GeometryWFSJobCreator{ + &WFSFeatureJobCreator{ description: "fairway marks boycar", depends: [2][]string{{"fairway_marks_boycar"}, {}}, newConsumer: newSQLConsumer( @@ -288,7 +288,7 @@ }) RegisterJobCreator(BOYSAWJobKind, - &GeometryWFSJobCreator{ + &WFSFeatureJobCreator{ description: "fairway marks boysaw", depends: [2][]string{{"fairway_marks_boysaw"}, {}}, newConsumer: newSQLConsumer( @@ -303,7 +303,7 @@ }) RegisterJobCreator(BOYSPPJobKind, - &GeometryWFSJobCreator{ + &WFSFeatureJobCreator{ description: "fairway marks boyspp", depends: [2][]string{{"fairway_marks_boyspp"}, {}}, newConsumer: newSQLConsumer( @@ -319,7 +319,7 @@ }) RegisterJobCreator(DAYMARHYDROJobKind, - &GeometryWFSJobCreator{ + &WFSFeatureJobCreator{ description: "fairway marks daymar (HYDRO)", depends: [2][]string{{"fairway_marks_daymar_hydro"}, {}}, newConsumer: newSQLConsumer( @@ -334,7 +334,7 @@ }) RegisterJobCreator(DAYMARIENCJobKind, - &GeometryWFSJobCreator{ + &WFSFeatureJobCreator{ description: "fairway marks daymar (IENC)", depends: [2][]string{{"fairway_marks_daymar_ienc"}, {}}, newConsumer: newSQLConsumer( @@ -350,7 +350,7 @@ }) RegisterJobCreator(LIGHTSJobKind, - &GeometryWFSJobCreator{ + &WFSFeatureJobCreator{ description: "fairway marks lights", depends: [2][]string{{"fairway_marks_lights"}, {}}, newConsumer: newSQLConsumer( @@ -369,7 +369,7 @@ }) RegisterJobCreator(NOTMRKJobKind, - &GeometryWFSJobCreator{ + &WFSFeatureJobCreator{ description: "fairway marks notmrk", depends: [2][]string{{"fairway_marks_lights"}, {}}, newConsumer: newSQLConsumer( @@ -388,7 +388,7 @@ }) RegisterJobCreator(RTPBCNJobKind, - &GeometryWFSJobCreator{ + &WFSFeatureJobCreator{ description: "fairway marks rtpbcn", depends: [2][]string{{"fairway_marks_rtpbcn"}, {}}, newConsumer: newSQLConsumer( @@ -403,7 +403,7 @@ }) RegisterJobCreator(TOPMARJobKind, - &GeometryWFSJobCreator{ + &WFSFeatureJobCreator{ description: "fairway marks topmar", depends: [2][]string{{"fairway_marks_topmar"}, {}}, newConsumer: newSQLConsumer(
--- a/pkg/imports/pointwfs.go Tue Mar 03 18:05:33 2020 +0100 +++ b/pkg/imports/pointwfs.go Tue Mar 03 18:12:18 2020 +0100 @@ -34,60 +34,60 @@ ) type ( - WFSGeometryConsumer interface { + WFSFeatureConsumer interface { Commit() error Rollback() error - NewFeature() (string, interface{}, interface{}) + NewFeature() (kind string, geom interface{}, properties interface{}) Consume(geom, properties interface{}, epsg int) error } - GeometryWFSJobCreator struct { + WFSFeatureJobCreator struct { description string depends [2][]string - newConsumer func(context.Context, *sql.Conn, Feedback) (WFSGeometryConsumer, error) + newConsumer func(context.Context, *sql.Conn, Feedback) (WFSFeatureConsumer, error) } - GeometryWFSJob struct { + WFSFeatureJob struct { models.WFSImport - creator *GeometryWFSJobCreator + creator *WFSFeatureJobCreator } ) -func (gwjc *GeometryWFSJobCreator) Description() string { - return gwjc.description +func (wfjc *WFSFeatureJobCreator) Description() string { + return wfjc.description } -func (gwjc *GeometryWFSJobCreator) Depends() [2][]string { - return gwjc.depends +func (wfjc *WFSFeatureJobCreator) Depends() [2][]string { + return wfjc.depends } -func (*GeometryWFSJobCreator) AutoAccept() bool { +func (*WFSFeatureJobCreator) AutoAccept() bool { return true } // StageDone is a NOP for WFS imports. -func (*GeometryWFSJobCreator) StageDone(context.Context, *sql.Tx, int64) error { +func (*WFSFeatureJobCreator) StageDone(context.Context, *sql.Tx, int64) error { return nil } -func (gwjc *GeometryWFSJobCreator) Create() Job { - return &GeometryWFSJob{creator: gwjc} +func (wfjc *WFSFeatureJobCreator) Create() Job { + return &WFSFeatureJob{creator: wfjc} } // Description gives a short info about relevant facts of this import. -func (gwj *GeometryWFSJob) Description() (string, error) { - return gwj.URL + "|" + gwj.FeatureType, nil +func (wfj *WFSFeatureJob) Description() (string, error) { + return wfj.URL + "|" + wfj.FeatureType, nil } // CleanUp for WFS imports is a NOP. -func (*GeometryWFSJob) CleanUp() error { +func (*WFSFeatureJob) CleanUp() error { return nil } -func (gwj *GeometryWFSJob) Do( +func (wfj *WFSFeatureJob) Do( ctx context.Context, importID int64, conn *sql.Conn, @@ -96,21 +96,21 @@ start := time.Now() - feedback.Info("Import %s", gwj.creator.Description()) + feedback.Info("Import %s", wfj.creator.Description()) - feedback.Info("Loading capabilities from %s", gwj.URL) - caps, err := wfs.GetCapabilities(gwj.URL) + feedback.Info("Loading capabilities from %s", wfj.URL) + caps, err := wfs.GetCapabilities(wfj.URL) if err != nil { feedback.Error("Loading capabilities failed: %v", err) return nil, err } - ft := caps.FindFeatureType(gwj.FeatureType) + ft := caps.FindFeatureType(wfj.FeatureType) if ft == nil { - return nil, fmt.Errorf("unknown feature type '%s'", gwj.FeatureType) + return nil, fmt.Errorf("unknown feature type '%s'", wfj.FeatureType) } - feedback.Info("Found feature type '%s'", gwj.FeatureType) + feedback.Info("Found feature type '%s'", wfj.FeatureType) epsg, err := wfs.CRSToEPSG(ft.DefaultCRS) if err != nil { @@ -118,11 +118,11 @@ return nil, err } - if nilString(gwj.SortBy) != "" { - feedback.Info("Features will be sorted by '%s'", *gwj.SortBy) + if nilString(wfj.SortBy) != "" { + feedback.Info("Features will be sorted by '%s'", *wfj.SortBy) } - dl, err := wfs.GetFeatures(caps, gwj.FeatureType, nilString(gwj.SortBy)) + dl, err := wfs.GetFeatures(caps, wfj.FeatureType, nilString(wfj.SortBy)) if err != nil { feedback.Error("Cannot create GetFeature URLs. %v", err) return nil, err @@ -136,13 +136,13 @@ features int ) - consumer, err := gwj.creator.newConsumer(ctx, conn, feedback) + consumer, err := wfj.creator.newConsumer(ctx, conn, feedback) if err != nil { return nil, err } defer consumer.Rollback() - if err := dl.Download(nilString(gwj.User), nilString(gwj.Password), func(url string, r io.Reader) error { + if err := dl.Download(nilString(wfj.User), nilString(wfj.Password), func(url string, r io.Reader) error { feedback.Info("Get features from: '%s'", url) rfc, err := wfs.ParseRawFeatureCollection(r) if err != nil { @@ -306,8 +306,8 @@ preCommit func(*SQLGeometryConsumer) error, newFeature func() (string, interface{}, interface{}), -) func(context.Context, *sql.Conn, Feedback) (WFSGeometryConsumer, error) { - return func(ctx context.Context, conn *sql.Conn, feedback Feedback) (WFSGeometryConsumer, error) { +) func(context.Context, *sql.Conn, Feedback) (WFSFeatureConsumer, error) { + return func(ctx context.Context, conn *sql.Conn, feedback Feedback) (WFSFeatureConsumer, error) { tx, err := conn.BeginTx(ctx, nil) if err != nil { return nil, err