export type GetApiGlobaldemArgs = {demtype: 'SRTMGL3' | 'SRTMGL1' | 'SRTMGL1_E' | 'AW3D30' | 'AW3D30_E' | 'SRTM15Plus' | 'NASADEM' | 'COP30' | 'COP90' | 'EU_DTM' | 'GEDI_L3' | 'GEBCOIceTopo' | 'GEBCOSubIceTopo' | 'CA_MRDEM_DTM' | 'CA_MRDEM_DSM' | 'ANADEM' | 'GEDTM30', south: number, north: number, west: number, east: number, outputFormat?: ('GTiff' | 'AAIGrid' | 'HFA') | undefined, API_Key: string}; export type GetApiGlobaldemOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Access global topographic datasets including SRTM GL3 (Global 90m), GL1 (Global 30m), ALOS World 3D, SRTM15+ V2.1, GEBCO IceTopo, and GEBCO SubIceTopo (Global Bathymetry 500m). Note: Requests are limited to 500,000,000 km² for GEDI L3, 125,000,000 km² for SRTM15+ V2.1, GEBCO IceTopo, and GEBCO SubIceTopo, 4,050,000 km² for SRTM GL3, COP90 and 450,000 km² for all other data. * * GET /globaldem */ export const getApiGlobaldem = async (args: GetApiGlobaldemArgs, options: GetApiGlobaldemOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.demtype != null) query.append("demtype", String(args.demtype)) if (args.south != null) query.append("south", String(args.south)) if (args.north != null) query.append("north", String(args.north)) if (args.west != null) query.append("west", String(args.west)) if (args.east != null) query.append("east", String(args.east)) if (args.outputFormat != null) query.append("outputFormat", String(args.outputFormat)) if (args.API_Key != null) query.append("API_Key", String(args.API_Key)) const url = `${baseUrl.replace(/\/+$/, '')}/globaldem${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 undefined };