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