Mercurial > gemma
diff pkg/wfs/global.go @ 4166:04876d865528
Made 'golint' and 'staticcheck' happy with wfs package.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 05 Aug 2019 14:35:54 +0200 |
parents | 2b6f73c30016 |
children | 16259efa828f |
line wrap: on
line diff
--- a/pkg/wfs/global.go Mon Aug 05 13:51:08 2019 +0200 +++ b/pkg/wfs/global.go Mon Aug 05 14:35:54 2019 +0200 @@ -28,8 +28,12 @@ ) var ( + // FormatGeoJSON is a list of MIME types of + // GeoJSON documents. FormatGeoJSON = []string{"geojson", "application/json"} - FormatGML = []string{ + // FormatGML is a list of MIME types + // GML documents. + FormatGML = []string{ "application/gml+xml; version=3.2", "gml2", "gml3", "gml32", "text/xml; subtype=gml/2.1.2", @@ -39,27 +43,31 @@ ) type ( + // Downloader abstracts the idea of a download function for WFS. Downloader interface { Download(user, password string, handler func(string, io.Reader) error) error } + // GeoJSONDownloader is a Downloader for GeoJSON. GeoJSONDownloader []string - GMLDownloader []string + // GMLDownloader is a Downloader for GML. + GMLDownloader []string ) +// GetFeatures is the default Downloader in this Gemma server. var GetFeatures = setup() func setup() func(*Capabilities, string, string) (Downloader, error) { path, err := exec.LookPath("ogr2ogr") if err != nil { log.Println("info: ogr2ogr not installed. Using direct GeoJSON WFS download.") - return GetFeaturesGeoJSON + return getFeaturesGeoJSON } log.Printf("info: ogr2ogr found at %s. Using GML WFS download.\n", path) - return GetFeaturesGML + return getFeaturesGML } -func GetFeaturesGeoJSON( +func getFeaturesGeoJSON( caps *Capabilities, featureTypeName string, sortBy string, @@ -72,7 +80,7 @@ return GeoJSONDownloader(urls), err } -func GetFeaturesGML( +func getFeaturesGML( caps *Capabilities, featureTypeName string, sortBy string, @@ -85,6 +93,7 @@ return GMLDownloader(urls), err } +// Download is the GeoJSON implementation of the Downloader. func (gjd GeoJSONDownloader) Download(user, password string, handler func(string, io.Reader) error) error { return DownloadURLs(user, password, []string(gjd), handler) } @@ -101,10 +110,11 @@ return places } +// Download is GML implementaion of the Downloader. 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 errors.New("nothing to download") } tmpDir := config.TmpDir()