Mercurial > gemma
comparison pkg/wfs/capabilities.go @ 1596:74413d52c439
Started with WFS Capabilities parser.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 14 Dec 2018 18:35:09 +0100 |
parents | |
children | 5e16d1fbe91f |
comparison
equal
deleted
inserted
replaced
1595:f6596daf2079 | 1596:74413d52c439 |
---|---|
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) 2018 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 "encoding/xml" | |
18 "io" | |
19 | |
20 "golang.org/x/net/html/charset" | |
21 ) | |
22 | |
23 type ServiceIdentification struct { | |
24 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 ServiceIdentification"` | |
25 | |
26 Title string | |
27 ServiceType string | |
28 ServiceTypeVersion string | |
29 } | |
30 | |
31 type Get struct { | |
32 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 Get"` | |
33 HRef string `xml:"http://www.w3.org/1999/xlink href,attr"` | |
34 } | |
35 | |
36 type Post struct { | |
37 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 Post"` | |
38 HRef string `xml:"http://www.w3.org/1999/xlink href,attr"` | |
39 } | |
40 | |
41 type HTTP struct { | |
42 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 HTTP"` | |
43 Get *Get `xml:"Get"` | |
44 Post *Post `xml:"Post"` | |
45 } | |
46 | |
47 type DCP struct { | |
48 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 DCP"` | |
49 HTTP HTTP `xml:"HTTP"` | |
50 } | |
51 | |
52 type AllowedValue struct { | |
53 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 Value"` | |
54 Value string `xml:",cdata"` | |
55 } | |
56 | |
57 type AllowedValues struct { | |
58 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 AllowedValues"` | |
59 AllowedValues []AllowedValue `xml:"Value"` | |
60 } | |
61 | |
62 type Parameter struct { | |
63 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 Parameter"` | |
64 Name string `xml:"name,attr"` | |
65 AllowedValues AllowedValues `xml:"AllowedValues"` | |
66 } | |
67 | |
68 type Operation struct { | |
69 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 Operation"` | |
70 Name string `xml:"name,attr"` | |
71 DCP DCP `xml:"DCP"` | |
72 Parameters []*Parameter `xml:"Parameter"` | |
73 } | |
74 | |
75 type OperationsMetadata struct { | |
76 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 OperationsMetadata"` | |
77 Operations []*Operation `xml:"http://www.opengis.net/ows/1.1 Operation"` | |
78 } | |
79 | |
80 type Capabilities struct { | |
81 XMLName xml.Name `xml:"http://www.opengis.net/wfs/2.0 WFS_Capabilities"` | |
82 | |
83 ServiceIdentification ServiceIdentification | |
84 OperationsMetadata OperationsMetadata | |
85 } | |
86 | |
87 func ParseCapabilities(r io.Reader) (*Capabilities, error) { | |
88 | |
89 decoder := xml.NewDecoder(r) | |
90 decoder.CharsetReader = charset.NewReaderLabel | |
91 | |
92 var capabilities Capabilities | |
93 | |
94 if err := decoder.Decode(&capabilities); err != nil { | |
95 return nil, err | |
96 } | |
97 | |
98 return &capabilities, nil | |
99 } |