export type GetApiCollectionsCollectionIdTilesZXYArgs = {collectionId: string, z: number, x: number, y: number, properties?: string | undefined}; export type GetApiCollectionsCollectionIdTilesZXYOptions = {baseUrl?: string | undefined, JWT?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get MVT Tile * * GET /collections/{collectionId}/tiles/{z}/{x}/{y} * * Also accepts auth: BasicAuth */ export const getApiCollectionsCollectionIdTilesZXY = async (args: GetApiCollectionsCollectionIdTilesZXYArgs, options?: GetApiCollectionsCollectionIdTilesZXYOptions) => { const {baseUrl = "https://api.planet.com/features/v1/ogc/my", fetch: fetchFn = fetch, JWT} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.properties != null) query.append("properties", String(args.properties)) if (JWT !== undefined) headers.set('authorization', `Bearer ${JWT}`) const url = `${baseUrl.replace(/\/+$/, '')}/collections/${encodeURIComponent(String(args.collectionId))}/tiles/${encodeURIComponent(String(args.z))}/${encodeURIComponent(String(args.x))}/${encodeURIComponent(String(args.y))}${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() };