export type GetApiTilesTilesIdWMTSCapabilitiesXmlOptions = {baseUrl?: string | undefined, key?: string | undefined, fetch?: typeof fetch | undefined}; /** * WMTS Capabilities * * GET /tiles/{tilesId}/WMTSCapabilities.xml */ export const getApiTilesTilesIdWMTSCapabilitiesXml = async (options?: GetApiTilesTilesIdWMTSCapabilitiesXmlOptions) => { const {baseUrl = "https://api.maptiler.com", fetch: fetchFn = fetch, key} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/xml") if (key !== undefined) query.set("key", key) const url = `${baseUrl.replace(/\/+$/, '')}/tiles/${encodeURIComponent(String(args.tilesId))}/WMTSCapabilities.xml${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.text() };