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

WCS fixes. (cherry pick of PR #1027 to 1.9 branch) #1028

Merged
merged 4 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ assignees: ''
4.

## Context (Environment)
### `datacube-ows` version (datacube-ows --version):
<!-- Run command datacube-ows --versiion -->
### `datacube-ows` version (datacube-ows-update --version):
<!-- Run command datacube-ows-update --version -->

### `ows_config.py` file (link, sample code)
<!-- Porvide a link to config or paste the config code below -->
<!-- Provide a link to config or paste the config code below -->

### datacube product metadata (datacube product show product_name)
<!-- If issue is related to a specific layer, run `datacube product show <product_name>` to get the product metadata and provide below -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Granting select on layer ranges table to {role}

GRANT SELECT ON ows.layer_ranges TO {role};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Granting agdc_user role to {role}

GRANT agdc_user to {role};
2 changes: 1 addition & 1 deletion datacube_ows/templates/wms_capabilities.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
{% endif %}
{%- endmacro %}
{% macro render_named_layer(lyr, depth=0) -%}
{% if not lyr.hide %}
{% set lyr_ranges = lyr.ranges %}
{% if not lyr.hide %}
<Layer queryable="1">
<Name>{{ lyr.name }}</Name>
<Title>{{ lyr.title }}</Title>
Expand Down
6 changes: 4 additions & 2 deletions datacube_ows/wcs1_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,17 @@ def get_coverage_data(req, qprof):
nparrays = {
band: (("time", yname, xname),
numpy.full((len(req.times), len(yvals), len(xvals)),
req.layer.band_idx.nodata_val(band))
req.layer.band_idx.nodata_val(band),
dtype=req.layer.band_idx.dtype_val(band))
)
for band in req.bands
}
else:
nparrays = {
band: (("time", xname, yname),
numpy.full((len(req.times), len(xvals), len(yvals)),
req.layer.band_idx.nodata_val(band))
req.layer.band_idx.nodata_val(band),
dtype=req.layer.band_idx.dtype_val(band))
)
for band in req.bands
}
Expand Down
49 changes: 24 additions & 25 deletions datacube_ows/wcs_scaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,26 @@ def to_crs(self, new_crs):
grid = self.layer.grids[new_crs]
skip_x_xform = False
skip_y_xform = False
if self.crs != new_crs:
if not self.subsetted.x and not self.subsetted.y:
# Neither axis subsetted
self.min.x = self.layer.ranges["bboxes"][new_crs]["left"]
self.max.x = self.layer.ranges["bboxes"][new_crs]["right"]
self.min.y = self.layer.ranges["bboxes"][new_crs]["bottom"]
self.max.y = self.layer.ranges["bboxes"][new_crs]["top"]
self.crs = new_crs
elif not self.subsetted.x or not self.subsetted.y:
# One axis subsetted
if self.subsetted.x:
self.min.y = self.layer.ranges["bboxes"][self.crs]["bottom"]
self.max.y = self.layer.ranges["bboxes"][self.crs]["top"]
skip_y_xform = True
if self.subsetted.y:
self.min.x = self.layer.ranges["bboxes"][self.crs]["left"]
self.max.x = self.layer.ranges["bboxes"][self.crs]["right"]
skip_x_xform = True
else:
# Both axes subsetted
pass
if not self.subsetted.x and not self.subsetted.y:
# Neither axis subsetted
self.min.x = self.layer.ranges.bboxes[new_crs]["left"]
self.max.x = self.layer.ranges.bboxes[new_crs]["right"]
self.min.y = self.layer.ranges.bboxes[new_crs]["bottom"]
self.max.y = self.layer.ranges.bboxes[new_crs]["top"]
self.crs = new_crs
elif not self.subsetted.x or not self.subsetted.y:
# One axis subsetted
if self.subsetted.x:
self.min.y = self.layer.ranges.bboxes[self.crs]["bottom"]
self.max.y = self.layer.ranges.bboxes[self.crs]["top"]
skip_y_xform = True
if self.subsetted.y:
self.min.x = self.layer.ranges.bboxes[self.crs]["left"]
self.max.x = self.layer.ranges.bboxes[self.crs]["right"]
skip_x_xform = True
else:
# Both axes subsetted
pass

if self.crs != new_crs:
is_point = False
Expand Down Expand Up @@ -189,14 +188,14 @@ def to_crs(self, new_crs):
proj_geom = geom.to_crs(new_crs_obj)
bbox = proj_geom.boundingbox
if skip_x_xform:
self.min.x = self.layer.ranges["bboxes"][new_crs]["left"]
self.max.x = self.layer.ranges["bboxes"][new_crs]["right"]
self.min.x = self.layer.ranges.bboxes[new_crs]["left"]
self.max.x = self.layer.ranges.bboxes[new_crs]["right"]
else:
self.min.x = bbox.left
self.max.x = bbox.right
if skip_y_xform:
self.min.y = self.layer.ranges["bboxes"][new_crs]["bottom"]
self.max.y = self.layer.ranges["bboxes"][new_crs]["top"]
self.min.y = self.layer.ranges.bboxes[new_crs]["bottom"]
self.max.y = self.layer.ranges.bboxes[new_crs]["top"]
else:
self.min.y = bbox.bottom
self.max.y = bbox.top
Expand Down
7 changes: 7 additions & 0 deletions integration_tests/test_wcs_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,13 @@ def test_wcs20_getcoverage_geotiff_bigimage(ows_server):
scalesize="x(3000),y(3000)",
)
assert "too much data for a single request" in str(e.value)
# Test default request
with pytest.raises(ServiceException) as e:
output = wcs.getCoverage(
identifier=[layer.name],
format="application/x-netcdf",
)
assert "too much data for a single request" in str(e.value)


def test_wcs20_getcoverage_netcdf(ows_server):
Expand Down
22 changes: 7 additions & 15 deletions tests/test_wcs_scaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from affine import Affine

from datacube_ows.ows_configuration import OWSConfig, OWSProductLayer
from datacube_ows.index.api import CoordRange, LayerExtent
from datacube_ows.wcs_scaler import (SpatialParameter, WCSScaler,
WCSScalerUnknownDimension)

Expand Down Expand Up @@ -124,20 +125,11 @@ def layer_crs_geom():
times = [datetime.date(2013, 1, 1), datetime.date(2014, 1, 1), datetime.date(2015, 1, 1),
datetime.date(2016, 1, 1), datetime.date(2017, 1, 1), datetime.date(2018, 1, 1)]
product_layer.dynamic = False
product_layer._ranges = {
'lat': {
'min': -34.5250413940276,
'max': -33.772472435988
},
'lon': {
'min': 150.330509919584,
'max': 151.258021405841
},
'times': times,
'start_time': datetime.date(2013, 1, 1),
'end_time': datetime.date(2018, 1, 1),
'time_set': set(times),
'bboxes': {
product_layer._ranges = LayerExtent(
lat=CoordRange(min=-34.5250413940276, max=-33.772472435988),
lon=CoordRange(min=150.330509919584, max=151.258021405841),
times=times,
bboxes={
'EPSG:3111': {
'top': 5725844.213533809, 'left': -1623290.9363678931,
'right': 3983581.449863785, 'bottom': 1042109.9920098772
Expand All @@ -155,7 +147,7 @@ def layer_crs_geom():
'right': 157.105656164263, 'bottom': -45.761684927317
}
}
}
)
return product_layer


Expand Down
Loading