Mercurial > gemma
comparison pkg/wfs/download.go @ 2622:02505fcff63c
WFS downloads: Accept 'geojson' as mime type, too.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 13 Mar 2019 15:39:12 +0100 |
parents | a8ebc785823d |
children | d7ef169fd0d3 |
comparison
equal
deleted
inserted
replaced
2621:78f75e99f9c5 | 2622:02505fcff63c |
---|---|
41 // ErrOutputFormatNotSupported is returned if a output format is | 41 // ErrOutputFormatNotSupported is returned if a output format is |
42 // not supported. | 42 // not supported. |
43 ErrOutputFormatNotSupported = errors.New("Output format not supported") | 43 ErrOutputFormatNotSupported = errors.New("Output format not supported") |
44 ) | 44 ) |
45 | 45 |
46 var FormatGeoJSON = []string{"geojson", "application/json"} | |
47 | |
46 // GetCapabilities downloads a capabilities document for a given URL. | 48 // GetCapabilities downloads a capabilities document for a given URL. |
47 func GetCapabilities(capURL string) (*Capabilities, error) { | 49 func GetCapabilities(capURL string) (*Capabilities, error) { |
48 | 50 |
49 base, err := url.Parse(capURL) | 51 base, err := url.Parse(capURL) |
50 if err != nil { | 52 if err != nil { |
106 | 108 |
107 // GetFeaturesGET constructs a list of URLs to get features | 109 // GetFeaturesGET constructs a list of URLs to get features |
108 // for a given feature type from a WFS servers. | 110 // for a given feature type from a WFS servers. |
109 func GetFeaturesGET( | 111 func GetFeaturesGET( |
110 caps *Capabilities, | 112 caps *Capabilities, |
111 featureTypeName, | 113 featureTypeName string, |
112 outputFormat string, | 114 outputFormats []string, |
113 sortBy string, | 115 sortBy string, |
114 ) ([]string, error) { | 116 ) ([]string, error) { |
115 | 117 |
116 feature := caps.FindFeatureType(featureTypeName) | 118 feature := caps.FindFeatureType(featureTypeName) |
117 if feature == nil { | 119 if feature == nil { |
138 return nil, err | 140 return nil, err |
139 } | 141 } |
140 getU = getU.ResolveReference(base) | 142 getU = getU.ResolveReference(base) |
141 } | 143 } |
142 | 144 |
143 if !op.SupportsOutputFormat(outputFormat) { | 145 var outputFormat string |
144 return nil, ErrOutputFormatNotSupported | 146 |
147 if len(outputFormats) > 0 { | |
148 if outputFormat = op.SupportsOutputFormat(outputFormats...); outputFormat == "" { | |
149 return nil, ErrOutputFormatNotSupported | |
150 } | |
145 } | 151 } |
146 | 152 |
147 wfsVersion := caps.HighestWFSVersion(WFS200) | 153 wfsVersion := caps.HighestWFSVersion(WFS200) |
148 | 154 |
149 featuresPerPage, supportsPaging := op.FeaturesPerPage() | 155 featuresPerPage, supportsPaging := op.FeaturesPerPage() |