Skip to content

Commit

Permalink
Merge pull request #526 from opendatacube/fix_flag_in_main_product
Browse files Browse the repository at this point in the history
Fix issue with masking on bands from main product.
  • Loading branch information
pindge authored Mar 16, 2021
2 parents 25d4bbe + 54c65b6 commit 503fb80
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion datacube_ows/cfg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def layers_report(config_values, input_file, output_file):
report = {"total_layers_count": len(config_values.values()), "layers": []}
for lyr in config_values.values():
layer = {
"product": lyr.product_names,
"product": list(lyr.product_names),
"styles_count": len(lyr.styles),
"styles_list": [styl.name for styl in lyr.styles],
}
Expand Down
32 changes: 16 additions & 16 deletions datacube_ows/ows_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,13 +763,13 @@ class OWSProductLayer(OWSNamedLayer):

def parse_product_names(self, cfg):
self.product_name = cfg["product_name"]
self.product_names = [self.product_name]
self.product_names = (self.product_name,)

self.low_res_product_name = cfg.get("low_res_product_name")
if self.low_res_product_name:
self.low_res_product_names = [self.low_res_product_name]
self.low_res_product_names = (self.low_res_product_name,)
else:
self.low_res_product_names = []
self.low_res_product_names = tuple()
if "product_names" in cfg:
raise ConfigException(f"'product_names' entry in non-multi-product layer {self.name} - use 'product_name' only")
if "low_res_product_names" in cfg:
Expand All @@ -779,31 +779,31 @@ def parse_pq_names(self, cfg):
if "dataset" in cfg:
raise ConfigException(f"The 'dataset' entry in the flags section is no longer supported. Please refer to the documentation for the correct format (layer {self.name})")
if "product" in cfg:
pq_names = [cfg["product"]]
pq_names = (cfg["product"],)
else:
pq_names = [self.product_name]
pq_names = (self.product_name,)

if "low_res_product" in cfg:
pq_low_res_names = [cfg.get("low_res_product")]
pq_low_res_names = (cfg.get("low_res_product"),)
else:
pq_low_res_names = self.low_res_product_names
if "products" in cfg:
raise ConfigException(f"'products' entry in flags section of non-multi-product layer {self.name} - use 'product' only")
if "low_res_products" in cfg:
raise ConfigException(f"'low_res_products' entry in flags section of non-multi-product layer {self.name}- use 'low_res_product' only")
return {
"pq_names": tuple(pq_names),
"pq_low_res_names": tuple(pq_low_res_names),
"pq_names": pq_names,
"pq_low_res_names": pq_low_res_names,
}


class OWSMultiProductLayer(OWSNamedLayer):
multi_product = True

def parse_product_names(self, cfg):
self.product_names = cfg["product_names"]
self.product_names = tuple(cfg["product_names"])
self.product_name = self.product_names[0]
self.low_res_product_names = cfg.get("low_res_product_names", [])
self.low_res_product_names = tuple(cfg.get("low_res_product_names", []))
if self.low_res_product_names:
self.low_res_product_name = self.low_res_product_names[0]
else:
Expand All @@ -817,21 +817,21 @@ def parse_pq_names(self, cfg):
if "datasets" in cfg:
raise ConfigException(f"The 'datasets' entry in the flags section is no longer supported. Please refer to the documentation for the correct format (layer {self.name})")
if "products" in cfg:
pq_names = cfg["products"]
pq_names = tuple(cfg["products"])
else:
pq_names = list(self.product_names)
pq_names = self.product_names

if "low_res_products" in cfg:
pq_low_res_names = cfg["low_res_products"]
pq_low_res_names = tuple(cfg["low_res_products"])
else:
pq_low_res_names = list(self.low_res_product_names)
pq_low_res_names = self.low_res_product_names
if "product" in cfg:
raise ConfigException(f"'product' entry in flags section of multi-product layer {self.name} - use 'products' only")
if "low_res_product" in cfg:
raise ConfigException(f"'low_res_product' entry in flags section of multi-product layer {self.name} - use 'low_res_products' only")
return {
"pq_names": tuple(pq_names),
"pq_low_res_names": tuple(pq_low_res_names),
"pq_names": pq_names,
"pq_low_res_names": pq_low_res_names,
}

def parse_ows_layer(cfg, global_cfg, parent_layer=None):
Expand Down
2 changes: 1 addition & 1 deletion datacube_ows/styles/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def make_ready(self, dc, *args, **kwargs):
for mask in self.masks:
fb = mask.band
if fb.pq_names == self.product.product_names:
self.needed_bands.add(fb.band)
self.needed_bands.add(fb.pq_band)
continue
handled=False
for pqp, pqb in self.pq_product_bands:
Expand Down

0 comments on commit 503fb80

Please sign in to comment.