export type AllCollections = 'blueMarble' | 'NaturalEarth:raster:HYP_HR_SR_OB_DR' | 'NaturalEarth:cultural:ne_10m_admin_0_countries' | 'NaturalEarth:physical:bathymetry' | 'SRTM_ViewFinderPanorama' | 'HRDEM-Ottawa' | 'HRDEM-RedRiver'; export type TileMatrixSets = 'WebMercatorQuad' | 'WorldCRS84Quad' | 'GNOSISGlobalGrid' | 'WorldMercatorWGS84Quad'; export type GetApiCollectionsCollectionIdMapTilesTileMatrixSetIdTileMatrixTileRowTileColArgs = {tileMatrix: string, tileRow: number, tileCol: number, datetime?: string | undefined, collectionId: AllCollections, collections?: Array | undefined, subset?: Array | undefined, crs?: string | undefined, 'subset-crs'?: string | undefined, bgcolor?: string | undefined, transparent?: boolean | undefined, tileMatrixSetId: TileMatrixSets, f?: ('png' | 'jpg' | 'tiff') | undefined}; export type GetApiCollectionsCollectionIdMapTilesTileMatrixSetIdTileMatrixTileRowTileColOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve a map tile from the specified collection * * GET /collections/{collectionId}/map/tiles/{tileMatrixSetId}/{tileMatrix}/{tileRow}/{tileCol} */ export const getApiCollectionsCollectionIdMapTilesTileMatrixSetIdTileMatrixTileRowTileCol = async (args: GetApiCollectionsCollectionIdMapTilesTileMatrixSetIdTileMatrixTileRowTileColArgs, options?: GetApiCollectionsCollectionIdMapTilesTileMatrixSetIdTileMatrixTileRowTileColOptions) => { const {baseUrl = "https://maps.ecere.com/ogcapi", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (args.datetime != null) query.append("datetime", String(args.datetime)) if (args.collections != null) query.append("collections", args.collections.join(',')) if (args.subset != null) query.append("subset", args.subset.join(',')) if (args.crs != null) query.append("crs", String(args.crs)) if (args['subset-crs'] != null) query.append("subset-crs", String(args['subset-crs'])) if (args.bgcolor != null) query.append("bgcolor", String(args.bgcolor)) if (args.transparent != null) query.append("transparent", String(args.transparent)) if (args.f != null) query.append("f", String(args.f)) const url = `${baseUrl.replace(/\/+$/, '')}/collections/${encodeURIComponent(String(args.collectionId))}/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() };