From 00d82daca2cdf0912d7cf73dc1de85f9bfff1505 Mon Sep 17 00:00:00 2001 From: Lukas Phaf Date: Mon, 25 Mar 2024 18:00:17 +0100 Subject: [PATCH] Fix CoverageCollection parameters. --- api/formatters/covjson.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/formatters/covjson.py b/api/formatters/covjson.py index 733dd585..23b3b97b 100644 --- a/api/formatters/covjson.py +++ b/api/formatters/covjson.py @@ -1,6 +1,8 @@ import math +import operator from collections import namedtuple from datetime import timezone +from functools import reduce from itertools import groupby from covjson_pydantic.coverage import Coverage @@ -88,9 +90,8 @@ def convert_to_covjson(response): elif len(coverages) == 1: return coverages[0] else: - return CoverageCollection( - coverages=coverages, parameters=coverages[0].parameters - ) # HACK to take parameters from first one + parameter_union = reduce(operator.ior, (c.parameters for c in coverages), {}) + return CoverageCollection(coverages=coverages, parameters=dict(sorted(parameter_union.items()))) def _collect_data(ts_mdata, obs_mdata):