changeset 2702:d7ef169fd0d3

WFS downloader: More on downloading GML. WIP.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 18 Mar 2019 15:45:42 +0100
parents e622689d73bd
children c887666b110f
files pkg/wfs/download.go pkg/wfs/global.go
diffstat 2 files changed, 27 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/wfs/download.go	Mon Mar 18 15:43:03 2019 +0100
+++ b/pkg/wfs/download.go	Mon Mar 18 15:45:42 2019 +0100
@@ -43,8 +43,6 @@
 	ErrOutputFormatNotSupported = errors.New("Output format not supported")
 )
 
-var FormatGeoJSON = []string{"geojson", "application/json"}
-
 // GetCapabilities downloads a capabilities document for a given URL.
 func GetCapabilities(capURL string) (*Capabilities, error) {
 
--- a/pkg/wfs/global.go	Mon Mar 18 15:43:03 2019 +0100
+++ b/pkg/wfs/global.go	Mon Mar 18 15:45:42 2019 +0100
@@ -19,6 +19,16 @@
 	"os/exec"
 )
 
+var (
+	FormatGeoJSON = []string{"geojson", "application/json"}
+	FormatGML     = []string{
+		"gml2", "gml3", "gml32",
+		"text/xml; subtype=gml/2.1.2",
+		"text/xml; subtype=gml/3.1.1",
+		"text/xml; subtype=gml/3.2",
+	}
+)
+
 type (
 	Downloader interface {
 		Download(handler func(string, io.Reader) error) error
@@ -45,7 +55,12 @@
 	featureTypeName string,
 	sortBy string,
 ) (Downloader, error) {
-	return nil, nil
+	urls, err := GetFeaturesGET(
+		caps,
+		featureTypeName,
+		FormatGeoJSON,
+		sortBy)
+	return GeoJSONDownloader(urls), err
 }
 
 func GetFeaturesGML(
@@ -53,15 +68,19 @@
 	featureTypeName string,
 	sortBy string,
 ) (Downloader, error) {
-	return nil, nil
+	urls, err := GetFeaturesGET(
+		caps,
+		featureTypeName,
+		FormatGML,
+		sortBy)
+	return GMLDownloader(urls), err
 }
 
-func (gjd GeoJSONDownloader) Download(handler func(string, io.Reader)) error {
+func (gjd GeoJSONDownloader) Download(handler func(string, io.Reader) error) error {
+	return DownloadURLs([]string(gjd), handler)
+}
+
+func (gmd GMLDownloader) Download(handler func(string, io.Reader) error) error {
 	// TODO: Implement, me!
 	return nil
 }
-
-func (gmd GMLDownloader) Download(handler func(string, io.Reader)) error {
-	// TODO: Implement, me!
-	return nil
-}