@@ -321,17 +321,23 @@ def __filter_getcapabilities(self, response, permissions, params):
321321
322322 self .__update_online_resources (online_resources , service_url , xlinkns , params )
323323
324+ # remove unsupported info formats
325+ featureInfoEl = root .find ('.//%sGetFeatureInfo' % (np ), ns )
326+ for formatEl in featureInfoEl .findall ('./%sFormat' % np , ns ):
327+ if formatEl .text not in ['text/plain' , 'text/xml' , 'text/html' ]:
328+ featureInfoEl .remove (formatEl )
329+
330+ # override GetFeatureInfo OnlineResources
324331 info_url = permissions ['online_resources' ].get ('feature_info' )
325332 if info_url :
326- # override GetFeatureInfo OnlineResources
327333 online_resources = root .findall (
328334 './/%sGetFeatureInfo//%sOnlineResource' % (np , np ), ns
329335 )
330336 self .__update_online_resources (online_resources , info_url , xlinkns , params )
331337
338+ # override GetLegend OnlineResources
332339 legend_url = permissions ['online_resources' ].get ('legend' )
333340 if legend_url :
334- # override GetLegend OnlineResources
335341 online_resources = root .findall (
336342 './/%sLegendURL//%sOnlineResource' % (np , np ), ns
337343 )
@@ -401,16 +407,21 @@ def __filter_getcapabilities(self, response, permissions, params):
401407 })
402408 editConfigEl .append (onlineResourceEl )
403409
404-
410+ # Inject GetTranslations url
411+ if permissions ['online_resources' ].get ('service' ):
412+ translationsEl = ElementTree .Element ('Traslations' )
413+ layerEl .append (translationsEl )
414+ ts_url = permissions ['online_resources' ]['service' ] + "?SERVICE=GetTranslations&LANG={lang}"
415+ if ts_url .startswith ("/" ):
416+ ts_url = request .host_url .rstrip ("/" ) + ts_url
417+ onlineResourceEl = ElementTree .Element ('OnlineResource' , {
418+ '{%s}href' % xlinkns : ts_url ,
419+ '{%s}type' % xlinkns : 'simple'
420+ })
421+ translationsEl .append (onlineResourceEl )
405422
406423 root_layer = root .find ('%sCapability/%sLayer' % (np , np ), ns )
407424 if root_layer is not None :
408- # remove broken info format 'application/vnd.ogc.gml/3.1.1'
409- feature_info = root .find ('.//%sGetFeatureInfo' % np , ns )
410- if feature_info is not None :
411- for format in feature_info .findall ('%sFormat' % np , ns ):
412- if format .text == 'application/vnd.ogc.gml/3.1.1' :
413- feature_info .remove (format )
414425
415426 # filter and update layers by permissions
416427 permitted_layers = permissions ['public_layers' ]
0 commit comments