Mercurial > gemma
changeset 2634:49ce3c11ca72
WFS downloads: Started with GML based downloads based on installation of ogr2ogr.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 13 Mar 2019 18:33:03 +0100 |
parents | eb1d119f253f |
children | 7ac90c4db14a |
files | pkg/wfs/global.go |
diffstat | 1 files changed, 67 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/wfs/global.go Wed Mar 13 18:33:03 2019 +0100 @@ -0,0 +1,67 @@ +// This is Free Software under GNU Affero General Public License v >= 3.0 +// without warranty, see README.md and license for details. +// +// SPDX-License-Identifier: AGPL-3.0-or-later +// License-Filename: LICENSES/AGPL-3.0.txt +// +// Copyright (C) 2019 by via donau +// – Österreichische Wasserstraßen-Gesellschaft mbH +// Software engineering by Intevation GmbH +// +// Author(s): +// * Sascha L. Teichmann <sascha.teichmann@intevation.de> + +package wfs + +import ( + "io" + "log" + "os/exec" +) + +type ( + Downloader interface { + Download(handler func(string, io.Reader) error) error + } + + GeoJSONDownloader []string + GMLDownloader []string +) + +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 + } + log.Printf("info: ogr2ogr found at %s. Using GML WFS download.\n", path) + return GetFeaturesGML +} + +func GetFeaturesGeoJSON( + caps *Capabilities, + featureTypeName string, + sortBy string, +) (Downloader, error) { + return nil, nil +} + +func GetFeaturesGML( + caps *Capabilities, + featureTypeName string, + sortBy string, +) (Downloader, error) { + return nil, nil +} + +func (gjd GeoJSONDownloader) Download(handler func(string, io.Reader)) error { + // TODO: Implement, me! + return nil +} + +func (gmd GMLDownloader) Download(handler func(string, io.Reader)) error { + // TODO: Implement, me! + return nil +}