export type TileMatrixSetNames = 'CanadianNAD83_LCC' | 'EPSG3413' | 'EPSG6933' | 'EuropeanETRS89_LAEAQuad' | 'LINZAntarticaMapTilegrid' | 'NZTM2000' | 'NZTM2000Quad' | 'UPSAntarcticWGS84Quad' | 'UPSArcticWGS84Quad' | 'UTM31WGS84Quad' | 'WebMercatorQuad' | 'WorldCRS84Quad' | 'WorldMercatorWGS84Quad'; export type GetApiApiV1LayersTilesTileMatrixSetIdLayerZXYPbfArgs = {z: number, x: number, y: number, TileMatrixSetId: TileMatrixSetNames, layer: string}; export type GetApiApiV1LayersTilesTileMatrixSetIdLayerZXYPbfOptions = {baseUrl: string, OAuth2PasswordBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Tile * * GET /api/v1/layers/tiles/{TileMatrixSetId}/{layer}/{z}/{x}/{y}.pbf */ export const getApiApiV1LayersTilesTileMatrixSetIdLayerZXYPbf = async (args: GetApiApiV1LayersTilesTileMatrixSetIdLayerZXYPbfArgs, options: GetApiApiV1LayersTilesTileMatrixSetIdLayerZXYPbfOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth2PasswordBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/x-protobuf") if (OAuth2PasswordBearer !== undefined) headers.set('authorization', `Bearer ${OAuth2PasswordBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/layers/tiles/${encodeURIComponent(String(args.TileMatrixSetId))}/${encodeURIComponent(String(args.layer))}/${encodeURIComponent(String(args.z))}/${encodeURIComponent(String(args.x))}/${encodeURIComponent(String(args.y))}.pbf${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };