annotate pkg/wfs/capabilities.go @ 1679:2dc7768be0e4

Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 26 Dec 2018 21:01:29 +0100
parents efc409e330a6
children 6caf5cd6249e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1596
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 // This is Free Software under GNU Affero General Public License v >= 3.0
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2 // without warranty, see README.md and license for details.
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 //
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4 // SPDX-License-Identifier: AGPL-3.0-or-later
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 // License-Filename: LICENSES/AGPL-3.0.txt
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 //
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 // Copyright (C) 2018 by via donau
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 // – Österreichische Wasserstraßen-Gesellschaft mbH
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 // Software engineering by Intevation GmbH
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 //
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 // Author(s):
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de>
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 package wfs
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 import (
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 "encoding/xml"
1679
2dc7768be0e4 Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1614
diff changeset
18 "errors"
1596
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 "io"
1608
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
20 "regexp"
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
21 "strconv"
1596
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 "golang.org/x/net/html/charset"
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 )
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25
1600
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
26 type Keyword struct {
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
27 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 Keyword"`
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
28 Value string `xml:",cdata"`
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
29 }
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
30 type Keywords struct {
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
31 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 Keywords"`
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
32 Keywords []Keyword `xml:"Keyword"`
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
33 }
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
34
1596
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 type ServiceIdentification struct {
1600
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
36 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 ServiceIdentification"`
1596
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 Title string
1600
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
38 Abstract string
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
39 Keywords Keywords `xml:"Keywords"`
1596
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 ServiceType string
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 ServiceTypeVersion string
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 }
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 type Get struct {
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 Get"`
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 HRef string `xml:"http://www.w3.org/1999/xlink href,attr"`
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 }
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 type Post struct {
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 Post"`
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 HRef string `xml:"http://www.w3.org/1999/xlink href,attr"`
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 }
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 type HTTP struct {
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 HTTP"`
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 Get *Get `xml:"Get"`
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 Post *Post `xml:"Post"`
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 }
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 type DCP struct {
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 DCP"`
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 HTTP HTTP `xml:"HTTP"`
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 }
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64
1599
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
65 type Value struct {
1596
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 Value"`
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 Value string `xml:",cdata"`
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 }
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 type AllowedValues struct {
1599
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
71 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 AllowedValues"`
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
72 Values []Value `xml:"Value"`
1596
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 }
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75 type Parameter struct {
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 Parameter"`
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 Name string `xml:"name,attr"`
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 AllowedValues AllowedValues `xml:"AllowedValues"`
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 }
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80
1599
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
81 type DefaultValue struct {
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
82 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 DefaultValue"`
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
83 Value string `xml:",cdata"`
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
84 }
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
85
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
86 type Constraint struct {
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
87 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 Constraint"`
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
88 Name string `xml:"name,attr"`
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
89 AllowedValues AllowedValues `xml:"AllowedValues"`
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
90 DefaultValue *DefaultValue `xml:"DefaultValue"`
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
91 }
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
92
1596
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 type Operation struct {
1599
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
94 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 Operation"`
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
95 Name string `xml:"name,attr"`
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
96 DCP DCP `xml:"DCP"`
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
97 Parameters []*Parameter `xml:"Parameter"`
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
98 Constraints []*Constraint `xml:"Constraint"`
1596
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 }
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 type OperationsMetadata struct {
1599
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
102 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 OperationsMetadata"`
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
103 Operations []*Operation `xml:"Operation"`
5e16d1fbe91f WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1596
diff changeset
104 Constraints []*Constraint `xml:"Constraint"`
1596
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105 }
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106
1600
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
107 type WGS84BoundingBox struct {
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
108 XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 WGS84BoundingBox"`
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
109 LowerCorner string `xml:"LowerCorner"`
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
110 UpperCorner string `xml:"UpperCorner"`
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
111 }
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
112
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
113 type FeatureType struct {
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
114 XMLName xml.Name `xml:"http://www.opengis.net/wfs/2.0 FeatureType"`
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
115 Name string `xml:"Name"`
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
116 Title string `xml:"Title"`
1602
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
117 Abstract string `xml:"Abstract"`
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
118 Keywords Keywords `xml:"Keywords"`
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
119 DefaultCRS string `xml:"DefaultCRS"`
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
120 OtherCRSs []string `xml:"OtherCRS"`
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
121 WGS84BoundingBox *WGS84BoundingBox `xml:"WGS84BoundingBox"`
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
122 Namespaces []xml.Name `xml:"-"`
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
123 }
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
124
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
125 // shadowFeatureType is used to prevent recursive UnmarshalXML for FeatureType.
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
126 type shadowFeatureType struct {
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
127 XMLName xml.Name `xml:"http://www.opengis.net/wfs/2.0 FeatureType"`
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
128 Name string `xml:"Name"`
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
129 Title string `xml:"Title"`
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
130 Abstract string `xml:"Abstract"`
1600
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
131 Keywords Keywords `xml:"Keywords"`
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
132 DefaultCRS string `xml:"DefaultCRS"`
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
133 OtherCRSs []string `xml:"OtherCRS"`
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
134 WGS84BoundingBox *WGS84BoundingBox `xml:"WGS84BoundingBox"`
1602
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
135 Namespaces []xml.Name `xml:"-"`
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
136 }
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
137
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
138 func (ft *FeatureType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
139 // Filter out the namespaces for this feature type.
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
140 var ns []xml.Name
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
141 for _, attr := range start.Attr {
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
142 if attr.Name.Space == "xmlns" {
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
143 ns = append(ns, xml.Name{Space: attr.Name.Local, Local: attr.Value})
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
144 }
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
145 }
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
146 var sft shadowFeatureType
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
147 if err := d.DecodeElement(&sft, &start); err != nil {
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
148 return err
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
149 }
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
150 *ft = FeatureType(sft)
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
151 ft.Namespaces = ns
e80e35b26f17 WFS Capabilities parser: Wrote a custom xml.Unmarshaler to extract the namespaces of FeatureTypes, too. They are needed in GetFeature requests.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1600
diff changeset
152 return nil
1600
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
153 }
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
154
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
155 type FeatureTypeList struct {
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
156 XMLName xml.Name `xml:"http://www.opengis.net/wfs/2.0 FeatureTypeList"`
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
157 FeatureTypes []*FeatureType `xml:"FeatureType"`
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
158 }
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
159
1596
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
160 type Capabilities struct {
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
161 XMLName xml.Name `xml:"http://www.opengis.net/wfs/2.0 WFS_Capabilities"`
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
162
1608
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
163 BaseURL string `xml:"-"`
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
164
1596
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
165 ServiceIdentification ServiceIdentification
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
166 OperationsMetadata OperationsMetadata
1600
658c1ebc1707 WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1599
diff changeset
167 FeatureTypeList FeatureTypeList
1596
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
168 }
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
169
1608
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
170 func (c *Capabilities) FindOperation(name string) *Operation {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
171 for _, op := range c.OperationsMetadata.Operations {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
172 if op.Name == name {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
173 return op
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
174 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
175 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
176 return nil
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
177 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
178
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
179 func (o *Operation) SupportsHits() bool {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
180 for _, p := range o.Parameters {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
181 if p.Name == "resultType" {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
182 for _, av := range p.AllowedValues.Values {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
183 if av.Value == "hits" {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
184 return true
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
185 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
186 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
187 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
188 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
189 return false
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
190 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
191
1614
efc409e330a6 WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1608
diff changeset
192 func (o *Operation) SupportsOutputFormat(formats ...string) bool {
efc409e330a6 WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1608
diff changeset
193 for _, p := range o.Parameters {
efc409e330a6 WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1608
diff changeset
194 if p.Name == "outputFormat" {
efc409e330a6 WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1608
diff changeset
195 for _, av := range p.AllowedValues.Values {
efc409e330a6 WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1608
diff changeset
196 for _, f := range formats {
efc409e330a6 WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1608
diff changeset
197 if av.Value == f {
efc409e330a6 WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1608
diff changeset
198 return true
efc409e330a6 WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1608
diff changeset
199 }
efc409e330a6 WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1608
diff changeset
200 }
efc409e330a6 WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1608
diff changeset
201 }
efc409e330a6 WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1608
diff changeset
202 }
efc409e330a6 WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1608
diff changeset
203 }
efc409e330a6 WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1608
diff changeset
204 return false
efc409e330a6 WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1608
diff changeset
205 }
efc409e330a6 WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1608
diff changeset
206
1608
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
207 func (o *Operation) FeaturesPerPage() (int, bool) {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
208 for _, c := range o.Constraints {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
209 if c.Name == "CountDefault" {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
210 if c.DefaultValue != nil {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
211 if v, err := strconv.Atoi(c.DefaultValue.Value); err == nil {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
212 return v, true
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
213 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
214 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
215 for _, av := range c.AllowedValues.Values {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
216 if v, err := strconv.Atoi(av.Value); err == nil {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
217 return v, true
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
218 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
219
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
220 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
221 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
222 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
223 return 0, false
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
224 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
225
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
226 func (c *Capabilities) FindFeatureType(name string) *FeatureType {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
227 for _, ft := range c.FeatureTypeList.FeatureTypes {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
228 if ft.Name == name {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
229 return ft
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
230 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
231 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
232 return nil
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
233 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
234
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
235 func (op *Operation) FindParameter(name string) *Parameter {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
236 for _, p := range op.Parameters {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
237 if p.Name == name {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
238 return p
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
239 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
240 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
241 return nil
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
242 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
243
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
244 const WFS2_0_0 = "2.0.0"
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
245
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
246 var versionRe = regexp.MustCompile(`(\d+)\.(\d+)\.(\d+)`)
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
247
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
248 func versionIsLess(a, b string) bool {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
249 am := versionRe.FindStringSubmatch(a)
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
250 bm := versionRe.FindStringSubmatch(b)
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
251
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
252 var n int
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
253 if len(am) < len(bm) {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
254 n = len(am)
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
255 } else {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
256 n = len(bm)
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
257 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
258 n--
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
259
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
260 for i := 0; i < n; i++ {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
261 ai, _ := strconv.Atoi(am[i+1])
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
262 bi, _ := strconv.Atoi(bm[i+1])
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
263 switch {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
264 case ai < bi:
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
265 return true
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
266 case ai > bi:
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
267 return false
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
268 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
269 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
270 return false
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
271 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
272
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
273 func maxVersion(a, b string) string {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
274 am := versionRe.FindStringSubmatch(a)
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
275 bm := versionRe.FindStringSubmatch(b)
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
276
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
277 var n int
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
278 if len(am) < len(bm) {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
279 n = len(am)
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
280 } else {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
281 n = len(bm)
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
282 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
283 n--
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
284
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
285 for i := 0; i < n; i++ {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
286 ai, _ := strconv.Atoi(am[i+1])
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
287 bi, _ := strconv.Atoi(bm[i+1])
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
288 switch {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
289 case ai > bi:
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
290 return a
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
291 case bi > ai:
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
292 return b
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
293 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
294 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
295 return a
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
296 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
297
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
298 func (c *Capabilities) HighestWFSVersion(def string) string {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
299 op := c.FindOperation("GetCapabilities")
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
300 if op == nil {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
301 return def
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
302 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
303 p := op.FindParameter("AcceptVersions")
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
304 if p == nil {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
305 return def
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
306 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
307 if len(p.AllowedValues.Values) == 0 {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
308 return def
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
309 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
310
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
311 max := p.AllowedValues.Values[0].Value
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
312 for _, v := range p.AllowedValues.Values[1:] {
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
313 max = maxVersion(max, v.Value)
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
314 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
315
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
316 return max
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
317 }
427f9010b4a9 WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1602
diff changeset
318
1679
2dc7768be0e4 Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1614
diff changeset
319 var (
2dc7768be0e4 Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1614
diff changeset
320 ErrInvalidCRS = errors.New("Invalid CRS string")
2dc7768be0e4 Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1614
diff changeset
321 crsRe = regexp.MustCompile(`urn:ogc:def:crs:EPSG:[^:]*:(\d+)`)
2dc7768be0e4 Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1614
diff changeset
322 )
2dc7768be0e4 Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1614
diff changeset
323
2dc7768be0e4 Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1614
diff changeset
324 func CRSToEPSG(s string) (int, error) {
2dc7768be0e4 Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1614
diff changeset
325 m := crsRe.FindStringSubmatch(s)
2dc7768be0e4 Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1614
diff changeset
326 if m == nil {
2dc7768be0e4 Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1614
diff changeset
327 return 0, ErrInvalidCRS
2dc7768be0e4 Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1614
diff changeset
328 }
2dc7768be0e4 Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1614
diff changeset
329 return strconv.Atoi(m[1])
2dc7768be0e4 Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1614
diff changeset
330 }
2dc7768be0e4 Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1614
diff changeset
331
1596
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
332 func ParseCapabilities(r io.Reader) (*Capabilities, error) {
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
333
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
334 decoder := xml.NewDecoder(r)
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
335 decoder.CharsetReader = charset.NewReaderLabel
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
336
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
337 var capabilities Capabilities
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
338
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
339 if err := decoder.Decode(&capabilities); err != nil {
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
340 return nil, err
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
341 }
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
342
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
343 return &capabilities, nil
74413d52c439 Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
344 }