Skip to content

Commit

Permalink
Add xyz tile support (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpiannucci authored Oct 17, 2024
1 parent 034acb3 commit b0d290b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ cartopy
cf_xarray
datashader
matplotlib
mercantile
Pillow
xarray
xpublish>=0.3.0,<0.4.0
10 changes: 8 additions & 2 deletions xpublish_wms/wms/get_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import datashader as dsh
import datashader.transfer_functions as tf
import matplotlib.cm as cm
import mercantile
import numpy as np
import pandas as pd
import xarray as xr
Expand Down Expand Up @@ -87,7 +88,7 @@ def get_minmax(self, ds: xr.Dataset, query: dict) -> dict:
entire_layer = False
if "bbox" not in query:
# When BBOX is not specified, we are just going to slice the layer in time and elevation
# and return the min and max values for the entire layer so bbox can just be the whoel world
# and return the min and max values for the entire layer so bbox can just be the whole world
entire_layer = True
query["bbox"] = "-180,-90,180,90"
query["width"] = 1
Expand Down Expand Up @@ -134,7 +135,12 @@ def ensure_query_types(self, ds: xr.Dataset, query: dict):

# Grid
self.crs = query.get("crs", None) or query.get("srs")
self.bbox = [float(x) for x in query["bbox"].split(",")]
tile = query.get("tile", None)
if tile is not None:
tile = [float(x) for x in query["tile"].split(",")]
self.bbox = mercantile.xy_bounds(*tile)
else:
self.bbox = [float(x) for x in query["bbox"].split(",")]
self.width = int(query["width"])
self.height = int(query["height"])

Expand Down

0 comments on commit b0d290b

Please sign in to comment.