geolibre-wasm 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -65,10 +65,87 @@ const { exitCode, stdout, files } = await runTool("slope", {
65
65
  const slopeCog = files["slope.tif"]; // Uint8Array (Cloud Optimized GeoTIFF)
66
66
  ```
67
67
 
68
+ COG subsets can be extracted from a local file or an HTTP source. HTTP sources
69
+ use byte-range requests and do not download the full object:
70
+
71
+ ```js
72
+ const { files } = await runTool("extract_cog_subset", {
73
+ args: [
74
+ "--url=https://example.com/scene.cog.tif",
75
+ "--bbox=-122.55,37.70,-122.35,37.84",
76
+ "--bbox_crs=4326",
77
+ "--output_crs=3857",
78
+ "--resolution=10",
79
+ "--nodata=-9999",
80
+ "--output=/work/subset.tif",
81
+ ],
82
+ });
83
+ const subsetCog = files["subset.tif"];
84
+ ```
85
+
86
+ WMS subsets can be requested from a GetMap endpoint that supports GeoTIFF
87
+ responses:
88
+
89
+ ```js
90
+ const { files } = await runTool("extract_wms_subset", {
91
+ args: [
92
+ "--url=https://example.com/geoserver/wms",
93
+ "--layers=workspace:layer",
94
+ "--bbox=-122.55,37.70,-122.35,37.84",
95
+ "--bbox_crs=4326",
96
+ "--resolution=0.0001",
97
+ "--format=image/geotiff",
98
+ "--output=/work/wms_subset.tif",
99
+ ],
100
+ });
101
+ ```
102
+
103
+ XYZ tile subsets can be mosaicked from raster tiles and written as an RGB COG:
104
+
105
+ ```js
106
+ const { files } = await runTool("extract_xyz_tile_subset", {
107
+ args: [
108
+ "--url=https://tile.openstreetmap.org/{z}/{x}/{y}.png",
109
+ "--zoom=10",
110
+ "--bbox=-122.55,37.70,-122.35,37.84",
111
+ "--bbox_crs=4326",
112
+ "--width=512",
113
+ "--height=512",
114
+ "--output=/work/xyz_subset.tif",
115
+ ],
116
+ });
117
+ ```
118
+
119
+ For a local COG, upload/provide bytes through `input` and point `--input` at
120
+ the `/work` path:
121
+
122
+ ```js
123
+ const { files } = await runTool("extract_cog_subset", {
124
+ args: [
125
+ "--input=/work/local.cog.tif",
126
+ "--bbox=-122.55,37.70,-122.35,37.84",
127
+ "--bbox_crs=4326",
128
+ "--output=/work/subset.tif",
129
+ ],
130
+ input: { "local.cog.tif": localCogBytes },
131
+ });
132
+ ```
133
+
68
134
  Inputs are placed under `/work` (keyed by filename); any file a tool writes is
69
135
  returned in `files`. Raster outputs are Cloud Optimized GeoTIFFs; vector outputs
70
136
  are GeoJSON.
71
137
 
138
+ When `output_crs` is set, `resolution` is interpreted in output CRS units and
139
+ the subset is reprojected with nearest-neighbor resampling. Without
140
+ `output_crs`, the output usually stays on the source COG grid. Sources with
141
+ user-defined projection strings that cannot be written as EPSG metadata, such as
142
+ the NLCD sample, default to `bbox_crs` output so GIS viewers can place the
143
+ result. Outputs are Deflate-compressed by default. `nodata` overrides the output
144
+ nodata metadata and is used to fill pixels introduced during reprojection.
145
+ The subset writer preserves the source sample type for supported COG types
146
+ (`uint8`, `float32`, and `float64`); palette-indexed `uint8` rasters retain
147
+ their source ColorMap.
148
+
72
149
  ## API
73
150
 
74
151
  | Export | Description |
@@ -77,6 +154,9 @@ are GeoJSON.
77
154
  | `listTools(): Promise<string[]>` | Every available tool id. |
78
155
  | `listManifests(): Promise<ToolManifest[]>` | All tool manifests (parameter schemas), for building UIs offline. |
79
156
  | `runTool(tool, { args?, input? }): Promise<ToolResult>` | Run one tool over the in-memory filesystem. |
157
+ | `extractCogSubset(source, opts): Promise<Uint8Array>` | Extract a local or HTTP COG subset directly. |
158
+ | `extractWmsSubset(url, opts): Promise<Uint8Array>` | Request a WMS GeoTIFF subset and encode it as a COG. |
159
+ | `extractXyzTileSubset(url, opts): Promise<Uint8Array>` | Mosaic XYZ raster tiles and encode them as an RGB COG. |
80
160
 
81
161
  `ToolResult` is `{ exitCode: number, stdout: string[], files: Record<string, Uint8Array> }`.
82
162
 
package/geolibre-cli.wasm CHANGED
Binary file
@@ -79,6 +79,14 @@ export class CogBuilder {
79
79
  export class CogStream {
80
80
  free(): void;
81
81
  [Symbol.dispose](): void;
82
+ /**
83
+ * Reproject a bbox from `bbox_epsg` into this COG's dataset CRS.
84
+ *
85
+ * The COG projection string is preferred over its EPSG tag when available,
86
+ * because some user-defined projected GeoTIFFs expose only their geographic
87
+ * base EPSG code.
88
+ */
89
+ bbox_to_dataset_crs(bbox_epsg: number, bbox: Float64Array): Float64Array;
82
90
  /**
83
91
  * Bounding box `[min_x, min_y, max_x, max_y]` in the dataset CRS, or empty.
84
92
  */
@@ -115,6 +123,14 @@ export class CogStream {
115
123
  * Parse a COG's tile layout from front-of-file header bytes.
116
124
  */
117
125
  constructor(header_bytes: Uint8Array);
126
+ /**
127
+ * Reproject x,y coordinate pairs from this COG's dataset CRS to an EPSG CRS.
128
+ */
129
+ points_from_dataset_crs(dst_epsg: number, xy: Float64Array): Float64Array;
130
+ /**
131
+ * Reproject x,y coordinate pairs from an EPSG CRS into this COG's dataset CRS.
132
+ */
133
+ points_to_dataset_crs(src_epsg: number, xy: Float64Array): Float64Array;
118
134
  /**
119
135
  * `[offset, length]` byte range of the tile at `(col, row)` on `level`.
120
136
  */
@@ -128,6 +144,10 @@ export class CogStream {
128
144
  * EPSG code of the full-resolution level, if any.
129
145
  */
130
146
  readonly epsg: number | undefined;
147
+ /**
148
+ * True when the COG CRS is represented by a user-defined projection string.
149
+ */
150
+ readonly has_projection_string: boolean;
131
151
  /**
132
152
  * No-data sentinel, if declared.
133
153
  */
@@ -319,6 +339,20 @@ export function lidar_read_xyz(data: Uint8Array, format: string): Float64Array;
319
339
  */
320
340
  export function morans_i(points_xy: Float64Array, values: Float64Array, distance_threshold: number): string;
321
341
 
342
+ /**
343
+ * Reproject a bbox between two EPSG CRSs.
344
+ *
345
+ * Input and output order is `[min_x, min_y, max_x, max_y]`. The bbox edges are
346
+ * densified so projected extrema that fall along an edge are preserved better
347
+ * than a corner-only transform.
348
+ */
349
+ export function transform_bbox_epsg(src_epsg: number, dst_epsg: number, bbox: Float64Array): Float64Array;
350
+
351
+ /**
352
+ * Reproject x,y coordinate pairs between two EPSG CRSs.
353
+ */
354
+ export function transform_points_epsg(src_epsg: number, dst_epsg: number, xy: Float64Array): Float64Array;
355
+
322
356
  /**
323
357
  * Vector formats this build can read from memory (comma-separated).
324
358
  */
@@ -370,6 +404,7 @@ export interface InitOutput {
370
404
  readonly cogbuilder_write_f32: (a: number, b: number, c: number, d: number) => void;
371
405
  readonly cogbuilder_write_f64: (a: number, b: number, c: number, d: number) => void;
372
406
  readonly cogbuilder_write_u8: (a: number, b: number, c: number, d: number) => void;
407
+ readonly cogstream_bbox_to_dataset_crs: (a: number, b: number, c: number, d: number, e: number) => void;
373
408
  readonly cogstream_bounding_box: (a: number, b: number) => void;
374
409
  readonly cogstream_bounds_lonlat: (a: number, b: number) => void;
375
410
  readonly cogstream_center: (a: number, b: number) => void;
@@ -377,10 +412,13 @@ export interface InitOutput {
377
412
  readonly cogstream_decode_tile_f64: (a: number, b: number, c: number, d: number, e: number) => void;
378
413
  readonly cogstream_epsg: (a: number) => number;
379
414
  readonly cogstream_geo_transform: (a: number, b: number) => void;
415
+ readonly cogstream_has_projection_string: (a: number) => number;
380
416
  readonly cogstream_levels_json: (a: number, b: number) => void;
381
417
  readonly cogstream_new: (a: number, b: number, c: number) => void;
382
418
  readonly cogstream_nodata: (a: number, b: number) => void;
383
419
  readonly cogstream_num_levels: (a: number) => number;
420
+ readonly cogstream_points_from_dataset_crs: (a: number, b: number, c: number, d: number, e: number) => void;
421
+ readonly cogstream_points_to_dataset_crs: (a: number, b: number, c: number, d: number, e: number) => void;
384
422
  readonly cogstream_tile_range: (a: number, b: number, c: number, d: number, e: number) => void;
385
423
  readonly cogstream_tiles_for_window: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
386
424
  readonly convex_hull: (a: number, b: number, c: number) => void;
@@ -421,6 +459,8 @@ export interface InitOutput {
421
459
  readonly lidar_read_intensity: (a: number, b: number, c: number, d: number, e: number) => void;
422
460
  readonly lidar_read_xyz: (a: number, b: number, c: number, d: number, e: number) => void;
423
461
  readonly morans_i: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
462
+ readonly transform_bbox_epsg: (a: number, b: number, c: number, d: number, e: number) => void;
463
+ readonly transform_points_epsg: (a: number, b: number, c: number, d: number, e: number) => void;
424
464
  readonly vector_formats: (a: number) => void;
425
465
  readonly vector_info: (a: number, b: number, c: number, d: number, e: number) => void;
426
466
  readonly vector_to_geojson: (a: number, b: number, c: number, d: number, e: number) => void;
package/geolibre_wasm.js CHANGED
@@ -218,6 +218,36 @@ export class CogStream {
218
218
  const ptr = this.__destroy_into_raw();
219
219
  wasm.__wbg_cogstream_free(ptr, 0);
220
220
  }
221
+ /**
222
+ * Reproject a bbox from `bbox_epsg` into this COG's dataset CRS.
223
+ *
224
+ * The COG projection string is preferred over its EPSG tag when available,
225
+ * because some user-defined projected GeoTIFFs expose only their geographic
226
+ * base EPSG code.
227
+ * @param {number} bbox_epsg
228
+ * @param {Float64Array} bbox
229
+ * @returns {Float64Array}
230
+ */
231
+ bbox_to_dataset_crs(bbox_epsg, bbox) {
232
+ try {
233
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
234
+ const ptr0 = passArrayF64ToWasm0(bbox, wasm.__wbindgen_export2);
235
+ const len0 = WASM_VECTOR_LEN;
236
+ wasm.cogstream_bbox_to_dataset_crs(retptr, this.__wbg_ptr, bbox_epsg, ptr0, len0);
237
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
238
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
239
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
240
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
241
+ if (r3) {
242
+ throw takeObject(r2);
243
+ }
244
+ var v2 = getArrayF64FromWasm0(r0, r1).slice();
245
+ wasm.__wbindgen_export(r0, r1 * 8, 8);
246
+ return v2;
247
+ } finally {
248
+ wasm.__wbindgen_add_to_stack_pointer(16);
249
+ }
250
+ }
221
251
  /**
222
252
  * Bounding box `[min_x, min_y, max_x, max_y]` in the dataset CRS, or empty.
223
253
  * @returns {Float64Array}
@@ -340,6 +370,14 @@ export class CogStream {
340
370
  wasm.__wbindgen_add_to_stack_pointer(16);
341
371
  }
342
372
  }
373
+ /**
374
+ * True when the COG CRS is represented by a user-defined projection string.
375
+ * @returns {boolean}
376
+ */
377
+ get has_projection_string() {
378
+ const ret = wasm.cogstream_has_projection_string(this.__wbg_ptr);
379
+ return ret !== 0;
380
+ }
343
381
  /**
344
382
  * JSON array describing every level: `[{level,width,height,tile_width,
345
383
  * tile_height,tiles_x,tiles_y,bands,bits_per_sample,sample_format,compression}]`.
@@ -407,6 +445,58 @@ export class CogStream {
407
445
  const ret = wasm.cogstream_num_levels(this.__wbg_ptr);
408
446
  return ret >>> 0;
409
447
  }
448
+ /**
449
+ * Reproject x,y coordinate pairs from this COG's dataset CRS to an EPSG CRS.
450
+ * @param {number} dst_epsg
451
+ * @param {Float64Array} xy
452
+ * @returns {Float64Array}
453
+ */
454
+ points_from_dataset_crs(dst_epsg, xy) {
455
+ try {
456
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
457
+ const ptr0 = passArrayF64ToWasm0(xy, wasm.__wbindgen_export2);
458
+ const len0 = WASM_VECTOR_LEN;
459
+ wasm.cogstream_points_from_dataset_crs(retptr, this.__wbg_ptr, dst_epsg, ptr0, len0);
460
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
461
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
462
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
463
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
464
+ if (r3) {
465
+ throw takeObject(r2);
466
+ }
467
+ var v2 = getArrayF64FromWasm0(r0, r1).slice();
468
+ wasm.__wbindgen_export(r0, r1 * 8, 8);
469
+ return v2;
470
+ } finally {
471
+ wasm.__wbindgen_add_to_stack_pointer(16);
472
+ }
473
+ }
474
+ /**
475
+ * Reproject x,y coordinate pairs from an EPSG CRS into this COG's dataset CRS.
476
+ * @param {number} src_epsg
477
+ * @param {Float64Array} xy
478
+ * @returns {Float64Array}
479
+ */
480
+ points_to_dataset_crs(src_epsg, xy) {
481
+ try {
482
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
483
+ const ptr0 = passArrayF64ToWasm0(xy, wasm.__wbindgen_export2);
484
+ const len0 = WASM_VECTOR_LEN;
485
+ wasm.cogstream_points_to_dataset_crs(retptr, this.__wbg_ptr, src_epsg, ptr0, len0);
486
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
487
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
488
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
489
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
490
+ if (r3) {
491
+ throw takeObject(r2);
492
+ }
493
+ var v2 = getArrayF64FromWasm0(r0, r1).slice();
494
+ wasm.__wbindgen_export(r0, r1 * 8, 8);
495
+ return v2;
496
+ } finally {
497
+ wasm.__wbindgen_add_to_stack_pointer(16);
498
+ }
499
+ }
410
500
  /**
411
501
  * `[offset, length]` byte range of the tile at `(col, row)` on `level`.
412
502
  * @param {number} level
@@ -1290,6 +1380,66 @@ export function morans_i(points_xy, values, distance_threshold) {
1290
1380
  }
1291
1381
  }
1292
1382
 
1383
+ /**
1384
+ * Reproject a bbox between two EPSG CRSs.
1385
+ *
1386
+ * Input and output order is `[min_x, min_y, max_x, max_y]`. The bbox edges are
1387
+ * densified so projected extrema that fall along an edge are preserved better
1388
+ * than a corner-only transform.
1389
+ * @param {number} src_epsg
1390
+ * @param {number} dst_epsg
1391
+ * @param {Float64Array} bbox
1392
+ * @returns {Float64Array}
1393
+ */
1394
+ export function transform_bbox_epsg(src_epsg, dst_epsg, bbox) {
1395
+ try {
1396
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1397
+ const ptr0 = passArrayF64ToWasm0(bbox, wasm.__wbindgen_export2);
1398
+ const len0 = WASM_VECTOR_LEN;
1399
+ wasm.transform_bbox_epsg(retptr, src_epsg, dst_epsg, ptr0, len0);
1400
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1401
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1402
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1403
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1404
+ if (r3) {
1405
+ throw takeObject(r2);
1406
+ }
1407
+ var v2 = getArrayF64FromWasm0(r0, r1).slice();
1408
+ wasm.__wbindgen_export(r0, r1 * 8, 8);
1409
+ return v2;
1410
+ } finally {
1411
+ wasm.__wbindgen_add_to_stack_pointer(16);
1412
+ }
1413
+ }
1414
+
1415
+ /**
1416
+ * Reproject x,y coordinate pairs between two EPSG CRSs.
1417
+ * @param {number} src_epsg
1418
+ * @param {number} dst_epsg
1419
+ * @param {Float64Array} xy
1420
+ * @returns {Float64Array}
1421
+ */
1422
+ export function transform_points_epsg(src_epsg, dst_epsg, xy) {
1423
+ try {
1424
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1425
+ const ptr0 = passArrayF64ToWasm0(xy, wasm.__wbindgen_export2);
1426
+ const len0 = WASM_VECTOR_LEN;
1427
+ wasm.transform_points_epsg(retptr, src_epsg, dst_epsg, ptr0, len0);
1428
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1429
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1430
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1431
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1432
+ if (r3) {
1433
+ throw takeObject(r2);
1434
+ }
1435
+ var v2 = getArrayF64FromWasm0(r0, r1).slice();
1436
+ wasm.__wbindgen_export(r0, r1 * 8, 8);
1437
+ return v2;
1438
+ } finally {
1439
+ wasm.__wbindgen_add_to_stack_pointer(16);
1440
+ }
1441
+ }
1442
+
1293
1443
  /**
1294
1444
  * Vector formats this build can read from memory (comma-separated).
1295
1445
  * @returns {string}
Binary file
@@ -17,6 +17,7 @@ export const cogbuilder_set_tile_size: (a: number, b: number) => void;
17
17
  export const cogbuilder_write_f32: (a: number, b: number, c: number, d: number) => void;
18
18
  export const cogbuilder_write_f64: (a: number, b: number, c: number, d: number) => void;
19
19
  export const cogbuilder_write_u8: (a: number, b: number, c: number, d: number) => void;
20
+ export const cogstream_bbox_to_dataset_crs: (a: number, b: number, c: number, d: number, e: number) => void;
20
21
  export const cogstream_bounding_box: (a: number, b: number) => void;
21
22
  export const cogstream_bounds_lonlat: (a: number, b: number) => void;
22
23
  export const cogstream_center: (a: number, b: number) => void;
@@ -24,10 +25,13 @@ export const cogstream_center_lonlat: (a: number, b: number) => void;
24
25
  export const cogstream_decode_tile_f64: (a: number, b: number, c: number, d: number, e: number) => void;
25
26
  export const cogstream_epsg: (a: number) => number;
26
27
  export const cogstream_geo_transform: (a: number, b: number) => void;
28
+ export const cogstream_has_projection_string: (a: number) => number;
27
29
  export const cogstream_levels_json: (a: number, b: number) => void;
28
30
  export const cogstream_new: (a: number, b: number, c: number) => void;
29
31
  export const cogstream_nodata: (a: number, b: number) => void;
30
32
  export const cogstream_num_levels: (a: number) => number;
33
+ export const cogstream_points_from_dataset_crs: (a: number, b: number, c: number, d: number, e: number) => void;
34
+ export const cogstream_points_to_dataset_crs: (a: number, b: number, c: number, d: number, e: number) => void;
31
35
  export const cogstream_tile_range: (a: number, b: number, c: number, d: number, e: number) => void;
32
36
  export const cogstream_tiles_for_window: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
33
37
  export const convex_hull: (a: number, b: number, c: number) => void;
@@ -68,6 +72,8 @@ export const lidar_read_classification: (a: number, b: number, c: number, d: num
68
72
  export const lidar_read_intensity: (a: number, b: number, c: number, d: number, e: number) => void;
69
73
  export const lidar_read_xyz: (a: number, b: number, c: number, d: number, e: number) => void;
70
74
  export const morans_i: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
75
+ export const transform_bbox_epsg: (a: number, b: number, c: number, d: number, e: number) => void;
76
+ export const transform_points_epsg: (a: number, b: number, c: number, d: number, e: number) => void;
71
77
  export const vector_formats: (a: number) => void;
72
78
  export const vector_info: (a: number, b: number, c: number, d: number, e: number) => void;
73
79
  export const vector_to_geojson: (a: number, b: number, c: number, d: number, e: number) => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "geolibre-wasm",
3
3
  "type": "module",
4
- "version": "0.5.3",
4
+ "version": "0.6.0",
5
5
  "description": "Pure-Rust geospatial toolkit (whitebox_next_gen) compiled to WebAssembly (WASI) for GeoLibre's in-browser tool execution",
6
6
  "license": "MIT",
7
7
  "repository": {
package/tools.d.ts CHANGED
@@ -19,6 +19,79 @@ export interface RunToolOptions {
19
19
  input?: Record<string, Uint8Array | ArrayBuffer | string>;
20
20
  }
21
21
 
22
+ export interface ExtractCogSubsetOptions {
23
+ /** Bounding box as [minX, minY, maxX, maxY]. */
24
+ bbox: [number, number, number, number];
25
+ /** EPSG code of bbox coordinates. */
26
+ bboxCrs: number;
27
+ /** COG overview level to read. Level 0 is full resolution. */
28
+ level?: number;
29
+ /** Target output pixel size in outputCrs units when outputCrs is set; otherwise bboxCrs units. */
30
+ resolution?: number;
31
+ /** Optional output EPSG code. User-defined source CRSs default to bboxCrs output when omitted. */
32
+ outputCrs?: number;
33
+ /** Optional output nodata value. Used as reprojection fill and output nodata metadata. */
34
+ nodata?: number;
35
+ /** Extra fetch options used for header and tile range requests. */
36
+ fetchOptions?: RequestInit;
37
+ /** Initial COG header prefix size in bytes. Default 262144. */
38
+ initialHeaderBytes?: number;
39
+ /** Maximum COG header prefix size in bytes. Default 8388608. */
40
+ maxHeaderBytes?: number;
41
+ }
42
+
43
+ export interface ExtractWmsSubsetOptions {
44
+ /** WMS layer name(s), comma-separated. */
45
+ layers: string;
46
+ /** WMS style name(s), comma-separated. */
47
+ styles?: string;
48
+ /** Bounding box as [minX, minY, maxX, maxY]. */
49
+ bbox: [number, number, number, number];
50
+ /** EPSG code of bbox coordinates. */
51
+ bboxCrs: number;
52
+ /** Target output pixel size in output CRS units. */
53
+ resolution?: number;
54
+ /** Request width in pixels; used when resolution is omitted. */
55
+ width?: number;
56
+ /** Request height in pixels; used when resolution is omitted. */
57
+ height?: number;
58
+ /** Optional output/request EPSG code. Defaults to bboxCrs. */
59
+ outputCrs?: number;
60
+ /** WMS image format. Defaults to image/geotiff. */
61
+ format?: string;
62
+ /** WMS version. Defaults to 1.1.1. */
63
+ version?: string;
64
+ /** Optional output nodata value. */
65
+ nodata?: number;
66
+ /** Extra fetch options used for the GetMap request. */
67
+ fetchOptions?: RequestInit;
68
+ }
69
+
70
+ export interface ExtractXyzTileSubsetOptions {
71
+ /** XYZ zoom level. */
72
+ zoom: number;
73
+ /** Bounding box as [minX, minY, maxX, maxY]. */
74
+ bbox: [number, number, number, number];
75
+ /** EPSG code of bbox coordinates. */
76
+ bboxCrs: number;
77
+ /** Target output pixel size in output CRS units. */
78
+ resolution?: number;
79
+ /** Output width in pixels; used when resolution is omitted. */
80
+ width?: number;
81
+ /** Output height in pixels; used when resolution is omitted. */
82
+ height?: number;
83
+ /** Optional output EPSG code. Defaults to bboxCrs. */
84
+ outputCrs?: number;
85
+ /** Tile size in pixels. Defaults to 256. */
86
+ tileSize?: number;
87
+ /** Optional subdomain letters for {s}. */
88
+ subdomains?: string;
89
+ /** Optional output nodata/fill value. */
90
+ nodata?: number;
91
+ /** Extra fetch options used for tile requests. */
92
+ fetchOptions?: RequestInit;
93
+ }
94
+
22
95
  /** A single parameter in a tool manifest. */
23
96
  export interface ToolParam {
24
97
  name: string;
@@ -46,3 +119,21 @@ export function listManifests(): Promise<ToolManifest[]>;
46
119
 
47
120
  /** Run one tool over an in-memory filesystem. */
48
121
  export function runTool(tool: string, opts?: RunToolOptions): Promise<ToolResult>;
122
+
123
+ /** Extract a bbox subset from a local COG or HTTP COG. HTTP sources use byte-range requests. */
124
+ export function extractCogSubset(
125
+ source: string | Uint8Array | ArrayBuffer,
126
+ opts: ExtractCogSubsetOptions,
127
+ ): Promise<Uint8Array>;
128
+
129
+ /** Request a bbox subset from a WMS GetMap endpoint and write it as a Deflate COG. */
130
+ export function extractWmsSubset(
131
+ url: string,
132
+ opts: ExtractWmsSubsetOptions,
133
+ ): Promise<Uint8Array>;
134
+
135
+ /** Fetch XYZ raster tiles for a bbox, mosaic them, and write a Deflate RGB COG. */
136
+ export function extractXyzTileSubset(
137
+ url: string,
138
+ opts: ExtractXyzTileSubsetOptions,
139
+ ): Promise<Uint8Array>;