Skip to content

Commit 54c1287

Browse files
authored
Merge branch 'geopython:master' into remove-pytz
2 parents 6faa53f + 852fe6d commit 54c1287

File tree

3 files changed

+64
-59
lines changed

3 files changed

+64
-59
lines changed

owslib/feature/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def getGETGetFeatureRequest(
160160
featureversion=None,
161161
propertyname=None,
162162
maxfeatures=None,
163+
srsname=None,
163164
storedQueryID=None,
164165
storedQueryParams=None,
165166
outputFormat=None,
@@ -183,6 +184,8 @@ def getGETGetFeatureRequest(
183184
List of feature property names. '*' matches all.
184185
maxfeatures : int
185186
Maximum number of features to be returned.
187+
srsname: string
188+
EPSG code to request the data in
186189
method : string
187190
Qualified name of the HTTP DCP method to use.
188191
outputFormat: string (optional)
@@ -238,6 +241,13 @@ def getGETGetFeatureRequest(
238241
request["count"] = str(maxfeatures)
239242
else:
240243
request["maxfeatures"] = str(maxfeatures)
244+
if srsname:
245+
request["srsname"] = str(srsname)
246+
247+
# Check if desired SRS is supported by the service for each
248+
# typename. Warning will be thrown if that SRS is not allowed.
249+
for name in typename:
250+
_ = self.getSRS(srsname, name)
241251
if startindex:
242252
request["startindex"] = str(startindex)
243253
if storedQueryID:

owslib/feature/wfs200.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ def getfeature(
226226
featureversion=None,
227227
propertyname=None,
228228
maxfeatures=None,
229+
srsname=None,
229230
storedQueryID=None,
230231
storedQueryParams=None,
231232
method="Get",
@@ -254,6 +255,8 @@ def getfeature(
254255
For Post request, leave blank (None) to get all properties.
255256
maxfeatures : int
256257
Maximum number of features to be returned.
258+
srsname: string
259+
EPSG code to request the data in
257260
storedQueryID : string
258261
A name identifying a prepared set available in WFS-service
259262
storedQueryParams : dict
@@ -298,6 +301,7 @@ def getfeature(
298301
featureversion,
299302
propertyname,
300303
maxfeatures,
304+
srsname,
301305
storedQueryID,
302306
storedQueryParams,
303307
outputFormat,

tests/test_wfs_generic.py

Lines changed: 50 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import json
77
import pytest
88

9-
SERVICE_URL = 'https://www.sciencebase.gov/catalogMaps/mapping/ows/53398e51e4b0db25ad10d288'
10-
9+
SERVICE_URL = 'https://services.ga.gov.au/gis/stratunits/ows'
1110

1211
def test_caps_info():
1312
getcapsin = open(resource_file("wfs_HSRS_GetCapabilities_1_1_0.xml"), "rb").read()
@@ -59,59 +58,50 @@ def test_verbOptions_wfs_100():
5958
assert len(verbOptions[0]) == 2
6059

6160

62-
@pytest.mark.xfail
6361
@pytest.mark.online
6462
@pytest.mark.skipif(not service_ok(SERVICE_URL),
6563
reason="WFS service is unreachable")
6664
def test_outputformat_wfs_100():
67-
wfs = WebFeatureService('https://www.sciencebase.gov/catalogMaps/mapping/ows/53398e51e4b0db25ad10d288',
68-
version='1.0.0')
65+
wfs = WebFeatureService(SERVICE_URL, version='1.0.0')
6966
feature = wfs.getfeature(
70-
typename=['sb:Project_Area'], maxfeatures=1, propertyname=None, outputFormat='application/json')
67+
typename=['stratunit:StratigraphicUnit'], maxfeatures=1, propertyname=None, outputFormat='application/json')
7168
assert len(json.loads(feature.read())['features']) == 1
7269

7370

74-
@pytest.mark.xfail
7571
@pytest.mark.online
7672
@pytest.mark.skipif(not service_ok(SERVICE_URL),
7773
reason="WFS service is unreachable")
7874
def test_outputformat_wfs_110():
79-
wfs = WebFeatureService('https://www.sciencebase.gov/catalogMaps/mapping/ows/53398e51e4b0db25ad10d288',
80-
version='1.1.0')
75+
wfs = WebFeatureService(SERVICE_URL, version='1.1.0')
8176
feature = wfs.getfeature(
82-
typename=['sb:Project_Area'], maxfeatures=1, propertyname=None, outputFormat='application/json')
77+
typename=['stratunit:StratigraphicUnit'], maxfeatures=1, propertyname=None, outputFormat='application/json')
8378
assert len(json.loads(feature.read())['features']) == 1
8479

8580

86-
@pytest.mark.xfail
8781
@pytest.mark.online
8882
@pytest.mark.skipif(not service_ok(SERVICE_URL),
8983
reason="WFS service is unreachable")
9084
def test_outputformat_wfs_200():
91-
wfs = WebFeatureService('https://www.sciencebase.gov/catalogMaps/mapping/ows/53398e51e4b0db25ad10d288',
92-
version='2.0.0')
85+
wfs = WebFeatureService(SERVICE_URL, version='2.0.0')
9386
feature = wfs.getfeature(
94-
typename=['sb:Project_Area'], maxfeatures=1, propertyname=None, outputFormat='application/json')
87+
typename=['stratunit:StratigraphicUnit'], maxfeatures=1, propertyname=None, outputFormat='application/json')
9588
assert len(json.loads(feature.read())['features']) == 1
9689

9790

98-
@pytest.mark.xfail
9991
@pytest.mark.online
10092
@pytest.mark.skipif(not service_ok(SERVICE_URL),
10193
reason="WFS service is unreachable")
10294
def test_srsname_wfs_100():
103-
wfs = WebFeatureService('https://www.sciencebase.gov/catalogMaps/mapping/ows/53398e51e4b0db25ad10d288',
104-
version='1.0.0')
95+
wfs = WebFeatureService(SERVICE_URL, version='1.0.0')
10596
# ServiceException: Unable to support srsName: EPSG:99999999
10697
with pytest.raises(ServiceException):
10798
feature = wfs.getfeature(
108-
typename=['sb:Project_Area'], maxfeatures=1, propertyname=None, outputFormat='application/json',
99+
typename=['stratunit:StratigraphicUnit'], maxfeatures=1, propertyname=None, outputFormat='application/json',
109100
srsname="EPSG:99999999")
110101

111-
wfs = WebFeatureService('https://www.sciencebase.gov/catalogMaps/mapping/ows/53398e51e4b0db25ad10d288',
112-
version='1.0.0')
102+
wfs = WebFeatureService(SERVICE_URL, version='1.0.0')
113103
feature = wfs.getfeature(
114-
typename=['sb:Project_Area'], maxfeatures=1, propertyname=None, outputFormat='application/json',
104+
typename=['stratunit:StratigraphicUnit'], maxfeatures=1, propertyname=None, outputFormat='application/json',
115105
srsname="urn:x-ogc:def:crs:EPSG:4326")
116106
assert len(json.loads(feature.read())['features']) == 1
117107

@@ -121,73 +111,76 @@ def test_srsname_wfs_100():
121111
@pytest.mark.skipif(not service_ok(SERVICE_URL),
122112
reason="WFS service is unreachable")
123113
def test_srsname_wfs_110():
124-
wfs = WebFeatureService(
125-
'https://www.sciencebase.gov/catalogMaps/mapping/ows/53398e51e4b0db25ad10d288',
126-
version='1.1.0')
114+
wfs = WebFeatureService(SERVICE_URL, version='1.1.0')
127115
# ServiceException: Unable to support srsName: EPSG:99999999
128116
with pytest.raises(ServiceException):
129117
feature = wfs.getfeature(
130-
typename=['sb:Project_Area'], maxfeatures=1, propertyname=None, outputFormat='application/json',
118+
typename=['stratunit:StratigraphicUnit'], maxfeatures=1, propertyname=None, outputFormat='application/json',
131119
srsname="EPSG:99999999")
132120

133-
wfs = WebFeatureService(
134-
'https://www.sciencebase.gov/catalogMaps/mapping/ows/53398e51e4b0db25ad10d288',
135-
version='1.0.0')
121+
wfs = WebFeatureService(SERVICE_URL, version='1.1.0')
136122
feature = wfs.getfeature(
137-
typename=['sb:Project_Area'], maxfeatures=1, propertyname=None, outputFormat='application/json',
123+
typename=['stratunit:StratigraphicUnit'], maxfeatures=1, propertyname=None, outputFormat='application/json',
124+
srsname="urn:x-ogc:def:crs:EPSG:4326")
125+
assert len(json.loads(feature.read())['features']) == 1
126+
127+
128+
@pytest.mark.online
129+
@pytest.mark.skipif(not service_ok(SERVICE_URL),
130+
reason="WFS service is unreachable")
131+
def test_srsname_wfs_200():
132+
wfs = WebFeatureService(SERVICE_URL, version='2.0.0')
133+
# ServiceException: Unable to support srsName: EPSG:99999999
134+
with pytest.raises(ServiceException):
135+
feature = wfs.getfeature(
136+
typename=['stratunit:StratigraphicUnit'], maxfeatures=1, propertyname=None, outputFormat='application/json',
137+
srsname="EPSG:99999999")
138+
139+
wfs = WebFeatureService(SERVICE_URL, version='2.0.0')
140+
feature = wfs.getfeature(
141+
typename=['stratunit:StratigraphicUnit'], maxfeatures=1, propertyname=None, outputFormat='application/json',
138142
srsname="urn:x-ogc:def:crs:EPSG:4326")
139143
assert len(json.loads(feature.read())['features']) == 1
140144

141145

142-
@pytest.mark.xfail
143146
@pytest.mark.online
144147
@pytest.mark.skipif(not service_ok(SERVICE_URL),
145148
reason="WFS service is unreachable")
146149
def test_schema_wfs_100():
147-
wfs = WebFeatureService(
148-
'https://www.sciencebase.gov/catalogMaps/mapping/ows/53398e51e4b0db25ad10d288',
149-
version='1.0.0')
150-
schema = wfs.get_schema('footprint')
151-
assert len(schema['properties']) == 4
152-
assert schema['properties']['summary'] == 'string'
153-
assert schema['geometry'] == 'Polygon'
150+
wfs = WebFeatureService(SERVICE_URL, version='1.0.0')
151+
schema = wfs.get_schema('stratunit:StratigraphicUnit')
152+
assert len(schema['properties']) == 33
153+
assert schema['properties']['DESCRIPTION'] == 'string'
154+
assert schema['geometry'] is None
154155

155156

156-
@pytest.mark.xfail
157157
@pytest.mark.online
158158
@pytest.mark.skipif(not service_ok(SERVICE_URL),
159159
reason="WFS service is unreachable")
160160
def test_schema_wfs_110():
161-
wfs = WebFeatureService(
162-
'https://www.sciencebase.gov/catalogMaps/mapping/ows/53398e51e4b0db25ad10d288',
163-
version='1.1.0')
164-
schema = wfs.get_schema('footprint')
165-
assert len(schema['properties']) == 4
166-
assert schema['properties']['summary'] == 'string'
167-
assert schema['geometry'] == '3D Polygon'
161+
wfs = WebFeatureService(SERVICE_URL, version='1.1.0')
162+
schema = wfs.get_schema('stratunit:StratigraphicUnit')
163+
assert len(schema['properties']) == 33
164+
assert schema['properties']['DESCRIPTION'] == 'string'
165+
assert schema['geometry'] is None
168166

169167

170-
@pytest.mark.xfail
171168
@pytest.mark.online
172169
@pytest.mark.skipif(not service_ok(SERVICE_URL),
173170
reason="WFS service is unreachable")
174171
def test_schema_wfs_200():
175-
wfs = WebFeatureService(
176-
'https://www.sciencebase.gov/catalogMaps/mapping/ows/53398e51e4b0db25ad10d288',
177-
version='2.0.0')
178-
schema = wfs.get_schema('footprint')
179-
assert len(schema['properties']) == 4
180-
assert schema['properties']['summary'] == 'string'
181-
assert schema['geometry'] == '3D Polygon'
172+
wfs = WebFeatureService(SERVICE_URL, version='2.0.0')
173+
schema = wfs.get_schema('stratunit:StratigraphicUnit')
174+
assert len(schema['properties']) == 33
175+
assert schema['properties']['DESCRIPTION'] == 'string'
176+
assert schema['geometry'] is None
182177

183178

184179
@pytest.mark.online
185180
@pytest.mark.skipif(not service_ok(SERVICE_URL),
186181
reason="WFS service is unreachable")
187182
def test_xmlfilter_wfs_110():
188-
wfs = WebFeatureService(
189-
'https://services.ga.gov.au/gis/stratunits/ows',
190-
version='1.1.0')
183+
wfs = WebFeatureService(SERVICE_URL, version='1.1.0')
191184
filter_prop = PropertyIsLike(propertyname='stratunit:GEOLOGICHISTORY', literal='Cisuralian - Guadalupian',
192185
matchCase=True)
193186

@@ -203,9 +196,7 @@ def test_xmlfilter_wfs_110():
203196
@pytest.mark.skipif(not service_ok(SERVICE_URL),
204197
reason="WFS service is unreachable")
205198
def test_xmlfilter_wfs_200():
206-
wfs = WebFeatureService(
207-
'https://services.ga.gov.au/gis/stratunits/ows',
208-
version='2.0.0')
199+
wfs = WebFeatureService(SERVICE_URL, version='2.0.0')
209200
filter_prop = PropertyIsLike(propertyname='stratunit:geologichistory', literal='Cisuralian - Guadalupian',
210201
matchCase=True)
211202

0 commit comments

Comments
 (0)