Mercurial > gemma
annotate pkg/wfs/capabilities.go @ 1800:f5c33972497e
corrected typo
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 15 Jan 2019 09:17:03 +0100 |
parents | 6caf5cd6249e |
children | 02505fcff63c |
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 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
26 // Keyword stores a value. |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
27 type Keyword struct { |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
28 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
|
29 Value string `xml:",cdata"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
30 } |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
31 |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
32 // Keywords stores a list of keywords. |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
33 type Keywords struct { |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
34 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
|
35 Keywords []Keyword `xml:"Keyword"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
36 } |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
37 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
38 // ServiceIdentification contains meta informations about a WFS. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 type ServiceIdentification struct { |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
40 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
|
41 Title string |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
42 Abstract string |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
43 Keywords Keywords `xml:"Keywords"` |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 ServiceType string |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 ServiceTypeVersion string |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
48 // Get stores the link to the GET method |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 type Get 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 Get"` |
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 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
54 // Post stores the link to the POST method. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 type Post struct { |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 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
|
57 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
|
58 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
60 // HTTP is a container for HTTP methods. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 type HTTP struct { |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 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
|
63 Get *Get `xml:"Get"` |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 Post *Post `xml:"Post"` |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
67 // DCP wraps the HTTP container. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 type DCP struct { |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 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
|
70 HTTP HTTP `xml:"HTTP"` |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
73 // Value is a simple string value. |
1599
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
74 type Value struct { |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 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
|
76 Value string `xml:",cdata"` |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
79 // AllowedValues is list positive list of values. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 type AllowedValues struct { |
1599
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
81 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
|
82 Values []Value `xml:"Value"` |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
85 // Parameter is a named parameter with a list of allowed values. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 type Parameter struct { |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 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
|
88 Name string `xml:"name,attr"` |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 AllowedValues AllowedValues `xml:"AllowedValues"` |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
92 // DefaultValue is the default value of a constraint. |
1599
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
93 type DefaultValue struct { |
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 DefaultValue"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
95 Value string `xml:",cdata"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
96 } |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
97 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
98 // Constraint is a named constraint with a list of allowed values |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
99 // and a default value. |
1599
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
100 type Constraint struct { |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
101 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
|
102 Name string `xml:"name,attr"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
103 AllowedValues AllowedValues `xml:"AllowedValues"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
104 DefaultValue *DefaultValue `xml:"DefaultValue"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
105 } |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
106 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
107 // Operation contains informations of a WFS operation. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 type Operation struct { |
1599
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
109 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
|
110 Name string `xml:"name,attr"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
111 DCP DCP `xml:"DCP"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
112 Parameters []*Parameter `xml:"Parameter"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
113 Constraints []*Constraint `xml:"Constraint"` |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
116 // OperationsMetadata is list of operations and constraints. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 type OperationsMetadata struct { |
1599
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
118 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
|
119 Operations []*Operation `xml:"Operation"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
120 Constraints []*Constraint `xml:"Constraint"` |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
123 // WGS84BoundingBox is a bounding box feature type in WGS84. |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
124 type WGS84BoundingBox struct { |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
125 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
|
126 LowerCorner string `xml:"LowerCorner"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
127 UpperCorner string `xml:"UpperCorner"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
128 } |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
129 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
130 // FeatureType is layer served by the WFS: |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
131 type FeatureType struct { |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
132 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
|
133 Name string `xml:"Name"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
134 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
|
135 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
|
136 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
|
137 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
|
138 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
|
139 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
|
140 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
|
141 } |
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 |
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 // 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
|
144 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
|
145 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
|
146 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
|
147 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
|
148 Abstract string `xml:"Abstract"` |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
149 Keywords Keywords `xml:"Keywords"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
150 DefaultCRS string `xml:"DefaultCRS"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
151 OtherCRSs []string `xml:"OtherCRS"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
152 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
|
153 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
|
154 } |
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
|
155 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
156 // UnmarshalXML implements xml.Unmarshaler for better namespace handling. |
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
|
157 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
|
158 // 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
|
159 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
|
160 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
|
161 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
|
162 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
|
163 } |
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
|
164 } |
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
|
165 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
|
166 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
|
167 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
|
168 } |
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
|
169 *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
|
170 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
|
171 return nil |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
172 } |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
173 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
174 // FeatureTypeList is the list of layers served by the WFS. |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
175 type FeatureTypeList struct { |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
176 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
|
177 FeatureTypes []*FeatureType `xml:"FeatureType"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
178 } |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
179 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
180 // Capabilities is the top level metadata struct. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
181 type Capabilities struct { |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
182 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
|
183 |
1608
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
184 BaseURL string `xml:"-"` |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
185 |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
186 ServiceIdentification ServiceIdentification |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
187 OperationsMetadata OperationsMetadata |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
188 FeatureTypeList FeatureTypeList |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
189 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
190 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
191 // FindOperation searches the capabilities for a specifc operation. |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
192 // Returns nil if not found. |
1608
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
193 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
|
194 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
|
195 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
|
196 return op |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
197 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
198 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
199 return nil |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
200 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
201 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
202 // SupportsHits checks if a operation supports the hits request. |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
203 func (op *Operation) SupportsHits() bool { |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
204 for _, p := range op.Parameters { |
1608
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
205 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
|
206 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
|
207 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
|
208 return true |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
209 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
210 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
211 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
212 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
213 return false |
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 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
216 // SupportsOutputFormat checks if one of the given formats is supported. |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
217 func (op *Operation) SupportsOutputFormat(formats ...string) bool { |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
218 for _, p := range op.Parameters { |
1614
efc409e330a6
WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1608
diff
changeset
|
219 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
|
220 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
|
221 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
|
222 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
|
223 return true |
efc409e330a6
WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1608
diff
changeset
|
224 } |
efc409e330a6
WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1608
diff
changeset
|
225 } |
efc409e330a6
WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1608
diff
changeset
|
226 } |
efc409e330a6
WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1608
diff
changeset
|
227 } |
efc409e330a6
WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1608
diff
changeset
|
228 } |
efc409e330a6
WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1608
diff
changeset
|
229 return false |
efc409e330a6
WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1608
diff
changeset
|
230 } |
efc409e330a6
WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1608
diff
changeset
|
231 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
232 // FeaturesPerPage returns the number of features per page. |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
233 // Returns if paging is not supported by the operation. |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
234 func (op *Operation) FeaturesPerPage() (int, bool) { |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
235 for _, c := range op.Constraints { |
1608
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
236 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
|
237 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
|
238 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
|
239 return v, true |
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 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
242 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
|
243 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
|
244 return v, true |
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 |
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 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
249 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
250 return 0, false |
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 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
253 // FindFeatureType searches the layers for a given name. |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
254 // Returns nil if not found. |
1608
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
255 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
|
256 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
|
257 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
|
258 return ft |
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 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
261 return nil |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
262 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
263 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
264 // FindParameter searches for named parameter. Returns nil |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
265 // if not found. |
1608
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
266 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
|
267 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
|
268 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
|
269 return p |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
270 } |
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 return nil |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
273 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
274 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
275 // WFS200 is dotted version string of version 2.0.0. |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
276 const WFS200 = "2.0.0" |
1608
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
277 |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
278 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
|
279 |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
280 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
|
281 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
|
282 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
|
283 |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
284 var n int |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
285 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
|
286 n = len(am) |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
287 } else { |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
288 n = len(bm) |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
289 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
290 n-- |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
291 |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
292 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
|
293 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
|
294 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
|
295 switch { |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
296 case ai < bi: |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
297 return true |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
298 case ai > bi: |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
299 return false |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
300 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
301 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
302 return false |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
303 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
304 |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
305 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
|
306 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
|
307 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
|
308 |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
309 var n int |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
310 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
|
311 n = len(am) |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
312 } else { |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
313 n = len(bm) |
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 n-- |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
316 |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
317 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
|
318 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
|
319 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
|
320 switch { |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
321 case ai > bi: |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
322 return a |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
323 case bi > ai: |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
324 return b |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
325 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
326 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
327 return a |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
328 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
329 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
330 // HighestWFSVersion figures out the highest supported WFS version. |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
331 // Defaults to def. |
1608
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
332 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
|
333 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
|
334 if op == nil { |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
335 return def |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
336 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
337 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
|
338 if p == nil { |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
339 return def |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
340 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
341 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
|
342 return def |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
343 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
344 |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
345 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
|
346 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
|
347 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
|
348 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
349 |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
350 return max |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
351 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
352 |
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
|
353 var ( |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
354 // ErrInvalidCRS is returned if a given string is not valid CRS URN. |
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
|
355 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
|
356 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
|
357 ) |
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
|
358 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
359 // CRSToEPSG extracts the EPSG code from a given CRS URN string. |
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
|
360 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
|
361 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
|
362 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
|
363 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
|
364 } |
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
|
365 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
|
366 } |
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
|
367 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
368 // ParseCapabilities constructs a capabilities document from an io.Reader. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
369 func ParseCapabilities(r io.Reader) (*Capabilities, error) { |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
370 |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
371 decoder := xml.NewDecoder(r) |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
372 decoder.CharsetReader = charset.NewReaderLabel |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
373 |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
374 var capabilities Capabilities |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
375 |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
376 if err := decoder.Decode(&capabilities); err != nil { |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
377 return nil, err |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
378 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
379 |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
380 return &capabilities, nil |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
381 } |