def get_capabilities(args): # TODO: Handle updatesequence request parameter for cache consistency. # Note: Only WMS v1.0.0 exists at this stage, so no version negotiation is necessary # Extract layer metadata from Datacube. cfg = get_config() url = args.get('Host', args['url_root']) base_url = get_service_base_url(cfg.allowed_urls, url) section = args.get("section") if section: section = section.lower() show_service_id = False show_service_provider = False show_ops_metadata = False show_contents = False show_themes = False if section is None: show_service_id = True show_service_provider = True show_ops_metadata = True show_contents = True show_themes = True else: sections = section.split(",") for s in sections: if s == "all": show_service_id = True show_service_provider = True show_ops_metadata = True show_contents = True show_themes = True elif s == "serviceidentification": show_service_id = True elif s == "serviceprovider": show_service_provider = True elif s == "operationsmetadata": show_ops_metadata = True elif s == "contents": show_contents = True elif s == "themes": show_themes = True else: raise WMTSException("Invalid section: %s" % section, WMTSException.INVALID_PARAMETER_VALUE, locator="Section parameter") return ( render_template( "wmts_capabilities.xml", cfg=cfg, base_url=base_url, show_service_id = show_service_id, show_service_provider = show_service_provider, show_ops_metadata = show_ops_metadata, show_contents = show_contents, show_themes = show_themes, webmerc_ss = WebMercScaleSet), 200, cfg.response_headers( {"Content-Type": "application/xml", "Cache-Control": "max-age=10"} ) )
def get_capabilities(args): # TODO: Handle updatesequence request parameter for cache consistency. # Note: Only WMS v1.3.0 is fully supported at this stage, so no version negotiation is necessary # Extract layer metadata from Datacube. cfg = get_config() url = args.get('Host', args['url_root']) base_url = get_service_base_url(cfg.allowed_urls, url) return (render_template("wms_capabilities.xml", cfg=cfg, base_url=base_url), 200, cfg.response_headers({ "Content-Type": "application/xml", "Cache-Control": "no-cache,max-age=0" }))
def ogc_impl(): #pylint: disable=too-many-branches nocase_args = lower_get_args() nocase_args = capture_headers(request, nocase_args) service = nocase_args.get("service", "").upper() if service: return ogc_svc_impl(service.lower()) # create dummy env if not exists try: # service argument is only required (in fact only defined) by OGC for # GetCapabilities requests. As long as we are persisting with a single # routing end point for all services, we must derive the service from the request # parameter. # This is a quick hack to fix #64. Service and operation routing could be # handled more elegantly. op = nocase_args.get("request", "").upper() if op in WMS_REQUESTS: return ogc_svc_impl("wms") elif op in WCS_REQUESTS: return ogc_svc_impl("wcs") elif op: # Should we return a WMS or WCS exception if there is no service specified? # Defaulting to WMS because that's what we already have. raise WMSException("Invalid service and/or request", locator="Service and request parameters") else: cfg = get_config() url = nocase_args.get('Host', nocase_args['url_root']) base_url = get_service_base_url(cfg.allowed_urls, url) return (render_template( "index.html", cfg=cfg, supported=OWS_SUPPORTED, base_url=base_url, version=__version__, ), 200, resp_headers({"Content-Type": "text/html"})) except OGCException as e: _LOG.error("Handled Error: %s", repr(e.errors)) return e.exception_response() except Exception as e: # pylint: disable=broad-except tb = sys.exc_info()[2] ogc_e = WMSException("Unexpected server error: %s" % str(e), http_response=500) return ogc_e.exception_response(traceback=traceback.extract_tb(tb))
def get_capabilities(args): # TODO: Handle updatesequence request parameter for cache consistency. section = args.get("section") if section: section = section.lower() show_service = False show_capability = False show_content_metadata = False if section is None or section == "/": show_service = True show_capability = True show_content_metadata = True elif section == "/wcs_capabilities/service": show_service = True elif section == "/wcs_capabilities/capability": show_capability = True elif section == "/wcs_capabilities/contentmetadata": show_content_metadata = True else: raise WCS1Exception("Invalid section: %s" % section, WCS1Exception.INVALID_PARAMETER_VALUE, locator="Section parameter") # Extract layer metadata from Datacube. cfg = get_config() url = args.get('Host', args['url_root']) base_url = get_service_base_url(cfg.allowed_urls, url) return (render_template("wcs_capabilities.xml", show_service=show_service, show_capability=show_capability, show_content_metadata=show_content_metadata, cfg=cfg, base_url=base_url), 200, cfg.response_headers({ "Content-Type": "application/xml", "Cache-Control": "no-cache, max-age=0" }))
def get_capabilities(args): # Extract layer metadata from Datacube. cfg = get_config() url = args.get('Host', args['url_root']) base_url = get_service_base_url(cfg.allowed_urls, url) request_obj = kvp_decode_get_capabilities(args) sections = request_obj.sections or ['all'] # TODO: check for invalid sections include_service_identification = False include_service_provider = False include_operations_metadata = False include_service_metadata = False include_coverage_summary = False if 'all' in sections: include_service_identification = True include_service_provider = True include_operations_metadata = True include_service_metadata = True include_coverage_summary = True if 'serviceidentification' in sections: include_service_identification = True if 'serviceprovider' in sections: include_service_provider = True if 'operationsmetadata' in sections: include_operations_metadata = True if 'servicemetadata' in sections: include_service_metadata = True if 'coveragesummary' in sections: include_coverage_summary = True capabilities = ServiceCapabilities.with_defaults_v20( service_url=base_url + '/wcs', allowed_operations=[ 'GetCapabilities', 'DescribeCoverage', 'GetCoverage' ], allow_post=False, title=cfg.title, abstract=cfg.abstract, keywords=cfg.keywords, fees=cfg.fees, access_constraints=[cfg.access_constraints], provider_name='', provider_site='', individual_name=cfg.contact_info['person'], organisation_name=cfg.contact_info['organisation'], position_name=cfg.contact_info['position'], phone_voice=cfg.contact_info['telephone'], phone_facsimile=cfg.contact_info['fax'], delivery_point=cfg.contact_info['address']['address'], city=cfg.contact_info['address']['city'], administrative_area=cfg.contact_info['address']['state'], postal_code=cfg.contact_info['address']['postcode'], country=cfg.contact_info['address']['country'], electronic_mail_address=cfg.contact_info['email'], online_resource=base_url, # hours_of_service=, # contact_instructions=, # role=, coverage_summaries=[ CoverageSummary(identifier=product.name, coverage_subtype='RectifiedGridCoverage', title=product.title, wgs84_bbox=WGS84BoundingBox([ product.ranges['lon']['min'], product.ranges['lat']['min'], product.ranges['lon']['max'], product.ranges['lat']['max'], ])) for product in cfg.product_index.values() if product.ready and not product.hide and product.wcs ], formats_supported=[ fmt.mime for fmt in cfg.wcs_formats if 2 in fmt.renderers ], crss_supported=[ crs # TODO: conversion to URL format for crs in cfg.published_CRSs ], interpolations_supported=None, # TODO: find out interpolations ) result = encoders_v20.xml_encode_capabilities( capabilities, include_service_identification=include_service_identification, include_service_provider=include_service_provider, include_operations_metadata=include_operations_metadata, include_service_metadata=include_service_metadata, include_coverage_summary=include_coverage_summary) return (result.value, 200, resp_headers({ "Content-Type": result.content_type, "Cache-Control": "no-cache, max-age=0" }))