export type GetApiUsgsdemArgs = {datasetName: 'USGS30m' | 'USGS10m' | 'USGS1m', south: number, north: number, west: number, east: number, outputFormat?: ('GTiff' | 'AAIGrid' | 'HFA') | undefined, API_Key: string}; export type GetApiUsgsdemOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Access U.S. Geological Survey 3DEP raster datasets including 1m, 1/3 arc-second (10m), 1 arc-second (30m) Digital Elevation Model. Note: 1m DEM is currently restricted to academic users. Requests are limited to 225,000 km² for USGS30m, 25,000 km² for USGS10m, 250 km² for USGS1m data. This API service relies on USGS resources. OpenTopography does not control the availability or performance of this service. * * GET /usgsdem */ export const getApiUsgsdem = async (args: GetApiUsgsdemArgs, options: GetApiUsgsdemOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.datasetName != null) query.append("datasetName", String(args.datasetName)) 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(/\/+$/, '')}/usgsdem${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 };