Mercurial > gemma
changeset 4990:16259efa828f
Dont try to download from WFS if they dont have features.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 05 Mar 2020 17:56:08 +0100 |
parents | f879933cf671 |
children | 6a48e5c6fe2f |
files | pkg/imports/wfsjob.go pkg/wfs/download.go pkg/wfs/global.go |
diffstat | 3 files changed, 18 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/imports/wfsjob.go Thu Mar 05 14:05:45 2020 +0100 +++ b/pkg/imports/wfsjob.go Thu Mar 05 17:56:08 2020 +0100 @@ -128,7 +128,6 @@ dl, err := wfs.GetFeatures(caps, wfj.FeatureType, nilString(wfj.SortBy)) if err != nil { - feedback.Error("Cannot create GetFeature URLs. %v", err) return nil, err }
--- a/pkg/wfs/download.go Thu Mar 05 14:05:45 2020 +0100 +++ b/pkg/wfs/download.go Thu Mar 05 17:56:08 2020 +0100 @@ -165,6 +165,8 @@ if err != nil { log.Printf("error: %v\n", err) supportsPaging = false + } else if numFeatures == 0 { + return nil, nil } else { log.Printf("info: Number of features: %d\n", numFeatures) } @@ -220,20 +222,22 @@ q.RawQuery = v.Encode() return q.String() } - if numFeatures <= featuresPerPage { - log.Println("info: All features can be fetched in one page.") - downloadURLs = []string{pagedURL(0, numFeatures)} - } else { - log.Println("info: Features need to be downloaded in pages.") - for pos := 0; pos < numFeatures; { - var count int - if rest := numFeatures - pos; rest >= numFeatures { - count = numFeatures - } else { - count = rest + if numFeatures > 0 { + if numFeatures <= featuresPerPage { + log.Println("info: All features can be fetched in one page.") + downloadURLs = []string{pagedURL(0, numFeatures)} + } else { + log.Println("info: Features need to be downloaded in pages.") + for pos := 0; pos < numFeatures; { + var count int + if rest := numFeatures - pos; rest >= numFeatures { + count = numFeatures + } else { + count = rest + } + downloadURLs = append(downloadURLs, pagedURL(pos, count)) + pos += count } - downloadURLs = append(downloadURLs, pagedURL(pos, count)) - pos += count } } } else { // No paging support.
--- a/pkg/wfs/global.go Thu Mar 05 14:05:45 2020 +0100 +++ b/pkg/wfs/global.go Thu Mar 05 17:56:08 2020 +0100 @@ -15,7 +15,6 @@ import ( "bufio" - "errors" "fmt" "io" "io/ioutil" @@ -114,7 +113,7 @@ func (gmd GMLDownloader) Download(user, password string, handler func(string, io.Reader) error) error { if len(gmd) == 0 { - return errors.New("nothing to download") + return nil } tmpDir := config.TmpDir()