Skip to content

Commit

Permalink
OGC API - Coverages: Propagate selected fields into covjson conversion (
Browse files Browse the repository at this point in the history
geopython#1788)

* Propagate selected fields into covjson conversion

* Update xarray_.py

---------

Co-authored-by: Tom Kralidis <[email protected]>
  • Loading branch information
JamesVarndell and tomkralidis authored Aug 22, 2024
1 parent 33b4ff7 commit 15be1dc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pygeoapi/provider/xarray_.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def gen_covjson(self, metadata, data, fields):
:param metadata: coverage metadata
:param data: rasterio DatasetReader object
:param fields: fields dict
:param fields: fields
:returns: dict of CoverageJSON representation
"""
Expand All @@ -246,6 +246,11 @@ def gen_covjson(self, metadata, data, fields):
minx, miny, maxx, maxy = metadata['bbox']
mint, maxt = metadata['time']

selected_fields = {
key: value for key, value in self.fields.items()
if key in fields
}

try:
tmp_min = data.coords[self.y_field].values[0]
except IndexError:
Expand Down Expand Up @@ -294,7 +299,7 @@ def gen_covjson(self, metadata, data, fields):
'ranges': {}
}

for key, value in self.fields.items():
for key, value in selected_fields.items():
parameter = {
'type': 'Parameter',
'description': value['title'],
Expand All @@ -315,7 +320,7 @@ def gen_covjson(self, metadata, data, fields):
data = _convert_float32_to_float64(data)

try:
for key, value in self.fields.items():
for key, value in selected_fields.items():
cj['ranges'][key] = {
'type': 'NdArray',
'dataType': value['type'],
Expand Down

0 comments on commit 15be1dc

Please sign in to comment.