Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with vector GFI requests on SGRIDS #23

Merged
merged 14 commits into from
Jul 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 31 additions & 12 deletions xpublish_wms/wms/get_feature_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,37 @@ def get_feature_info(ds: xr.Dataset, query: dict) -> Response:
elif grid_type == GridType.SGRID:
topology = ds.cf["grid_topology"]

# TODO: ASSUMES HEAVILY THAT ALL PARAMETERS HAVE THE SAME GRID LOCATION
grid_location = ds[parameters[0]].attrs["location"]
lng_coord, lat_coord = topology.attrs[f"{grid_location}_coordinates"].split(" ")
selected_ds = sel2d(
selected_ds,
lons=selected_ds.cf[lng_coord],
lats=selected_ds.cf[lat_coord],
lon0=x_coord[x],
lat0=y_coord[y],
)
x_axis = [strip_float(selected_ds.cf[lng_coord])]
y_axis = [strip_float(selected_ds.cf[lat_coord])]
merged_ds = None
x_axis = None
y_axis = None

for parameter in parameters:
grid_location = selected_ds[parameter].attrs["location"]
lng_coord, lat_coord = topology.attrs[f"{grid_location}_coordinates"].split(
" ",
)
new_selected_ds = sel2d(
selected_ds,
lons=selected_ds.cf[lng_coord],
lats=selected_ds.cf[lat_coord],
lon0=x_coord[x],
lat0=y_coord[y],
)

if merged_ds is None:
merged_ds = new_selected_ds[[parameter, lat_coord, lng_coord]]
else:
merged_ds = new_selected_ds[[parameter, lat_coord, lng_coord]].merge(
merged_ds,
compat="override",
)

if x_axis is None:
x_axis = [strip_float(new_selected_ds.cf[lng_coord])]
if y_axis is None:
y_axis = [strip_float(new_selected_ds.cf[lat_coord])]

selected_ds = merged_ds
else:
raise HTTPException(500, f"Unsupported grid type: {grid_type}")

Expand Down