cog-tiler-wasm 0.2.4 → 0.2.6
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/cog-tiler.d.ts +2 -2
- package/cog-tiler.js +19 -7
- package/cog_tiler_wasm_bg.wasm +0 -0
- package/package.json +2 -2
package/cog-tiler.d.ts
CHANGED
|
@@ -124,8 +124,8 @@ export declare function init(): Promise<unknown>;
|
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
126
|
* Open a COG and return a {@link CogSource} ready to render XYZ tiles. Pass a URL
|
|
127
|
-
* string (read via HTTP range)
|
|
128
|
-
*
|
|
127
|
+
* string (read via HTTP range), a Blob / File (read via ranged slices, so
|
|
128
|
+
* multi-GB local rasters never load whole), or in-memory bytes.
|
|
129
129
|
*/
|
|
130
130
|
export declare function openCog(source: string | ArrayBuffer | Uint8Array | Blob): Promise<CogSource>;
|
|
131
131
|
|
package/cog-tiler.js
CHANGED
|
@@ -240,18 +240,29 @@ function sampleWindowBilinear(buf, w, h, fc, fr) {
|
|
|
240
240
|
return top + (bot - top) * ty;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
// Build a byte reader from a URL string or an in-memory source
|
|
244
|
-
//
|
|
243
|
+
// Build a byte reader from a URL string, a Blob/File, or an in-memory source
|
|
244
|
+
// (ArrayBuffer, Uint8Array). `range(a,b)` yields bytes [a..b]; `openTiff()`
|
|
245
245
|
// returns a geotiff.js GeoTIFF for reading the CRS / color table from the header.
|
|
246
246
|
async function makeReader(source) {
|
|
247
247
|
if (typeof source === "string") {
|
|
248
248
|
return { label: source, range: rangeFetcher(source), openTiff: () => GeoTIFF.fromUrl(source) };
|
|
249
249
|
}
|
|
250
|
+
// Blob / File: read on demand via ranged slices, mirroring the URL path.
|
|
251
|
+
// Slurping the whole file (blob.arrayBuffer()) throws NotReadableError in
|
|
252
|
+
// Chromium for multi-GB rasters (e.g. the 7 GB GEBCO GeoTIFF) — and only the
|
|
253
|
+
// header prefix and the requested tiles are ever needed.
|
|
254
|
+
if (typeof Blob !== "undefined" && source instanceof Blob) {
|
|
255
|
+
return {
|
|
256
|
+
label: source.name || "(local file)",
|
|
257
|
+
range: async (a, b) => new Uint8Array(await source.slice(a, b + 1).arrayBuffer()),
|
|
258
|
+
openTiff: () => GeoTIFF.fromBlob(source),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
250
261
|
let bytes;
|
|
251
262
|
if (source instanceof Uint8Array) bytes = source;
|
|
252
263
|
else if (source instanceof ArrayBuffer) bytes = new Uint8Array(source);
|
|
253
264
|
else if (source && typeof source.arrayBuffer === "function") {
|
|
254
|
-
bytes = new Uint8Array(await source.arrayBuffer()); // Blob
|
|
265
|
+
bytes = new Uint8Array(await source.arrayBuffer()); // exotic Blob-likes
|
|
255
266
|
} else {
|
|
256
267
|
throw new Error("openCog: expected a URL string, ArrayBuffer, Uint8Array, or Blob");
|
|
257
268
|
}
|
|
@@ -270,10 +281,11 @@ async function makeReader(source) {
|
|
|
270
281
|
|
|
271
282
|
/**
|
|
272
283
|
* Open a COG and return a {@link CogSource} ready to render XYZ tiles. `source`
|
|
273
|
-
* is a URL string (read via HTTP range)
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
* whitebox-wasm 0.4.0
|
|
284
|
+
* is a URL string (read via HTTP range), a Blob / File (read via ranged slices,
|
|
285
|
+
* so multi-GB local rasters never load whole), or in-memory bytes. Detects
|
|
286
|
+
* EPSG:3857 (fast path) vs. any other CRS (warp path), reading the source
|
|
287
|
+
* projection + color table from the GeoTIFF header (which whitebox-wasm 0.4.0
|
|
288
|
+
* does not expose).
|
|
277
289
|
*/
|
|
278
290
|
export async function openCog(source) {
|
|
279
291
|
await init();
|
package/cog_tiler_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"Qiusheng Wu <giswqs@gmail.com>"
|
|
6
6
|
],
|
|
7
7
|
"description": "Serverless Cloud Optimized GeoTIFF (COG) dynamic tiling in WebAssembly. TiTiler-style XYZ tiles, no backend.",
|
|
8
|
-
"version": "0.2.
|
|
8
|
+
"version": "0.2.6",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"whitebox-wasm": "^0.4.
|
|
40
|
+
"whitebox-wasm": "^0.4.1",
|
|
41
41
|
"proj4": "^2.15.0",
|
|
42
42
|
"geotiff": "^2.1.0 || ^3.0.0",
|
|
43
43
|
"geotiff-geokeys-to-proj4": "^2024.4.13"
|