Skip to content

Commit

Permalink
Expose WFS 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Jan 31, 2025
1 parent c7d10ff commit b206184
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/ogc_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ def adjust_params(self, params, permission, origin, method):
ogc_request = params.get('REQUEST', '').upper()

if ogc_service == 'WFS':
# always use version 1.0.0 for WFS requests
self.logger.warning("Overriding WFS VERSION=1.0.0")
params['VERSION'] = '1.0.0'
if params['VERSION'] not in ['1.0.0', '1.1.0']:
self.logger.warning("Unsupported WFS version %s requested, falling back to 1.1.0" % params['VERSION'])
params['VERSION'] = '1.1.0'

if ogc_service == 'WMS' and ogc_request == 'GETMAP':
requested_layers = params.get('LAYERS')
Expand Down
31 changes: 26 additions & 5 deletions src/wfs_response_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ def wfs_getcapabilities(response, host_url, params, script_root, permissions):

if response.status_code == requests.codes.ok:
# parse capabilities XML
xlinkns = 'http://www.w3.org/1999/xlink'
owsns = 'http://www.opengis.net/ows'
ElementTree.register_namespace('', 'http://www.opengis.net/wfs')
ElementTree.register_namespace('ogc', 'http://www.opengis.net/ogc')
ElementTree.register_namespace('ows', owsns)
ElementTree.register_namespace('xlink', xlinkns)
root = ElementTree.fromstring(xml)

# use default namespace for XML search
Expand All @@ -47,10 +51,16 @@ def wfs_getcapabilities(response, host_url, params, script_root, permissions):
url_parts.scheme, url_parts.netloc, script_root, permissions.get('service_name')
)

for online_resource in root.findall('.//%sGet' % (np), ns):
online_resource.set('onlineResource', wfs_url)
for online_resource in root.findall('.//%sPost' % (np), ns):
online_resource.set('onlineResource', wfs_url)
if params['VERSION'] == "1.1.0":
for online_resource in root.findall('.//ows:Get', {'ows': owsns}):
online_resource.set('{%s}href' % xlinkns, wfs_url)
for online_resource in root.findall('.//ows:Post', {'ows': owsns}):
online_resource.set('{%s}href' % xlinkns, wfs_url)
else:
for online_resource in root.findall('.//%sGet' % (np), ns):
online_resource.set('onlineResource', wfs_url)
for online_resource in root.findall('.//%sPost' % (np), ns):
online_resource.set('onlineResource', wfs_url)

# remove Transaction capability
capability_request = root.find(
Expand Down Expand Up @@ -111,9 +121,20 @@ def wfs_describefeaturetype(response, params, permissions):
ns = {}
np = ''

complexTypeMap = {}
for element in root.findall('%selement' % np, ns):
eltype = element.get('type')
if eltype.startswith("qgs:"):
eltype = eltype[4:]
complexTypeMap[eltype] = element.get('name')

for complex_type in root.findall('%scomplexType' % np, ns):
# get layer name
layer_name = complex_type.get('name', 'Type')[:-4]
type_name = complex_type.get('name')
layer_name = complexTypeMap.get(type_name, None)
if not layer_name:
# Unknown layer?
continue

# get permitted attributes for layer
permitted_attributes = permissions['layers'].get(layer_name, [])
Expand Down

0 comments on commit b206184

Please sign in to comment.