def kvp_encode_get_map_request(request: GetMapRequest, swap_coordinates=False): bbox = request.bounding_box.bbox if swap_coordinates: bbox = [bbox[1], bbox[0], bbox[3], bbox[2]] params = [ ('service', 'WMS'), ('version', str(request)), ('request', 'GetMap'), ('layers', ','.join(request.layers)), ('styles', ','.join(request.styles)), ('crs', request.bounding_box.crs), ('bbox', ','.join(str(v) for v in bbox)), ('width', str(request.width)), ('height', str(request.height)), ('format', request.format), ] if request.transparent is not None: params.append(('transparent', str(request.transparent).upper())) if request.background_color is not None: params.append(('bgcolor', request.background_color)) if request.exceptions is not None: params.append(('exceptions', request.exceptions)) for name, value in request.dimensions.items(): lower = name.lower() if lower in ('time', 'elevation'): params.append((lower, value)) else: params.append((f'dim_{lower}', value)) return Result.from_kvp(params)
def kvp_encode_describe_process(request: DescribeProcessRequest, **kwargs): return Result.from_kvp( dict( service='WCS', version=str(request.version), request='DescribeProcess', processid=','.join(request.process_ids), ), **kwargs)
def kvp_encode_dismiss(request: DismissRequest, **kwargs): return Result.from_kvp( dict( service='WCS', version=str(request.version), request='Dismiss', jobid=request.job_id, ), **kwargs)
def kvp_encode_get_result(request: GetResultRequest, **kwargs): return Result.from_kvp( dict( service='WCS', version=str(request.version), request='GetResult', jobid=request.job_id, ), **kwargs)
def kvp_encode_describe_coverage(request: DescribeCoverageRequest, **kwargs): return Result.from_kvp( dict( service='WCS', version=str(request.version), request='DescribeCoverage', coverageid=','.join(request.coverage_ids), ), **kwargs)
def kvp_encode_get_coverage(request: GetCoverageRequest): params = [ ('service', 'WCS'), ('version', str(request.version)), ('request', 'GetCoverage'), ('coverageid', request.coverage_id), ] for subset in request.subsets: if isinstance(subset, Trim): low = maybe_quote(subset.low) if subset.low is not None else '*' high = maybe_quote(subset.high) if subset.high is not None else '*' params.append(('subset', f'{subset.dimension}({low},{high})')) elif isinstance(subset, Slice): params.append( ('subset', f'{subset.dimension}({maybe_quote(subset.point)})')) if request.format is not None: params.append(('format', request.format)) if request.mediatype is not None: params.append(('mediaType', request.mediatype)) if request.subsetting_crs is not None: params.append(('subsettingCrs', request.subsetting_crs)) if request.output_crs is not None: params.append(('outputCrs', request.output_crs)) scale_sizes = [ scale for scale in request.scales if isinstance(scale, ScaleSize) ] scale_axes = [ scale for scale in request.scales if isinstance(scale, ScaleAxis) ] scale_extents = [ scale for scale in request.scales if isinstance(scale, ScaleExtent) ] if request.scalefactor: params.append(('scaleFactor', str(request.scalefactor))) if scale_sizes: params.append(('scaleSize', ','.join(f'{scale.axis}({scale.size})' for scale in scale_sizes))) if scale_axes: params.append(('scaleAxes', ','.join(f'{scale.axis}({scale.factor})' for scale in scale_axes))) if scale_extents: params.append( ('scaleExtent', ','.join(f'{scale.axis}({scale.low}:{scale.high})' for scale in scale_extents))) if request.interpolation or request.axis_interpolations: if request.interpolation: params.append(('interpolation', request.interpolation)) for axis_interpolation in request.axis_interpolations: axis = axis_interpolation.axis method = axis_interpolation.method params.append(('interpolationPerAxis', f'{axis},{method}')) geotiff = request.geotiff_encoding_parameters if geotiff: if geotiff.compression is not None: params.append(('geotiff:compression', geotiff.compression)) if geotiff.jpeg_quality: params.append(('geotiff:jpeg_quality', geotiff.jpeg_quality)) if geotiff.predictor is not None: params.append(('geotiff:predictor', geotiff.predictor)) if geotiff.interleave is not None: params.append(('geotiff:interleave', geotiff.interleave)) if geotiff.tiling is not None: params.append(('geotiff:tiling', str(geotiff.tiling).lower())) if geotiff.tile_width is not None: params.append(('geotiff:tilewidth', str(geotiff.tile_width))) if geotiff.tile_height is not None: params.append(('geotiff:tileheight', str(geotiff.tile_height))) return Result.from_kvp(params)