Skip to content

Commit

Permalink
Resolve 1.8-1.9 cherry-picking conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpacemanPaul committed Jul 31, 2024
1 parent 0bdeeca commit b6957f6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
26 changes: 13 additions & 13 deletions datacube_ows/feature_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,23 +232,23 @@ def feature_info(args: dict[str, str]) -> FlaskResponse:
# legacy function signature: pass in band and index data as a dictionary
date_info[k] = f(date_info["bands"])

# Any custom-defined layer fields
# (entries from the legacy are overwritten by the new if both exist)
for k, f in params.product.feature_info_custom_includes.items():
# New function signature: pass in:
# Any custom-defined layer fields
# (entries from the legacy are overwritten by the new if both exist)
for k, f in params.layer.feature_info_custom_includes.items():
# New function signature: pass in:
# * a single pixel (1x1x1) multiband xarray Dataset, and
# * the ODC Dataset model (i.e. full ODC metadata)
date_info[k] = f(pixel_ds, ds)

if params.style is not None:
# Any custom-defined style fields
# (style definitions override layer-level entries where both exist)
for k, f in params.style.feature_info_includes.items():
# Function signature: pass in:
# * a single pixel (1x1x1) multiband xarray Dataset, and
# * the ODC Dataset model (i.e. full ODC metadata)
date_info[k] = f(pixel_ds, ds)

if params.style is not None:
# Any custom-defined style fields
# (style definitions override layer-level entries where both exist)
for k, f in params.style.feature_info_includes.items():
# Function signature: pass in:
# * a single pixel (1x1x1) multiband xarray Dataset, and
# * the ODC Dataset model (i.e. full ODC metadata)
date_info[k] = f(pixel_ds, ds)

cast(list[RAW_CFG], feature_json["data"]).append(date_info)
fi_date_index[dt] = cast(dict[str, list[RAW_CFG]], feature_json)["data"][-1]
# Multidate custom includes reflect all selected times on multidate requests,
Expand Down
4 changes: 1 addition & 3 deletions datacube_ows/templates/wms_capabilities.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@
{% elif lyr.regular_time_axis %}
<Dimension name="time" units="ISO8601" default="{{ lyr.default_time.isoformat() }}">{{ lyr.time_axis_representation() }}</Dimension>
{% elif lyr_ranges.times|length > 1 %}
<Dimension name="time" units="ISO8601" default="{{ lyr.default_time.isoformat() }}">
{% for t in lyr_ranges.times %}{{ t.isoformat() }}{% if not loop.last %},{% endif %}{% endfor %}
</Dimension>
<Dimension name="time" units="ISO8601" default="{{ lyr.default_time.isoformat() }}">{% for t in lyr_ranges.times %}{{ t.isoformat() }}{% if not loop.last %},{% endif %}{% endfor %}</Dimension>
{% endif %}

{% if lyr.attribution %}
Expand Down
20 changes: 10 additions & 10 deletions datacube_ows/wms_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ def get_layer(self, args) -> OWSNamedLayer:
return get_layer_from_arg(args)


def single_style_from_args(product, args, required=True):
def single_style_from_args(layer, args, required=True):
# User Band Math (overrides style if present).
if product.user_band_math and "code" in args and "colorscheme" in args:
if layer.user_band_math and "code" in args and "colorscheme" in args:
code = args["code"]
mpl_ramp = args["colorscheme"]
try:
Expand All @@ -347,7 +347,7 @@ def single_style_from_args(product, args, required=True):
raise WMSException(f"Colorscale range must be two numbers, sorted and separated by a comma.",
locator="Colorscalerange parameter")
try:
style = StyleDef(product, {
style = StyleDef(layer, {
"name": "custom_user_style",
"index_expression": code,
"mpl_ramp": mpl_ramp,
Expand All @@ -374,28 +374,28 @@ def single_style_from_args(product, args, required=True):
if not style_r and not required:
return None
if not style_r:
style_r = product.default_style.name
style = product.style_index.get(style_r)
style_r = layer.default_style.name
style = layer.style_index.get(style_r)
if not style:
raise WMSException("Style %s is not defined" % style_r,
WMSException.STYLE_NOT_DEFINED,
locator="Style parameter",
valid_keys=list(product.style_index))
valid_keys=list(layer.style_index))
return style

class GetLegendGraphicParameters():
def __init__(self, args):
self.product = get_layer_from_arg(args, 'layer')
self.layer = get_layer_from_arg(args, 'layer')

# Validate Format parameter
self.format = get_arg(args, "format", "image format",
errcode=WMSException.INVALID_FORMAT,
lower=True,
permitted_values=["image/png"])
self.style = single_style_from_args(self.product, args)
self.style = single_style_from_args(self.layer, args)
self.styles = [self.style]
# Time parameter
self.times = get_times(args, self.product)
self.times = get_times(args, self.layer)


class GetMapParameters(GetParameters):
Expand Down Expand Up @@ -456,7 +456,7 @@ def method_specific_init(self, args):
"%s parameter" % coords[0])
self.i = int(i)
self.j = int(j)
self.style = single_style_from_args(self.product, args, required=False)
self.style = single_style_from_args(self.layer, args, required=False)


# Solar angle correction functions
Expand Down

0 comments on commit b6957f6

Please sign in to comment.