export type TileMatrixSets = 'WebMercatorQuad' | 'WorldCRS84Quad' | 'GNOSISGlobalGrid' | 'WorldMercatorWGS84Quad'; export type GetApiMapTilesTileMatrixSetIdTileMatrixTileRowTileColArgs = {tileMatrix: string, tileRow: number, tileCol: number, tileMatrixSetId: TileMatrixSets}; export type GetApiMapTilesTileMatrixSetIdTileMatrixTileRowTileColOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve a default map tile of the whole dataset * * GET /map/tiles/{tileMatrixSetId}/{tileMatrix}/{tileRow}/{tileCol} */ export const getApiMapTilesTileMatrixSetIdTileMatrixTileRowTileCol = async (args: GetApiMapTilesTileMatrixSetIdTileMatrixTileRowTileColArgs, options?: GetApiMapTilesTileMatrixSetIdTileMatrixTileRowTileColOptions) => { const {baseUrl = "https://maps.ecere.com/ogcapi", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") const url = `${baseUrl.replace(/\/+$/, '')}/map/tiles/${encodeURIComponent(String(args.tileMatrixSetId))}/${encodeURIComponent(String(args.tileMatrix))}/${encodeURIComponent(String(args.tileRow))}/${encodeURIComponent(String(args.tileCol))}${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() };