Mercurial > gemma
annotate pkg/wfs/capabilities.go @ 5591:0011f50cf216 surveysperbottleneckid
Removed no longer used alternative api for surveys/ endpoint.
As bottlenecks in the summary for SR imports are now identified by
their id and no longer by the (not guarantied to be unique!) name,
there is no longer the need to request survey data by the name+date
tuple (which isn't reliable anyway). So the workaround was now
reversed.
author | Sascha Wilde <wilde@sha-bang.de> |
---|---|
date | Wed, 06 Apr 2022 13:30:29 +0200 |
parents | 04876d865528 |
children |
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" |
2622
02505fcff63c
WFS downloads: Accept 'geojson' as mime type, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1689
diff
changeset
|
22 "strings" |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 "golang.org/x/net/html/charset" |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 ) |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
27 // Keyword stores a value. |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
28 type Keyword struct { |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
29 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
|
30 Value string `xml:",cdata"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
31 } |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
32 |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
33 // 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
|
34 type Keywords struct { |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
35 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
|
36 Keywords []Keyword `xml:"Keyword"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
37 } |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
38 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
39 // ServiceIdentification contains meta informations about a WFS. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 type ServiceIdentification struct { |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
41 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
|
42 Title string |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
43 Abstract string |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
44 Keywords Keywords `xml:"Keywords"` |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 ServiceType string |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 ServiceTypeVersion string |
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 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
49 // 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
|
50 type Get struct { |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 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
|
52 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
|
53 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
55 // 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
|
56 type Post struct { |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 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
|
58 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
|
59 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
61 // HTTP is a container for HTTP methods. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 type HTTP struct { |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 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
|
64 Get *Get `xml:"Get"` |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 Post *Post `xml:"Post"` |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
68 // DCP wraps the HTTP container. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 type DCP struct { |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 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
|
71 HTTP HTTP `xml:"HTTP"` |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
74 // 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
|
75 type Value struct { |
1596
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 Value"` |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 Value string `xml:",cdata"` |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
80 // AllowedValues is list positive list of values. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 type AllowedValues struct { |
1599
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 AllowedValues"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
83 Values []Value `xml:"Value"` |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
86 // 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
|
87 type Parameter struct { |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 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
|
89 Name string `xml:"name,attr"` |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 AllowedValues AllowedValues `xml:"AllowedValues"` |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
93 // 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
|
94 type DefaultValue struct { |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
95 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
|
96 Value string `xml:",cdata"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
97 } |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
98 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
99 // 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
|
100 // and a default value. |
1599
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
101 type Constraint struct { |
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 Constraint"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
103 Name string `xml:"name,attr"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
104 AllowedValues AllowedValues `xml:"AllowedValues"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
105 DefaultValue *DefaultValue `xml:"DefaultValue"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
106 } |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
107 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
108 // Operation contains informations of a WFS operation. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 type Operation struct { |
1599
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
110 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
|
111 Name string `xml:"name,attr"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
112 DCP DCP `xml:"DCP"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
113 Parameters []*Parameter `xml:"Parameter"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
114 Constraints []*Constraint `xml:"Constraint"` |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
117 // OperationsMetadata is list of operations and constraints. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
118 type OperationsMetadata struct { |
1599
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
119 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
|
120 Operations []*Operation `xml:"Operation"` |
5e16d1fbe91f
WFS Capabilities parser: Parse constraints, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1596
diff
changeset
|
121 Constraints []*Constraint `xml:"Constraint"` |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
124 // 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
|
125 type WGS84BoundingBox struct { |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
126 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
|
127 LowerCorner string `xml:"LowerCorner"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
128 UpperCorner string `xml:"UpperCorner"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
129 } |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
130 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
131 // 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
|
132 type FeatureType struct { |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
133 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
|
134 Name string `xml:"Name"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
135 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
|
136 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
|
137 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
|
138 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
|
139 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
|
140 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
|
141 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
|
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 |
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 // 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
|
145 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
|
146 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
|
147 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
|
148 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
|
149 Abstract string `xml:"Abstract"` |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
150 Keywords Keywords `xml:"Keywords"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
151 DefaultCRS string `xml:"DefaultCRS"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
152 OtherCRSs []string `xml:"OtherCRS"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
153 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
|
154 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
|
155 } |
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
|
156 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
157 // 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
|
158 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
|
159 // 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
|
160 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
|
161 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
|
162 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
|
163 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
|
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 } |
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 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
|
167 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
|
168 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
|
169 } |
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 = 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
|
171 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
|
172 return nil |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
173 } |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
174 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
175 // 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
|
176 type FeatureTypeList struct { |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
177 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
|
178 FeatureTypes []*FeatureType `xml:"FeatureType"` |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
179 } |
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
180 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
181 // Capabilities is the top level metadata struct. |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
182 type Capabilities struct { |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
183 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
|
184 |
1608
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
185 BaseURL string `xml:"-"` |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
186 |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
187 ServiceIdentification ServiceIdentification |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
188 OperationsMetadata OperationsMetadata |
1600
658c1ebc1707
WFS Capabilities parser: Parse FeatureTypeList, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1599
diff
changeset
|
189 FeatureTypeList FeatureTypeList |
1596
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
190 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
191 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
192 // FindOperation searches the capabilities for a specifc operation. |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
193 // 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
|
194 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
|
195 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
|
196 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
|
197 return op |
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 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
200 return nil |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
201 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
202 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
203 // 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
|
204 func (op *Operation) SupportsHits() bool { |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
205 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
|
206 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
|
207 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
|
208 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
|
209 return true |
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 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
214 return false |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
215 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
216 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
217 // SupportsOutputFormat checks if one of the given formats is supported. |
2622
02505fcff63c
WFS downloads: Accept 'geojson' as mime type, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1689
diff
changeset
|
218 func (op *Operation) SupportsOutputFormat(formats ...string) string { |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
219 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
|
220 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
|
221 for _, av := range p.AllowedValues.Values { |
2622
02505fcff63c
WFS downloads: Accept 'geojson' as mime type, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1689
diff
changeset
|
222 v := strings.ToLower(av.Value) |
1614
efc409e330a6
WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1608
diff
changeset
|
223 for _, f := range formats { |
2622
02505fcff63c
WFS downloads: Accept 'geojson' as mime type, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1689
diff
changeset
|
224 if v == strings.ToLower(f) { |
02505fcff63c
WFS downloads: Accept 'geojson' as mime type, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1689
diff
changeset
|
225 return av.Value |
1614
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 } |
efc409e330a6
WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1608
diff
changeset
|
230 } |
2622
02505fcff63c
WFS downloads: Accept 'geojson' as mime type, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1689
diff
changeset
|
231 return "" |
1614
efc409e330a6
WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1608
diff
changeset
|
232 } |
efc409e330a6
WFS downloader: Propagate namespaces of feature type into GetFeature request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1608
diff
changeset
|
233 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
234 // FeaturesPerPage returns the number of features per page. |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
235 // 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
|
236 func (op *Operation) FeaturesPerPage() (int, bool) { |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
237 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
|
238 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
|
239 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
|
240 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
|
241 return v, true |
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 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
|
245 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
|
246 return v, true |
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 } |
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 return 0, false |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
253 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
254 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
255 // FindFeatureType searches the layers for a given name. |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
256 // 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
|
257 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
|
258 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
|
259 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
|
260 return ft |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
261 } |
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 return nil |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
264 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
265 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
266 // FindParameter searches for named parameter. Returns nil |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
267 // 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
|
268 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
|
269 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
|
270 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
|
271 return p |
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 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
274 return nil |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
275 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
276 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
277 // 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
|
278 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
|
279 |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
280 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
|
281 |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
282 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
|
283 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
|
284 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
|
285 |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
286 var n int |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
287 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
|
288 n = len(am) |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
289 } else { |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
290 n = len(bm) |
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 n-- |
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 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
|
295 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
|
296 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
|
297 switch { |
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 true |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
300 case ai > bi: |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
301 return false |
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 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
304 return false |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
305 } |
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 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
|
308 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
|
309 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
|
310 |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
311 var n int |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
312 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
|
313 n = len(am) |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
314 } else { |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
315 n = len(bm) |
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 n-- |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
318 |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
319 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
|
320 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
|
321 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
|
322 switch { |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
323 case ai > bi: |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
324 return a |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
325 case bi > ai: |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
326 return b |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
327 } |
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 return a |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
330 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
331 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
332 // HighestWFSVersion figures out the highest supported WFS version. |
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
333 // 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
|
334 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
|
335 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
|
336 if op == nil { |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
337 return def |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
338 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
339 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
|
340 if p == nil { |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
341 return def |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
342 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
343 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
|
344 return def |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
345 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
346 |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
347 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
|
348 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
|
349 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
|
350 } |
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 return max |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
353 } |
427f9010b4a9
WFS download: Started with GET downloader (paged and unpaged).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1602
diff
changeset
|
354 |
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 var ( |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
356 // ErrInvalidCRS is returned if a given string is not valid CRS URN. |
4166
04876d865528
Made 'golint' and 'staticcheck' happy with wfs package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2622
diff
changeset
|
357 ErrInvalidCRS = errors.New("invalid CRS 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
|
358 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
|
359 ) |
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 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
361 // 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
|
362 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
|
363 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
|
364 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
|
365 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
|
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 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
|
368 } |
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
|
369 |
1689
6caf5cd6249e
WFS: Made golint happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1679
diff
changeset
|
370 // 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
|
371 func ParseCapabilities(r io.Reader) (*Capabilities, error) { |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
372 |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
373 decoder := xml.NewDecoder(r) |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
374 decoder.CharsetReader = charset.NewReaderLabel |
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 var capabilities Capabilities |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
377 |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
378 if err := decoder.Decode(&capabilities); err != nil { |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
379 return nil, err |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
380 } |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
381 |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
382 return &capabilities, nil |
74413d52c439
Started with WFS Capabilities parser.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
383 } |