Mercurial > gemma
comparison pkg/wfs/global.go @ 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 | |
children | d7ef169fd0d3 |
comparison
equal
deleted
inserted
replaced
2633:eb1d119f253f | 2634:49ce3c11ca72 |
---|---|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 | |
2 // without warranty, see README.md and license for details. | |
3 // | |
4 // SPDX-License-Identifier: AGPL-3.0-or-later | |
5 // License-Filename: LICENSES/AGPL-3.0.txt | |
6 // | |
7 // Copyright (C) 2019 by via donau | |
8 // – Österreichische Wasserstraßen-Gesellschaft mbH | |
9 // Software engineering by Intevation GmbH | |
10 // | |
11 // Author(s): | |
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> | |
13 | |
14 package wfs | |
15 | |
16 import ( | |
17 "io" | |
18 "log" | |
19 "os/exec" | |
20 ) | |
21 | |
22 type ( | |
23 Downloader interface { | |
24 Download(handler func(string, io.Reader) error) error | |
25 } | |
26 | |
27 GeoJSONDownloader []string | |
28 GMLDownloader []string | |
29 ) | |
30 | |
31 var GetFeatures = setup() | |
32 | |
33 func setup() func(*Capabilities, string, string) (Downloader, error) { | |
34 path, err := exec.LookPath("ogr2ogr") | |
35 if err != nil { | |
36 log.Println("info: ogr2ogr not installed. Using direct GeoJSON WFS download.") | |
37 return GetFeaturesGeoJSON | |
38 } | |
39 log.Printf("info: ogr2ogr found at %s. Using GML WFS download.\n", path) | |
40 return GetFeaturesGML | |
41 } | |
42 | |
43 func GetFeaturesGeoJSON( | |
44 caps *Capabilities, | |
45 featureTypeName string, | |
46 sortBy string, | |
47 ) (Downloader, error) { | |
48 return nil, nil | |
49 } | |
50 | |
51 func GetFeaturesGML( | |
52 caps *Capabilities, | |
53 featureTypeName string, | |
54 sortBy string, | |
55 ) (Downloader, error) { | |
56 return nil, nil | |
57 } | |
58 | |
59 func (gjd GeoJSONDownloader) Download(handler func(string, io.Reader)) error { | |
60 // TODO: Implement, me! | |
61 return nil | |
62 } | |
63 | |
64 func (gmd GMLDownloader) Download(handler func(string, io.Reader)) error { | |
65 // TODO: Implement, me! | |
66 return nil | |
67 } |