Skip to content

Commit

Permalink
Fix autoscale bug, add test coverage (#101)
Browse files Browse the repository at this point in the history
* Fix autoscale bug, add test coverage

* lint
  • Loading branch information
mpiannucci authored Nov 13, 2024
1 parent 683f7df commit a04aece
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 8 additions & 0 deletions tests/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ def test_get_map(xpublish_client):
assert response.status_code == 200, "Response did not return successfully"
assert response.headers["content-type"] == "image/png", "Response is not an image"

autoscale_response = xpublish_client.get(
"datasets/air/wms?version=1.3.0&service=WMS&request=GetMap&layers=air&styles=raster/default&crs=EPSG:4326&bbox=-160.0,15.0,-30.0,75.0&width=512&height=513&format=image/png&colorscalerange=227.0,302.6&autoscale=True",
)
assert autoscale_response.status_code == 200, "Response did not return successfully"
assert (
autoscale_response.headers["content-type"] == "image/png"
), "Response is not an image"


def test_get_feature_info(xpublish_client):
response = xpublish_client.get(
Expand Down
8 changes: 3 additions & 5 deletions xpublish_wms/wms/get_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ def render(
return {"min": float(da.min()), "max": float(da.max())}

if not self.autoscale:
vmin, vmax = self.colorscalerange
span = (self.colorscalerange[0], self.colorscalerange[1])
else:
vmin, vmax = [None, None]
span = None

start_shade = time.time()
cvs = dsh.Canvas(
Expand All @@ -344,8 +344,6 @@ def render(
y_range=(self.bbox[1], self.bbox[3]),
)

print(da)

if ds.gridded.render_method == RenderMethod.Quad:
mesh = cvs.quadmesh(
da,
Expand Down Expand Up @@ -373,7 +371,7 @@ def render(
mesh,
cmap=cm.get_cmap(self.palettename),
how="linear",
span=(vmin, vmax),
span=span,
)
logger.info(f"WMS GetMap Shade time: {time.time() - start_shade}")

Expand Down

0 comments on commit a04aece

Please sign in to comment.