maplibre-gl-components 0.16.2 → 0.17.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 +4 -3
- package/dist/{ControlGrid-DQ4w_Nf9.js → ControlGrid-C6zp03Vq.js} +125375 -115454
- package/dist/ControlGrid-DIAcXRBe.cjs +17278 -0
- package/dist/DuckDBConverter-5a2FWwmf.js +354 -0
- package/dist/DuckDBConverter-pfXSUi_l.cjs +23 -0
- package/dist/ShapefileConverter-DGCXPY_S.cjs +1 -0
- package/dist/ShapefileConverter-DN3fVOuo.js +102 -0
- package/dist/basedecoder-BliCKuUS.js +62 -0
- package/dist/basedecoder-Zw0CbD9L.cjs +1 -0
- package/dist/deflate-DBL0msKQ.js +10 -0
- package/dist/deflate-DNeBKDsy.cjs +1 -0
- package/dist/esm-Bp6m44bk.js +811 -0
- package/dist/esm-oEp_aN1n.cjs +1 -0
- package/dist/geojson-Bnoe76Pm.js +2002 -0
- package/dist/geojson-CxMdRvJX.cjs +1 -0
- package/dist/geotiff-Bzy-Zyc2.js +1882 -0
- package/dist/geotiff-DYylEFA9.cjs +8 -0
- package/dist/globals-B4iCNAg9.cjs +1 -0
- package/dist/globals-BKIWameS.js +572 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +150 -147
- package/dist/jpeg-B6Sg6W8k.cjs +1 -0
- package/dist/jpeg-CJcNvScS.js +545 -0
- package/dist/lerc-2QwcA_K7.js +840 -0
- package/dist/lerc-DQRITnja.cjs +1 -0
- package/dist/lib-B4jvG7hB.cjs +4 -0
- package/dist/lib-CNQtqzfc.js +4060 -0
- package/dist/lzw-1HaU0PJK.cjs +1 -0
- package/dist/lzw-DF5VHuii.js +76 -0
- package/dist/main-dist-CbHNdsir.js +18314 -0
- package/dist/main-dist-DOx_Axbx.cjs +2 -0
- package/dist/maplibre-geoman.es-C0F1ydoG.cjs +213 -0
- package/dist/maplibre-geoman.es-D1CztSQd.js +27213 -0
- package/dist/maplibre-gl-components.css +2 -1
- package/dist/packbits-CK8RPU_B.js +22 -0
- package/dist/packbits-D5Zovac7.cjs +1 -0
- package/dist/pako.esm-DFyPB7cO.cjs +1 -0
- package/dist/pako.esm-hTfpTBhd.js +1536 -0
- package/dist/raw-Brljg6vy.js +9 -0
- package/dist/raw-C-CSxCoU.cjs +1 -0
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +1357 -1004
- package/dist/{types → src}/lib/core/CogLayer.d.ts.map +1 -1
- package/dist/{types → src}/lib/core/PMTilesLayer.d.ts.map +1 -1
- package/dist/{types → src}/lib/core/SpinGlobeControl.d.ts +6 -7
- package/dist/src/lib/core/SpinGlobeControl.d.ts.map +1 -0
- package/dist/{types → src}/lib/core/StacLayer.d.ts.map +1 -1
- package/dist/{types → src}/lib/core/types.d.ts +3 -1
- package/dist/{types → src}/lib/core/types.d.ts.map +1 -1
- package/dist/{types → src}/lib/utils/color.d.ts +8 -0
- package/dist/src/lib/utils/color.d.ts.map +1 -0
- package/dist/{types → src}/lib/utils/index.d.ts +1 -1
- package/dist/{types → src}/lib/utils/index.d.ts.map +1 -1
- package/dist/webimage-Bh2pNwjN.cjs +1 -0
- package/dist/webimage-rg-Z9Sbn.js +25 -0
- package/dist/zstd-B3Xa90HD.cjs +1 -0
- package/dist/zstd-BwwN0X3K.js +51 -0
- package/package.json +66 -53
- package/dist/ControlGrid-Bukna_at.cjs +0 -17062
- package/dist/DuckDBConverter-B98M0DFs.cjs +0 -23
- package/dist/DuckDBConverter-RPq48-t0.js +0 -434
- package/dist/ShapefileConverter-AjbEjEyq.cjs +0 -1
- package/dist/ShapefileConverter-trvt8J3z.js +0 -125
- package/dist/decoder-CLokFc0V.js +0 -8
- package/dist/decoder-D9LU4bUo.cjs +0 -1
- package/dist/deflate-Bay-vzHJ.cjs +0 -1
- package/dist/deflate-yeu3ogBn.js +0 -10
- package/dist/geojson-BQSVgKFt.cjs +0 -1
- package/dist/geojson-BSUuDj5k.js +0 -2551
- package/dist/geotiff-BNxc90fm.cjs +0 -8
- package/dist/geotiff-BUZniE5g.js +0 -3105
- package/dist/index-8ZZtuDTp.js +0 -705
- package/dist/index-DQXdX5y1.js +0 -4666
- package/dist/index-Dh1kpCb6.cjs +0 -1
- package/dist/index-IrsIiQNM.cjs +0 -4
- package/dist/jpeg-B7yImnpY.js +0 -533
- package/dist/jpeg-BiN8bMT5.cjs +0 -1
- package/dist/lerc-BvSjGMM2.cjs +0 -1
- package/dist/lerc-CqgA9njy.js +0 -1031
- package/dist/lzw-C-_B7Jis.cjs +0 -1
- package/dist/lzw-DL9RcHOz.js +0 -84
- package/dist/main-dist-Bymiy5aM.cjs +0 -2
- package/dist/main-dist-Cv8AKwrY.js +0 -629
- package/dist/maplibre-geoman.es-Bxdg-2EU.cjs +0 -129
- package/dist/maplibre-geoman.es-CFgM2ajb.js +0 -22827
- package/dist/packbits-DRGSjtn-.cjs +0 -1
- package/dist/packbits-YEJGULcy.js +0 -24
- package/dist/pako.esm-Bx5X36Wo.js +0 -1074
- package/dist/pako.esm-DZC2QrbJ.cjs +0 -1
- package/dist/raw-CoQHiEnn.js +0 -9
- package/dist/raw-D6OidBKc.cjs +0 -1
- package/dist/types/lib/core/SpinGlobeControl.d.ts.map +0 -1
- package/dist/types/lib/utils/color.d.ts.map +0 -1
- package/dist/webimage-BXLN-zu8.js +0 -19
- package/dist/webimage-mWTez3Wv.cjs +0 -1
- /package/dist/{types → src}/index.d.ts +0 -0
- /package/dist/{types → src}/index.d.ts.map +0 -0
- /package/dist/{types → src}/lib/adapters/AddVectorAdapter.d.ts +0 -0
- /package/dist/{types → src}/lib/adapters/AddVectorAdapter.d.ts.map +0 -0
- /package/dist/{types → src}/lib/adapters/CogLayerAdapter.d.ts +0 -0
- /package/dist/{types → src}/lib/adapters/CogLayerAdapter.d.ts.map +0 -0
- /package/dist/{types → src}/lib/adapters/PMTilesLayerAdapter.d.ts +0 -0
- /package/dist/{types → src}/lib/adapters/PMTilesLayerAdapter.d.ts.map +0 -0
- /package/dist/{types → src}/lib/adapters/StacLayerAdapter.d.ts +0 -0
- /package/dist/{types → src}/lib/adapters/StacLayerAdapter.d.ts.map +0 -0
- /package/dist/{types → src}/lib/adapters/ZarrLayerAdapter.d.ts +0 -0
- /package/dist/{types → src}/lib/adapters/ZarrLayerAdapter.d.ts.map +0 -0
- /package/dist/{types → src}/lib/adapters/index.d.ts +0 -0
- /package/dist/{types → src}/lib/adapters/index.d.ts.map +0 -0
- /package/dist/{types → src}/lib/addControlGrid.d.ts +0 -0
- /package/dist/{types → src}/lib/addControlGrid.d.ts.map +0 -0
- /package/dist/{types → src}/lib/colormaps/diverging.d.ts +0 -0
- /package/dist/{types → src}/lib/colormaps/diverging.d.ts.map +0 -0
- /package/dist/{types → src}/lib/colormaps/index.d.ts +0 -0
- /package/dist/{types → src}/lib/colormaps/index.d.ts.map +0 -0
- /package/dist/{types → src}/lib/colormaps/misc.d.ts +0 -0
- /package/dist/{types → src}/lib/colormaps/misc.d.ts.map +0 -0
- /package/dist/{types → src}/lib/colormaps/sequential.d.ts +0 -0
- /package/dist/{types → src}/lib/colormaps/sequential.d.ts.map +0 -0
- /package/dist/{types → src}/lib/converters/DuckDBConverter.d.ts +0 -0
- /package/dist/{types → src}/lib/converters/DuckDBConverter.d.ts.map +0 -0
- /package/dist/{types → src}/lib/converters/ShapefileConverter.d.ts +0 -0
- /package/dist/{types → src}/lib/converters/ShapefileConverter.d.ts.map +0 -0
- /package/dist/{types → src}/lib/converters/index.d.ts +0 -0
- /package/dist/{types → src}/lib/converters/index.d.ts.map +0 -0
- /package/dist/{types → src}/lib/converters/types.d.ts +0 -0
- /package/dist/{types → src}/lib/converters/types.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/AddVector.d.ts +0 -0
- /package/dist/{types → src}/lib/core/AddVector.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/Basemap.d.ts +0 -0
- /package/dist/{types → src}/lib/core/Basemap.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/BasemapReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/BasemapReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/BookmarkControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/BookmarkControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ChoroplethControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ChoroplethControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/CogLayer.d.ts +0 -0
- /package/dist/{types → src}/lib/core/CogLayerReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/CogLayerReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/Colorbar.d.ts +0 -0
- /package/dist/{types → src}/lib/core/Colorbar.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ColorbarGuiControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ColorbarGuiControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ColorbarReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ColorbarReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ControlGrid.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ControlGrid.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ControlGridReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ControlGridReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/HtmlControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/HtmlControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/HtmlControlReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/HtmlControlReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/HtmlGuiControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/HtmlGuiControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/InspectControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/InspectControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/InspectControlReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/InspectControlReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/Legend.d.ts +0 -0
- /package/dist/{types → src}/lib/core/Legend.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/LegendGuiControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/LegendGuiControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/LegendReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/LegendReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/MeasureControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/MeasureControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/MinimapControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/MinimapControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/MinimapControlReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/MinimapControlReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/PMTilesLayer.d.ts +0 -0
- /package/dist/{types → src}/lib/core/PrintControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/PrintControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/SearchControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/SearchControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/SearchControlReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/SearchControlReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/StacLayer.d.ts +0 -0
- /package/dist/{types → src}/lib/core/StacSearch.d.ts +0 -0
- /package/dist/{types → src}/lib/core/StacSearch.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/Terrain.d.ts +0 -0
- /package/dist/{types → src}/lib/core/Terrain.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/TerrainReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/TerrainReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/TileLayerControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/TileLayerControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/VectorDataset.d.ts +0 -0
- /package/dist/{types → src}/lib/core/VectorDataset.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/VectorDatasetReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/VectorDatasetReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ViewStateControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ViewStateControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ViewStateControlReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ViewStateControlReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ZarrLayer.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ZarrLayer.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/index.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/index.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useBasemap.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useBasemap.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useCogLayer.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useCogLayer.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useColorbar.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useColorbar.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useControlGrid.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useControlGrid.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useHtmlControl.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useHtmlControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useInspectControl.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useInspectControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useLegend.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useLegend.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useMinimapControl.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useMinimapControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useSearchControl.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useSearchControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useTerrain.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useTerrain.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useVectorDataset.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useVectorDataset.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useViewState.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useViewState.d.ts.map +0 -0
- /package/dist/{types → src}/lib/utils/fileHelpers.d.ts +0 -0
- /package/dist/{types → src}/lib/utils/fileHelpers.d.ts.map +0 -0
- /package/dist/{types → src}/lib/utils/helpers.d.ts +0 -0
- /package/dist/{types → src}/lib/utils/helpers.d.ts.map +0 -0
- /package/dist/{types → src}/lib/utils/providers.d.ts +0 -0
- /package/dist/{types → src}/lib/utils/providers.d.ts.map +0 -0
- /package/dist/{types → src}/react.d.ts +0 -0
- /package/dist/{types → src}/react.d.ts.map +0 -0
|
@@ -0,0 +1,1882 @@
|
|
|
1
|
+
import { cn as it, on as at } from "./ControlGrid-C6zp03Vq.js";
|
|
2
|
+
import "./basedecoder-BliCKuUS.js";
|
|
3
|
+
import { a as nt, i as y, l as Q, o as G, s as x, t as ot, u as te } from "./globals-BKIWameS.js";
|
|
4
|
+
var lt = "Cannot convert undefined or null to object";
|
|
5
|
+
function A(e) {
|
|
6
|
+
return (t, ...r) => ct(e, t, r);
|
|
7
|
+
}
|
|
8
|
+
function B(e, t) {
|
|
9
|
+
return A(ge(e, t).get);
|
|
10
|
+
}
|
|
11
|
+
var { apply: ct, construct: Nr, defineProperty: Lr, get: Cr, getOwnPropertyDescriptor: ge, getPrototypeOf: se, has: zr, ownKeys: ht, set: Gr, setPrototypeOf: qr } = Reflect, { EPSILON: ft, MAX_SAFE_INTEGER: jr, isFinite: Hr, isNaN: Yr } = Number, { iterator: Y, species: $r, toStringTag: ut, for: Xr } = Symbol, ie = Object, { create: ye, defineProperty: dt, freeze: Kr, is: Zr } = ie, fe = ie.prototype, Jr = fe.__lookupGetter__ ? A(fe.__lookupGetter__) : (e, t) => {
|
|
12
|
+
if (e == null) throw It(lt);
|
|
13
|
+
let r = ie(e);
|
|
14
|
+
do {
|
|
15
|
+
const s = ge(r, t);
|
|
16
|
+
if (s !== void 0)
|
|
17
|
+
return gt(s, "get") ? s.get : void 0;
|
|
18
|
+
} while ((r = se(r)) !== null);
|
|
19
|
+
}, gt = ie.hasOwn || A(fe.hasOwnProperty), De = Array, Qr = De.isArray, ae = De.prototype, Wr = A(ae.join), es = A(ae.push), ts = A(ae.toLocaleString), Oe = ae[Y], yt = A(Oe), { abs: rs, trunc: ss } = Math, pe = ArrayBuffer, is = pe.isView, Re = pe.prototype, as = A(Re.slice), ns = B(Re, "byteLength"), xe = typeof SharedArrayBuffer < "u" ? SharedArrayBuffer : null, os = xe && B(xe.prototype, "byteLength"), Me = se(Uint8Array), ls = Me.from, E = Me.prototype, cs = E[Y], hs = A(E.keys), fs = A(E.values), us = A(E.entries), ds = A(E.set), gs = A(E.reverse), ys = A(E.fill), ps = A(E.copyWithin), ws = A(E.sort), ms = A(E.slice), bs = A(E.subarray), vs = B(E, "buffer"), Is = B(E, "byteOffset"), As = B(E, "length"), Ts = B(E, ut), pt = Uint8Array, Be = Uint16Array, we = Uint32Array, wt = Float32Array, q = se([][Y]()), Ve = A(q.next), mt = A((function* () {
|
|
20
|
+
})().next), bt = se(q), Ue = DataView.prototype, vt = A(Ue.getUint16), Ss = A(Ue.setUint16), It = TypeError, At = WeakSet, Ne = At.prototype, Es = A(Ne.add), _s = A(Ne.has), me = WeakMap, be = me.prototype, Le = A(be.get), xs = A(be.has), Tt = A(be.set), Ce = new me(), St = ye(null, {
|
|
21
|
+
next: { value: function() {
|
|
22
|
+
return Ve(Le(Ce, this));
|
|
23
|
+
} },
|
|
24
|
+
[Y]: { value: function() {
|
|
25
|
+
return this;
|
|
26
|
+
} }
|
|
27
|
+
});
|
|
28
|
+
function Et(e) {
|
|
29
|
+
if (e[Y] === Oe && q.next === Ve) return e;
|
|
30
|
+
const t = ye(St);
|
|
31
|
+
return Tt(Ce, t, yt(e)), t;
|
|
32
|
+
}
|
|
33
|
+
var _t = new me(), xt = ye(bt, { next: {
|
|
34
|
+
value: function() {
|
|
35
|
+
return mt(Le(_t, this));
|
|
36
|
+
},
|
|
37
|
+
writable: !0,
|
|
38
|
+
configurable: !0
|
|
39
|
+
} });
|
|
40
|
+
for (const e of ht(q))
|
|
41
|
+
e !== "next" && dt(xt, e, ge(q, e));
|
|
42
|
+
var kt = 1 / ft, Pt = 6103515625e-14, ze = 9765625e-10, ks = ze * Pt, Ps = ze * kt, Ge = new pe(4), Ft = new wt(Ge), Dt = new we(Ge), F = new Be(512), D = new pt(512);
|
|
43
|
+
for (let e = 0; e < 256; ++e) {
|
|
44
|
+
const t = e - 127;
|
|
45
|
+
t < -24 ? (F[e] = 0, F[e | 256] = 32768, D[e] = 24, D[e | 256] = 24) : t < -14 ? (F[e] = 1024 >> -t - 14, F[e | 256] = 1024 >> -t - 14 | 32768, D[e] = -t - 1, D[e | 256] = -t - 1) : t <= 15 ? (F[e] = t + 15 << 10, F[e | 256] = t + 15 << 10 | 32768, D[e] = 13, D[e | 256] = 13) : t < 128 ? (F[e] = 31744, F[e | 256] = 64512, D[e] = 24, D[e | 256] = 24) : (F[e] = 31744, F[e | 256] = 64512, D[e] = 13, D[e | 256] = 13);
|
|
46
|
+
}
|
|
47
|
+
var ve = new we(2048);
|
|
48
|
+
for (let e = 1; e < 1024; ++e) {
|
|
49
|
+
let t = e << 13, r = 0;
|
|
50
|
+
for (; (t & 8388608) === 0; )
|
|
51
|
+
t <<= 1, r -= 8388608;
|
|
52
|
+
t &= -8388609, r += 947912704, ve[e] = t | r;
|
|
53
|
+
}
|
|
54
|
+
for (let e = 1024; e < 2048; ++e) ve[e] = 939524096 + (e - 1024 << 13);
|
|
55
|
+
var V = new we(64);
|
|
56
|
+
for (let e = 1; e < 31; ++e) V[e] = e << 23;
|
|
57
|
+
V[31] = 1199570944;
|
|
58
|
+
V[32] = 2147483648;
|
|
59
|
+
for (let e = 33; e < 63; ++e) V[e] = 2147483648 + (e - 32 << 23);
|
|
60
|
+
V[63] = 3347054592;
|
|
61
|
+
var qe = new Be(64);
|
|
62
|
+
for (let e = 1; e < 64; ++e) e !== 32 && (qe[e] = 1024);
|
|
63
|
+
function Ot(e) {
|
|
64
|
+
const t = e >> 10;
|
|
65
|
+
return Dt[0] = ve[qe[t] + (e & 1023)] + V[t], Ft[0];
|
|
66
|
+
}
|
|
67
|
+
function je(e, t, ...r) {
|
|
68
|
+
return Ot(vt(e, t, ...Et(r)));
|
|
69
|
+
}
|
|
70
|
+
function le(e, t, r) {
|
|
71
|
+
const s = r && r.debug || !1;
|
|
72
|
+
s && console.log("[xml-utils] getting " + t + " in " + e);
|
|
73
|
+
const i = typeof e == "object" ? e.outer : e, a = i.slice(0, i.indexOf(">") + 1), o = ['"', "'"];
|
|
74
|
+
for (let n = 0; n < o.length; n++) {
|
|
75
|
+
const f = o[n], l = t + "\\=" + f + "([^" + f + "]*)" + f;
|
|
76
|
+
s && console.log("[xml-utils] pattern:", l);
|
|
77
|
+
const c = new RegExp(l).exec(a);
|
|
78
|
+
if (s && console.log("[xml-utils] match:", c), c) return c[1];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function Rt(e, t, r) {
|
|
82
|
+
const s = new RegExp(t).exec(e.slice(r));
|
|
83
|
+
return s ? r + s.index : -1;
|
|
84
|
+
}
|
|
85
|
+
function ke(e, t, r) {
|
|
86
|
+
const s = new RegExp(t).exec(e.slice(r));
|
|
87
|
+
return s ? r + s.index + s[0].length - 1 : -1;
|
|
88
|
+
}
|
|
89
|
+
function Pe(e, t) {
|
|
90
|
+
const r = new RegExp(t, "g"), s = e.match(r);
|
|
91
|
+
return s ? s.length : 0;
|
|
92
|
+
}
|
|
93
|
+
function Mt(e, t, r) {
|
|
94
|
+
const s = r && r.debug || !1, i = r && r.startIndex || 0;
|
|
95
|
+
s && console.log("[xml-utils] starting findTagByName with", t, " and ", r);
|
|
96
|
+
const a = Rt(e, `<${t}[
|
|
97
|
+
>/]`, i);
|
|
98
|
+
if (s && console.log("[xml-utils] start:", a), a === -1) return;
|
|
99
|
+
const o = e.slice(a + t.length);
|
|
100
|
+
let n = ke(o, "^[^<]*[ /]>", 0);
|
|
101
|
+
const f = n !== -1 && o[n - 1] === "/";
|
|
102
|
+
if (s && console.log("[xml-utils] selfClosing:", f), f === !1) {
|
|
103
|
+
let d = 0, u = 1, g = 0;
|
|
104
|
+
for (; (n = ke(o, "[ /]" + t + ">", d)) !== -1; ) {
|
|
105
|
+
const p = o.substring(d, n + 1);
|
|
106
|
+
if (u += Pe(p, "<" + t + `[
|
|
107
|
+
>]`), g += Pe(p, "</" + t + ">"), g >= u) break;
|
|
108
|
+
d = n;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const l = a + t.length + n + 1;
|
|
112
|
+
if (s && console.log("[xml-utils] end:", l), l === -1) return;
|
|
113
|
+
const c = e.slice(a, l);
|
|
114
|
+
let h;
|
|
115
|
+
return f ? h = null : h = c.slice(c.indexOf(">") + 1, c.lastIndexOf("<")), {
|
|
116
|
+
inner: h,
|
|
117
|
+
outer: c,
|
|
118
|
+
start: a,
|
|
119
|
+
end: l
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function Bt(e, t, r) {
|
|
123
|
+
const s = [], i = r && r.debug || !1, a = r && typeof r.nested == "boolean" ? r.nested : !0;
|
|
124
|
+
let o = r && r.startIndex || 0, n;
|
|
125
|
+
for (; n = Mt(e, t, {
|
|
126
|
+
debug: i,
|
|
127
|
+
startIndex: o
|
|
128
|
+
}); )
|
|
129
|
+
a ? o = n.start + 1 + t.length : o = n.end, s.push(n);
|
|
130
|
+
return i && console.log("findTagsByName found", s.length, "tags"), s;
|
|
131
|
+
}
|
|
132
|
+
function Vt(e, t) {
|
|
133
|
+
const { width: r, height: s } = e, i = new Uint8Array(r * s * 3);
|
|
134
|
+
let a;
|
|
135
|
+
for (let o = 0, n = 0; o < e.length; ++o, n += 3)
|
|
136
|
+
a = 256 - e[o] / t * 256, i[n] = a, i[n + 1] = a, i[n + 2] = a;
|
|
137
|
+
return i;
|
|
138
|
+
}
|
|
139
|
+
function Ut(e, t) {
|
|
140
|
+
const { width: r, height: s } = e, i = new Uint8Array(r * s * 3);
|
|
141
|
+
let a;
|
|
142
|
+
for (let o = 0, n = 0; o < e.length; ++o, n += 3)
|
|
143
|
+
a = e[o] / t * 256, i[n] = a, i[n + 1] = a, i[n + 2] = a;
|
|
144
|
+
return i;
|
|
145
|
+
}
|
|
146
|
+
function Nt(e, t) {
|
|
147
|
+
const { width: r, height: s } = e, i = new Uint8Array(r * s * 3), a = t.length / 3, o = t.length / 3 * 2;
|
|
148
|
+
for (let n = 0, f = 0; n < e.length; ++n, f += 3) {
|
|
149
|
+
const l = e[n];
|
|
150
|
+
i[f] = t[l] / 65536 * 256, i[f + 1] = t[l + a] / 65536 * 256, i[f + 2] = t[l + o] / 65536 * 256;
|
|
151
|
+
}
|
|
152
|
+
return i;
|
|
153
|
+
}
|
|
154
|
+
function Lt(e) {
|
|
155
|
+
const { width: t, height: r } = e, s = new Uint8Array(t * r * 3);
|
|
156
|
+
for (let i = 0, a = 0; i < e.length; i += 4, a += 3) {
|
|
157
|
+
const o = e[i], n = e[i + 1], f = e[i + 2], l = e[i + 3];
|
|
158
|
+
s[a] = 255 * ((255 - o) / 256) * ((255 - l) / 256), s[a + 1] = 255 * ((255 - n) / 256) * ((255 - l) / 256), s[a + 2] = 255 * ((255 - f) / 256) * ((255 - l) / 256);
|
|
159
|
+
}
|
|
160
|
+
return s;
|
|
161
|
+
}
|
|
162
|
+
function Ct(e) {
|
|
163
|
+
const { width: t, height: r } = e, s = new Uint8ClampedArray(t * r * 3);
|
|
164
|
+
for (let i = 0, a = 0; i < e.length; i += 3, a += 3) {
|
|
165
|
+
const o = e[i], n = e[i + 1], f = e[i + 2];
|
|
166
|
+
s[a] = o + 1.402 * (f - 128), s[a + 1] = o - 0.34414 * (n - 128) - 0.71414 * (f - 128), s[a + 2] = o + 1.772 * (n - 128);
|
|
167
|
+
}
|
|
168
|
+
return s;
|
|
169
|
+
}
|
|
170
|
+
var zt = 0.95047, Gt = 1, qt = 1.08883;
|
|
171
|
+
function jt(e) {
|
|
172
|
+
const { width: t, height: r } = e, s = new Uint8Array(t * r * 3);
|
|
173
|
+
for (let i = 0, a = 0; i < e.length; i += 3, a += 3) {
|
|
174
|
+
const o = e[i + 0], n = e[i + 1] << 24 >> 24, f = e[i + 2] << 24 >> 24;
|
|
175
|
+
let l = (o + 16) / 116, c = n / 500 + l, h = l - f / 200, d, u, g;
|
|
176
|
+
c = zt * (c * c * c > 8856e-6 ? c * c * c : (c - 16 / 116) / 7.787), l = Gt * (l * l * l > 8856e-6 ? l * l * l : (l - 16 / 116) / 7.787), h = qt * (h * h * h > 8856e-6 ? h * h * h : (h - 16 / 116) / 7.787), d = c * 3.2406 + l * -1.5372 + h * -0.4986, u = c * -0.9689 + l * 1.8758 + h * 0.0415, g = c * 0.0557 + l * -0.204 + h * 1.057, d = d > 31308e-7 ? 1.055 * d ** (1 / 2.4) - 0.055 : 12.92 * d, u = u > 31308e-7 ? 1.055 * u ** (1 / 2.4) - 0.055 : 12.92 * u, g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : 12.92 * g, s[a] = Math.max(0, Math.min(1, d)) * 255, s[a + 1] = Math.max(0, Math.min(1, u)) * 255, s[a + 2] = Math.max(0, Math.min(1, g)) * 255;
|
|
177
|
+
}
|
|
178
|
+
return s;
|
|
179
|
+
}
|
|
180
|
+
var j = /* @__PURE__ */ new Map();
|
|
181
|
+
async function ee(e) {
|
|
182
|
+
const t = !e.hasTag("StripOffsets");
|
|
183
|
+
return {
|
|
184
|
+
tileWidth: t ? await e.loadValue("TileWidth") : await e.loadValue("ImageWidth"),
|
|
185
|
+
tileHeight: t ? await e.loadValue("TileLength") : await e.loadValue("RowsPerStrip") || await e.loadValue("ImageLength"),
|
|
186
|
+
planarConfiguration: await e.loadValue("PlanarConfiguration"),
|
|
187
|
+
bitsPerSample: await e.loadValue("BitsPerSample"),
|
|
188
|
+
predictor: await e.loadValue("Predictor") || 1
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function Ht(e, t, r = ee, s = !0) {
|
|
192
|
+
Array.isArray(e) || (e = [e]), e.forEach((i) => {
|
|
193
|
+
j.set(i, {
|
|
194
|
+
importFn: t,
|
|
195
|
+
decoderParameterFn: r,
|
|
196
|
+
preferWorker: s
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
async function Yt(e, t) {
|
|
201
|
+
if (!j.has(e)) throw new Error(`Unknown compression method identifier: ${e}`);
|
|
202
|
+
const { decoderParameterFn: r } = j.get(e);
|
|
203
|
+
return r(t);
|
|
204
|
+
}
|
|
205
|
+
async function $t(e, t) {
|
|
206
|
+
if (!j.has(e)) throw new Error(`Unknown compression method identifier: ${e}`);
|
|
207
|
+
const { importFn: r } = j.get(e);
|
|
208
|
+
return new (await r())(t);
|
|
209
|
+
}
|
|
210
|
+
var Xt = [
|
|
211
|
+
{
|
|
212
|
+
cases: [void 0, 1],
|
|
213
|
+
importFn: () => import("./raw-Brljg6vy.js").then((e) => e.default),
|
|
214
|
+
preferWorker: !1
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
cases: 5,
|
|
218
|
+
importFn: () => import("./lzw-DF5VHuii.js").then((e) => e.default)
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
cases: 6,
|
|
222
|
+
importFn: () => {
|
|
223
|
+
throw new Error("old style JPEG compression is not supported.");
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
cases: 7,
|
|
228
|
+
importFn: () => import("./jpeg-CJcNvScS.js").then((e) => e.default),
|
|
229
|
+
decoderParameterFn: async (e) => ({
|
|
230
|
+
...await ee(e),
|
|
231
|
+
JPEGTables: await e.loadValue("JPEGTables")
|
|
232
|
+
})
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
cases: [8, 32946],
|
|
236
|
+
importFn: () => import("./deflate-DBL0msKQ.js").then((e) => e.default)
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
cases: 32773,
|
|
240
|
+
importFn: () => import("./packbits-CK8RPU_B.js").then((e) => e.default)
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
cases: 34887,
|
|
244
|
+
importFn: () => import("./lerc-2QwcA_K7.js").then(async (e) => (await e.zstd.init(), e)).then((e) => e.default),
|
|
245
|
+
decoderParameterFn: async (e) => ({
|
|
246
|
+
...await ee(e),
|
|
247
|
+
LercParameters: await e.loadValue("LercParameters")
|
|
248
|
+
})
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
cases: 5e4,
|
|
252
|
+
importFn: () => import("./zstd-BwwN0X3K.js").then(async (e) => (await e.zstd.init(), e)).then((e) => e.default)
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
cases: 50001,
|
|
256
|
+
importFn: () => import("./webimage-rg-Z9Sbn.js").then((e) => e.default),
|
|
257
|
+
decoderParameterFn: async (e) => ({
|
|
258
|
+
...await ee(e),
|
|
259
|
+
samplesPerPixel: Number(await e.loadValue("SamplesPerPixel")) || 4
|
|
260
|
+
}),
|
|
261
|
+
preferWorker: !1
|
|
262
|
+
}
|
|
263
|
+
];
|
|
264
|
+
for (const e of Xt) {
|
|
265
|
+
const { cases: t, importFn: r, decoderParameterFn: s, preferWorker: i } = e;
|
|
266
|
+
Ht(t, r, s, i);
|
|
267
|
+
}
|
|
268
|
+
function ne(e, t, r, s = 1) {
|
|
269
|
+
return new (Object.getPrototypeOf(e)).constructor(t * r * s);
|
|
270
|
+
}
|
|
271
|
+
function Kt(e, t, r, s, i) {
|
|
272
|
+
const a = t / s, o = r / i;
|
|
273
|
+
return e.map((n) => {
|
|
274
|
+
const f = ne(n, s, i);
|
|
275
|
+
for (let l = 0; l < i; ++l) {
|
|
276
|
+
const c = Math.min(Math.round(o * l), r - 1);
|
|
277
|
+
for (let h = 0; h < s; ++h) {
|
|
278
|
+
const d = Math.min(Math.round(a * h), t - 1), u = n[c * t + d];
|
|
279
|
+
f[l * s + h] = u;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return f;
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
function M(e, t, r) {
|
|
286
|
+
return (1 - r) * e + r * t;
|
|
287
|
+
}
|
|
288
|
+
function Zt(e, t, r, s, i) {
|
|
289
|
+
const a = t / s, o = r / i;
|
|
290
|
+
return e.map((n) => {
|
|
291
|
+
const f = ne(n, s, i);
|
|
292
|
+
for (let l = 0; l < i; ++l) {
|
|
293
|
+
const c = o * l, h = Math.floor(c), d = Math.min(Math.ceil(c), r - 1);
|
|
294
|
+
for (let u = 0; u < s; ++u) {
|
|
295
|
+
const g = a * u, p = g % 1, w = Math.floor(g), m = Math.min(Math.ceil(g), t - 1), b = n[h * t + w], I = n[h * t + m], S = n[d * t + w], v = n[d * t + m], T = M(M(b, I, p), M(S, v, p), c % 1);
|
|
296
|
+
f[l * s + u] = T;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return f;
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
function Jt(e, t, r, s, i, a = "nearest") {
|
|
303
|
+
switch (a.toLowerCase()) {
|
|
304
|
+
case "nearest":
|
|
305
|
+
return Kt(e, t, r, s, i);
|
|
306
|
+
case "bilinear":
|
|
307
|
+
case "linear":
|
|
308
|
+
return Zt(e, t, r, s, i);
|
|
309
|
+
default:
|
|
310
|
+
throw new Error(`Unsupported resampling method: '${a}'`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function Qt(e, t, r, s, i, a) {
|
|
314
|
+
const o = t / s, n = r / i, f = ne(e, s, i, a);
|
|
315
|
+
for (let l = 0; l < i; ++l) {
|
|
316
|
+
const c = Math.min(Math.round(n * l), r - 1);
|
|
317
|
+
for (let h = 0; h < s; ++h) {
|
|
318
|
+
const d = Math.min(Math.round(o * h), t - 1);
|
|
319
|
+
for (let u = 0; u < a; ++u) {
|
|
320
|
+
const g = e[c * t * a + d * a + u];
|
|
321
|
+
f[l * s * a + h * a + u] = g;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return f;
|
|
326
|
+
}
|
|
327
|
+
function Wt(e, t, r, s, i, a) {
|
|
328
|
+
const o = t / s, n = r / i, f = ne(e, s, i, a);
|
|
329
|
+
for (let l = 0; l < i; ++l) {
|
|
330
|
+
const c = n * l, h = Math.floor(c), d = Math.min(Math.ceil(c), r - 1);
|
|
331
|
+
for (let u = 0; u < s; ++u) {
|
|
332
|
+
const g = o * u, p = g % 1, w = Math.floor(g), m = Math.min(Math.ceil(g), t - 1);
|
|
333
|
+
for (let b = 0; b < a; ++b) {
|
|
334
|
+
const I = e[h * t * a + w * a + b], S = e[h * t * a + m * a + b], v = e[d * t * a + w * a + b], T = e[d * t * a + m * a + b], k = M(M(I, S, p), M(v, T, p), c % 1);
|
|
335
|
+
f[l * s * a + u * a + b] = k;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return f;
|
|
340
|
+
}
|
|
341
|
+
function er(e, t, r, s, i, a, o = "nearest") {
|
|
342
|
+
switch (o.toLowerCase()) {
|
|
343
|
+
case "nearest":
|
|
344
|
+
return Qt(e, t, r, s, i, a);
|
|
345
|
+
case "bilinear":
|
|
346
|
+
case "linear":
|
|
347
|
+
return Wt(e, t, r, s, i, a);
|
|
348
|
+
default:
|
|
349
|
+
throw new Error(`Unsupported resampling method: '${o}'`);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function tr(e, t, r) {
|
|
353
|
+
let s = 0;
|
|
354
|
+
for (let i = t; i < r; ++i) s += e[i];
|
|
355
|
+
return s;
|
|
356
|
+
}
|
|
357
|
+
function ue(e, t, r) {
|
|
358
|
+
let s;
|
|
359
|
+
switch (e) {
|
|
360
|
+
case 1:
|
|
361
|
+
t <= 8 ? s = Uint8Array : t <= 16 ? s = Uint16Array : t <= 32 && (s = Uint32Array);
|
|
362
|
+
break;
|
|
363
|
+
case 2:
|
|
364
|
+
t === 8 ? s = Int8Array : t === 16 ? s = Int16Array : t === 32 && (s = Int32Array);
|
|
365
|
+
break;
|
|
366
|
+
case 3:
|
|
367
|
+
switch (t) {
|
|
368
|
+
case 16:
|
|
369
|
+
case 32:
|
|
370
|
+
s = Float32Array;
|
|
371
|
+
break;
|
|
372
|
+
case 64:
|
|
373
|
+
s = Float64Array;
|
|
374
|
+
break;
|
|
375
|
+
default:
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
break;
|
|
379
|
+
default:
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
if (s) {
|
|
383
|
+
if (typeof r == "number") return new s(r);
|
|
384
|
+
if (r instanceof ArrayBuffer) return new s(r);
|
|
385
|
+
}
|
|
386
|
+
throw Error("Unsupported data format/bitsPerSample");
|
|
387
|
+
}
|
|
388
|
+
function rr(e, t) {
|
|
389
|
+
return (e === 1 || e === 2) && t <= 32 && t % 8 === 0 ? !1 : !(e === 3 && (t === 16 || t === 32 || t === 64));
|
|
390
|
+
}
|
|
391
|
+
function sr(e, t, r, s, i, a, o) {
|
|
392
|
+
const n = new DataView(e), f = r === 2 ? o * a : o * a * s, l = r === 2 ? 1 : s, c = ue(t, i, f), h = parseInt("1".repeat(i), 2);
|
|
393
|
+
if (t === 1) {
|
|
394
|
+
let d;
|
|
395
|
+
r === 1 ? d = s * i : d = i;
|
|
396
|
+
let u = a * d;
|
|
397
|
+
(u & 7) !== 0 && (u = u + 7 & -8);
|
|
398
|
+
for (let g = 0; g < o; ++g) {
|
|
399
|
+
const p = g * u;
|
|
400
|
+
for (let w = 0; w < a; ++w) {
|
|
401
|
+
const m = p + w * l * i;
|
|
402
|
+
for (let b = 0; b < l; ++b) {
|
|
403
|
+
const I = m + b * i, S = (g * a + w) * l + b, v = Math.floor(I / 8), T = I % 8;
|
|
404
|
+
T + i <= 8 ? c[S] = n.getUint8(v) >> 8 - i - T & h : T + i <= 16 ? c[S] = n.getUint16(v) >> 16 - i - T & h : T + i <= 24 ? c[S] = (n.getUint16(v) << 8 | n.getUint8(v + 2)) >> 24 - i - T & h : c[S] = n.getUint32(v) >> 32 - i - T & h;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return c.buffer;
|
|
410
|
+
}
|
|
411
|
+
var ir = class {
|
|
412
|
+
constructor(e, t, r, s) {
|
|
413
|
+
this.fileDirectory = e, this.littleEndian = t, this.tiles = r ? [] : null, this.isTiled = !e.hasTag("StripOffsets");
|
|
414
|
+
const i = e.getValue("PlanarConfiguration") ?? 1;
|
|
415
|
+
if (i !== 1 && i !== 2) throw new Error("Invalid planar configuration.");
|
|
416
|
+
this.planarConfiguration = i, this.source = s;
|
|
417
|
+
}
|
|
418
|
+
getFileDirectory() {
|
|
419
|
+
return this.fileDirectory;
|
|
420
|
+
}
|
|
421
|
+
getGeoKeys() {
|
|
422
|
+
return this.fileDirectory.parseGeoKeyDirectory();
|
|
423
|
+
}
|
|
424
|
+
getWidth() {
|
|
425
|
+
return this.fileDirectory.getValue("ImageWidth") || 0;
|
|
426
|
+
}
|
|
427
|
+
getHeight() {
|
|
428
|
+
return this.fileDirectory.getValue("ImageLength") || 0;
|
|
429
|
+
}
|
|
430
|
+
getSamplesPerPixel() {
|
|
431
|
+
return this.fileDirectory.getValue("SamplesPerPixel") ?? 1;
|
|
432
|
+
}
|
|
433
|
+
getTileWidth() {
|
|
434
|
+
return this.isTiled ? this.fileDirectory.getValue("TileWidth") || 0 : this.getWidth();
|
|
435
|
+
}
|
|
436
|
+
getTileHeight() {
|
|
437
|
+
if (this.isTiled) return this.fileDirectory.getValue("TileLength") || 0;
|
|
438
|
+
const e = this.fileDirectory.hasTag("RowsPerStrip") && this.fileDirectory.getValue("RowsPerStrip");
|
|
439
|
+
return e ? Math.min(e, this.getHeight()) : this.getHeight();
|
|
440
|
+
}
|
|
441
|
+
getBlockWidth() {
|
|
442
|
+
return this.getTileWidth();
|
|
443
|
+
}
|
|
444
|
+
getBlockHeight(e) {
|
|
445
|
+
return this.isTiled || (e + 1) * this.getTileHeight() <= this.getHeight() ? this.getTileHeight() : this.getHeight() - e * this.getTileHeight();
|
|
446
|
+
}
|
|
447
|
+
getBytesPerPixel() {
|
|
448
|
+
let e = 0;
|
|
449
|
+
const t = this.fileDirectory.getValue("BitsPerSample") || [];
|
|
450
|
+
for (let r = 0; r < t.length; ++r) e += this.getSampleByteSize(r);
|
|
451
|
+
return e;
|
|
452
|
+
}
|
|
453
|
+
getSampleByteSize(e) {
|
|
454
|
+
const t = this.fileDirectory.getValue("BitsPerSample") || [];
|
|
455
|
+
if (e >= t.length) throw new RangeError(`Sample index ${e} is out of range.`);
|
|
456
|
+
return Math.ceil(t[e] / 8);
|
|
457
|
+
}
|
|
458
|
+
getReaderForSample(e) {
|
|
459
|
+
const t = this.fileDirectory.getValue("SampleFormat"), r = t ? t[e] : 1, s = (this.fileDirectory.getValue("BitsPerSample") || [])[e];
|
|
460
|
+
switch (r) {
|
|
461
|
+
case 1:
|
|
462
|
+
if (s <= 8) return DataView.prototype.getUint8;
|
|
463
|
+
if (s <= 16) return DataView.prototype.getUint16;
|
|
464
|
+
if (s <= 32) return DataView.prototype.getUint32;
|
|
465
|
+
break;
|
|
466
|
+
case 2:
|
|
467
|
+
if (s <= 8) return DataView.prototype.getInt8;
|
|
468
|
+
if (s <= 16) return DataView.prototype.getInt16;
|
|
469
|
+
if (s <= 32) return DataView.prototype.getInt32;
|
|
470
|
+
break;
|
|
471
|
+
case 3:
|
|
472
|
+
switch (s) {
|
|
473
|
+
case 16:
|
|
474
|
+
return function(i, a) {
|
|
475
|
+
return je(this, i, a);
|
|
476
|
+
};
|
|
477
|
+
case 32:
|
|
478
|
+
return DataView.prototype.getFloat32;
|
|
479
|
+
case 64:
|
|
480
|
+
return DataView.prototype.getFloat64;
|
|
481
|
+
default:
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
break;
|
|
485
|
+
default:
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
throw Error("Unsupported data format/bitsPerSample");
|
|
489
|
+
}
|
|
490
|
+
getSampleFormat(e = 0) {
|
|
491
|
+
const t = this.fileDirectory.getValue("SampleFormat");
|
|
492
|
+
return t ? t[e] : 1;
|
|
493
|
+
}
|
|
494
|
+
getBitsPerSample(e = 0) {
|
|
495
|
+
const t = this.fileDirectory.getValue("BitsPerSample");
|
|
496
|
+
return t ? t[e] : 0;
|
|
497
|
+
}
|
|
498
|
+
getArrayForSample(e, t) {
|
|
499
|
+
return ue(this.getSampleFormat(e), this.getBitsPerSample(e), t);
|
|
500
|
+
}
|
|
501
|
+
async getTileOrStrip(e, t, r, s, i) {
|
|
502
|
+
const a = Math.ceil(this.getWidth() / this.getTileWidth()), o = Math.ceil(this.getHeight() / this.getTileHeight());
|
|
503
|
+
let n;
|
|
504
|
+
const { tiles: f } = this;
|
|
505
|
+
if (this.planarConfiguration === 1 ? n = t * a + e : this.planarConfiguration === 2 && (n = r * a * o + t * a + e), n === void 0) throw new Error("Could not determine tile or strip index.");
|
|
506
|
+
let l, c;
|
|
507
|
+
if (this.isTiled ? (l = Number(await this.fileDirectory.loadValueIndexed("TileOffsets", n)), c = Number(await this.fileDirectory.loadValueIndexed("TileByteCounts", n))) : (l = Number(await this.fileDirectory.loadValueIndexed("StripOffsets", n)), c = Number(await this.fileDirectory.loadValueIndexed("StripByteCounts", n))), c === 0) {
|
|
508
|
+
const u = this.getBlockHeight(t) * this.getTileWidth(), g = this.planarConfiguration === 2 ? this.getSampleByteSize(r) : this.getBytesPerPixel(), p = new ArrayBuffer(u * g);
|
|
509
|
+
return this.getArrayForSample(r, p).fill(this.getGDALNoData() || 0), {
|
|
510
|
+
x: e,
|
|
511
|
+
y: t,
|
|
512
|
+
sample: r,
|
|
513
|
+
data: p
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
const h = (await this.source.fetch([{
|
|
517
|
+
offset: l,
|
|
518
|
+
length: c
|
|
519
|
+
}], i))[0];
|
|
520
|
+
let d;
|
|
521
|
+
return f === null || !f[n] ? (d = (async () => {
|
|
522
|
+
let u = await s.decode(h);
|
|
523
|
+
const g = this.getSampleFormat(), p = this.getBitsPerSample();
|
|
524
|
+
return rr(g, p) && (u = sr(u, g, this.planarConfiguration, this.getSamplesPerPixel(), p, this.getTileWidth(), this.getBlockHeight(t))), u;
|
|
525
|
+
})(), f !== null && (f[n] = d)) : d = f[n], {
|
|
526
|
+
x: e,
|
|
527
|
+
y: t,
|
|
528
|
+
sample: r,
|
|
529
|
+
data: await d
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
async _readRaster(e, t, r, s, i, a, o, n, f) {
|
|
533
|
+
const l = this.getTileWidth(), c = this.getTileHeight(), h = this.getWidth(), d = this.getHeight(), u = Math.max(Math.floor(e[0] / l), 0), g = Math.min(Math.ceil(e[2] / l), Math.ceil(h / l)), p = Math.max(Math.floor(e[1] / c), 0), w = Math.min(Math.ceil(e[3] / c), Math.ceil(d / c)), m = e[2] - e[0];
|
|
534
|
+
let b = this.getBytesPerPixel();
|
|
535
|
+
const I = [], S = [];
|
|
536
|
+
for (let _ = 0; _ < t.length; ++_) {
|
|
537
|
+
if (this.planarConfiguration === 1) {
|
|
538
|
+
const P = await this.fileDirectory.loadValue("BitsPerSample");
|
|
539
|
+
if (typeof P != "object") throw new Error("Expected BitsPerSample to be an array or typed array.");
|
|
540
|
+
I.push(tr(P, 0, t[_]) / 8);
|
|
541
|
+
} else I.push(0);
|
|
542
|
+
S.push(this.getReaderForSample(t[_]));
|
|
543
|
+
}
|
|
544
|
+
const v = [], { littleEndian: T } = this;
|
|
545
|
+
for (let _ = p; _ < w; ++_) for (let P = u; P < g; ++P) {
|
|
546
|
+
let $;
|
|
547
|
+
this.planarConfiguration === 1 && ($ = this.getTileOrStrip(P, _, 0, i, f));
|
|
548
|
+
for (let X = 0; X < t.length; ++X) {
|
|
549
|
+
const K = X, Ee = t[X];
|
|
550
|
+
if (this.planarConfiguration === 2 && (b = this.getSampleByteSize(Ee), $ = this.getTileOrStrip(P, _, Ee, i, f)), !$) throw new Error("Could not get tile or strip data.");
|
|
551
|
+
const Ke = $.then((U) => {
|
|
552
|
+
const Ze = U.data, Je = new DataView(Ze), oe = this.getBlockHeight(U.y), N = U.y * c, Z = U.x * l, Qe = N + oe, We = (U.x + 1) * l, et = S[K], tt = Math.min(oe, oe - (Qe - e[3]), d - N), rt = Math.min(l, l - (We - e[2]), h - Z);
|
|
553
|
+
for (let L = Math.max(0, e[1] - N); L < tt; ++L) for (let C = Math.max(0, e[0] - Z); C < rt; ++C) {
|
|
554
|
+
const st = (L * l + C) * b, _e = et.call(Je, st + I[K], T);
|
|
555
|
+
let J;
|
|
556
|
+
s ? (J = (L + N - e[1]) * m * t.length + (C + Z - e[0]) * t.length + K, r[J] = _e) : (J = (L + N - e[1]) * m + C + Z - e[0], r[K][J] = _e);
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
v.push(Ke);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
if (await Promise.all(v), a && e[2] - e[0] !== a || o && e[3] - e[1] !== o) {
|
|
563
|
+
let _;
|
|
564
|
+
s ? _ = er(r, e[2] - e[0], e[3] - e[1], a, o, t.length, n) : _ = Jt(r, e[2] - e[0], e[3] - e[1], a, o, n);
|
|
565
|
+
const P = _;
|
|
566
|
+
return P.width = a ?? e[2] - e[0], P.height = o ?? e[3] - e[1], P;
|
|
567
|
+
}
|
|
568
|
+
const k = r;
|
|
569
|
+
return k.width = a || e[2] - e[0], k.height = o || e[3] - e[1], k;
|
|
570
|
+
}
|
|
571
|
+
async readRasters(e = {}) {
|
|
572
|
+
const { window: t, samples: r = [], pool: s = null, width: i, height: a, resampleMethod: o, fillValue: n, signal: f } = e, l = "interleave" in e && e.interleave, c = t || [
|
|
573
|
+
0,
|
|
574
|
+
0,
|
|
575
|
+
this.getWidth(),
|
|
576
|
+
this.getHeight()
|
|
577
|
+
];
|
|
578
|
+
if (c[0] > c[2] || c[1] > c[3]) throw new Error("Invalid subsets");
|
|
579
|
+
const h = (c[2] - c[0]) * (c[3] - c[1]), d = this.getSamplesPerPixel();
|
|
580
|
+
if (!r || !r.length) for (let m = 0; m < d; ++m) r.push(m);
|
|
581
|
+
else for (let m = 0; m < r.length; ++m) if (r[m] >= d) return Promise.reject(/* @__PURE__ */ new RangeError(`Invalid sample index '${r[m]}'.`));
|
|
582
|
+
let u;
|
|
583
|
+
if (l) {
|
|
584
|
+
const { fileDirectory: m } = this, b = m.getValue("SampleFormat"), I = b ? Math.max.apply(null, Array.from(b)) : 1;
|
|
585
|
+
if (I !== 1 && I !== 2 && I !== 3) throw new Error("Unsupported sample format for interleaved data. Must be 1, 2, or 3.");
|
|
586
|
+
const S = m.getValue("BitsPerSample");
|
|
587
|
+
if (u = ue(I, S ? Math.max.apply(null, Array.from(S)) : 8, h * r.length), n) {
|
|
588
|
+
if (Array.isArray(n)) throw new Error("When reading interleaved data, fillValue must be a single number.");
|
|
589
|
+
u.fill(n);
|
|
590
|
+
}
|
|
591
|
+
} else {
|
|
592
|
+
u = [];
|
|
593
|
+
for (let m = 0; m < r.length; ++m) {
|
|
594
|
+
const b = this.getArrayForSample(r[m], h);
|
|
595
|
+
Array.isArray(n) && m < n.length ? b.fill(n[m]) : n && !Array.isArray(n) && b.fill(n), u.push(b);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
const g = this.fileDirectory.getValue("Compression") || 1, p = await Yt(g, this.fileDirectory), w = s ? s.bindParameters(g, p) : await $t(g, p);
|
|
599
|
+
return await this._readRaster(c, r, u, l, w, i, a, o, f);
|
|
600
|
+
}
|
|
601
|
+
async readRGB(e = {}) {
|
|
602
|
+
const { window: t, pool: r = null, width: s, height: i, resampleMethod: a, enableAlpha: o = !1, signal: n } = e, f = ("interleave" in e && e.interleave) ?? !1, l = t || [
|
|
603
|
+
0,
|
|
604
|
+
0,
|
|
605
|
+
this.getWidth(),
|
|
606
|
+
this.getHeight()
|
|
607
|
+
];
|
|
608
|
+
if (l[0] > l[2] || l[1] > l[3]) throw new Error("Invalid subsets");
|
|
609
|
+
const c = this.fileDirectory.getValue("PhotometricInterpretation");
|
|
610
|
+
if (c === x.RGB) {
|
|
611
|
+
let b = [
|
|
612
|
+
0,
|
|
613
|
+
1,
|
|
614
|
+
2
|
|
615
|
+
];
|
|
616
|
+
const I = this.fileDirectory.getValue("ExtraSamples");
|
|
617
|
+
if (I && I[0] !== ot.Unspecified && o) {
|
|
618
|
+
b = [];
|
|
619
|
+
const S = this.fileDirectory.getValue("BitsPerSample") || [];
|
|
620
|
+
for (let v = 0; v < S.length; v += 1) b.push(v);
|
|
621
|
+
}
|
|
622
|
+
return this.readRasters({
|
|
623
|
+
window: t,
|
|
624
|
+
interleave: f,
|
|
625
|
+
samples: b,
|
|
626
|
+
pool: r,
|
|
627
|
+
width: s,
|
|
628
|
+
height: i,
|
|
629
|
+
resampleMethod: a,
|
|
630
|
+
signal: n
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
let h;
|
|
634
|
+
switch (c) {
|
|
635
|
+
case x.WhiteIsZero:
|
|
636
|
+
case x.BlackIsZero:
|
|
637
|
+
case x.Palette:
|
|
638
|
+
h = [0];
|
|
639
|
+
break;
|
|
640
|
+
case x.CMYK:
|
|
641
|
+
h = [
|
|
642
|
+
0,
|
|
643
|
+
1,
|
|
644
|
+
2,
|
|
645
|
+
3
|
|
646
|
+
];
|
|
647
|
+
break;
|
|
648
|
+
case x.YCbCr:
|
|
649
|
+
case x.CIELab:
|
|
650
|
+
h = [
|
|
651
|
+
0,
|
|
652
|
+
1,
|
|
653
|
+
2
|
|
654
|
+
];
|
|
655
|
+
break;
|
|
656
|
+
default:
|
|
657
|
+
throw new Error("Invalid or unsupported photometric interpretation.");
|
|
658
|
+
}
|
|
659
|
+
const d = {
|
|
660
|
+
window: l,
|
|
661
|
+
interleave: !0,
|
|
662
|
+
samples: h,
|
|
663
|
+
pool: r,
|
|
664
|
+
width: s,
|
|
665
|
+
height: i,
|
|
666
|
+
resampleMethod: a,
|
|
667
|
+
signal: n
|
|
668
|
+
}, { fileDirectory: u } = this, g = await this.readRasters(d), p = 2 ** this.getBitsPerSample(0);
|
|
669
|
+
let w;
|
|
670
|
+
switch (c) {
|
|
671
|
+
case x.WhiteIsZero:
|
|
672
|
+
w = Vt(g, p);
|
|
673
|
+
break;
|
|
674
|
+
case x.BlackIsZero:
|
|
675
|
+
w = Ut(g, p);
|
|
676
|
+
break;
|
|
677
|
+
case x.Palette:
|
|
678
|
+
w = Nt(g, await u.loadValue("ColorMap"));
|
|
679
|
+
break;
|
|
680
|
+
case x.CMYK:
|
|
681
|
+
w = Lt(g);
|
|
682
|
+
break;
|
|
683
|
+
case x.YCbCr:
|
|
684
|
+
w = Ct(g);
|
|
685
|
+
break;
|
|
686
|
+
case x.CIELab:
|
|
687
|
+
w = jt(g);
|
|
688
|
+
break;
|
|
689
|
+
default:
|
|
690
|
+
throw new Error("Unsupported photometric interpretation.");
|
|
691
|
+
}
|
|
692
|
+
if (!f) {
|
|
693
|
+
const b = new Uint8Array(w.length / 3), I = new Uint8Array(w.length / 3), S = new Uint8Array(w.length / 3);
|
|
694
|
+
for (let v = 0, T = 0; v < w.length; v += 3, ++T)
|
|
695
|
+
b[T] = w[v], I[T] = w[v + 1], S[T] = w[v + 2];
|
|
696
|
+
w = [
|
|
697
|
+
b,
|
|
698
|
+
I,
|
|
699
|
+
S
|
|
700
|
+
];
|
|
701
|
+
}
|
|
702
|
+
const m = w;
|
|
703
|
+
return m.width = g.width, m.height = g.height, m;
|
|
704
|
+
}
|
|
705
|
+
async getTiePoints() {
|
|
706
|
+
if (!this.fileDirectory.hasTag("ModelTiepoint")) return [];
|
|
707
|
+
const e = await this.fileDirectory.loadValue("ModelTiepoint");
|
|
708
|
+
if (typeof e != "object") throw new Error("Expected ModelTiepoint to be an array or typed array.");
|
|
709
|
+
const t = [];
|
|
710
|
+
for (let r = 0; r < e.length; r += 6) t.push({
|
|
711
|
+
i: e[r],
|
|
712
|
+
j: e[r + 1],
|
|
713
|
+
k: e[r + 2],
|
|
714
|
+
x: e[r + 3],
|
|
715
|
+
y: e[r + 4],
|
|
716
|
+
z: e[r + 5]
|
|
717
|
+
});
|
|
718
|
+
return t;
|
|
719
|
+
}
|
|
720
|
+
async getGDALMetadata(e = null) {
|
|
721
|
+
const t = {};
|
|
722
|
+
if (!this.fileDirectory.hasTag("GDAL_METADATA")) return null;
|
|
723
|
+
let r = Bt(await this.fileDirectory.loadValue("GDAL_METADATA"), "Item");
|
|
724
|
+
e === null ? r = r.filter((s) => le(s, "sample") === void 0) : r = r.filter((s) => Number(le(s, "sample")) === e);
|
|
725
|
+
for (let s = 0; s < r.length; ++s) {
|
|
726
|
+
const i = r[s];
|
|
727
|
+
t[le(i, "name")] = i.inner;
|
|
728
|
+
}
|
|
729
|
+
return t;
|
|
730
|
+
}
|
|
731
|
+
getGDALNoData() {
|
|
732
|
+
const e = this.fileDirectory.hasTag("GDAL_NODATA") && this.fileDirectory.getValue("GDAL_NODATA");
|
|
733
|
+
return e ? Number(e.substring(0, e.length - 1)) : null;
|
|
734
|
+
}
|
|
735
|
+
getOrigin() {
|
|
736
|
+
const e = this.fileDirectory.getValue("ModelTiepoint"), t = this.fileDirectory.getValue("ModelTransformation");
|
|
737
|
+
if (e && e.length === 6) return [
|
|
738
|
+
e[3],
|
|
739
|
+
e[4],
|
|
740
|
+
e[5]
|
|
741
|
+
];
|
|
742
|
+
if (t) return [
|
|
743
|
+
t[3],
|
|
744
|
+
t[7],
|
|
745
|
+
t[11]
|
|
746
|
+
];
|
|
747
|
+
throw new Error("The image does not have an affine transformation.");
|
|
748
|
+
}
|
|
749
|
+
getResolution(e = null) {
|
|
750
|
+
const t = this.fileDirectory.getValue("ModelPixelScale"), r = this.fileDirectory.getValue("ModelTransformation");
|
|
751
|
+
if (t) return [
|
|
752
|
+
t[0],
|
|
753
|
+
-t[1],
|
|
754
|
+
t[2]
|
|
755
|
+
];
|
|
756
|
+
if (r)
|
|
757
|
+
return r[1] === 0 && r[4] === 0 ? [
|
|
758
|
+
r[0],
|
|
759
|
+
-r[5],
|
|
760
|
+
r[10]
|
|
761
|
+
] : [
|
|
762
|
+
Math.sqrt(r[0] * r[0] + r[4] * r[4]),
|
|
763
|
+
-Math.sqrt(r[1] * r[1] + r[5] * r[5]),
|
|
764
|
+
r[10]
|
|
765
|
+
];
|
|
766
|
+
if (e) {
|
|
767
|
+
const [s, i, a] = e.getResolution();
|
|
768
|
+
return [
|
|
769
|
+
s * e.getWidth() / this.getWidth(),
|
|
770
|
+
i * e.getHeight() / this.getHeight(),
|
|
771
|
+
a * e.getWidth() / this.getWidth()
|
|
772
|
+
];
|
|
773
|
+
}
|
|
774
|
+
throw new Error("The image does not have an affine transformation.");
|
|
775
|
+
}
|
|
776
|
+
pixelIsArea() {
|
|
777
|
+
return this.getGeoKeys()?.GTRasterTypeGeoKey === 1;
|
|
778
|
+
}
|
|
779
|
+
getBoundingBox(e = !1) {
|
|
780
|
+
const t = this.getHeight(), r = this.getWidth(), s = this.fileDirectory.getValue("ModelTransformation");
|
|
781
|
+
if (s && !e) {
|
|
782
|
+
const [i, a, , o, n, f, , l] = s, c = [
|
|
783
|
+
[0, 0],
|
|
784
|
+
[0, t],
|
|
785
|
+
[r, 0],
|
|
786
|
+
[r, t]
|
|
787
|
+
].map(([u, g]) => [o + i * u + a * g, l + n * u + f * g]), h = c.map((u) => u[0]), d = c.map((u) => u[1]);
|
|
788
|
+
return [
|
|
789
|
+
Math.min(...h),
|
|
790
|
+
Math.min(...d),
|
|
791
|
+
Math.max(...h),
|
|
792
|
+
Math.max(...d)
|
|
793
|
+
];
|
|
794
|
+
} else {
|
|
795
|
+
const i = this.getOrigin(), a = this.getResolution(), o = i[0], n = i[1], f = o + a[0] * r, l = n + a[1] * t;
|
|
796
|
+
return [
|
|
797
|
+
Math.min(o, f),
|
|
798
|
+
Math.min(n, l),
|
|
799
|
+
Math.max(o, f),
|
|
800
|
+
Math.max(n, l)
|
|
801
|
+
];
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}, ar = class {
|
|
805
|
+
constructor(e) {
|
|
806
|
+
this._dataView = new DataView(e);
|
|
807
|
+
}
|
|
808
|
+
get buffer() {
|
|
809
|
+
return this._dataView.buffer;
|
|
810
|
+
}
|
|
811
|
+
getUint64(e, t) {
|
|
812
|
+
const r = this.getUint32(e, t), s = this.getUint32(e + 4, t);
|
|
813
|
+
let i;
|
|
814
|
+
if (t) {
|
|
815
|
+
if (i = r + 2 ** 32 * s, !Number.isSafeInteger(i)) throw new Error(`${i} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);
|
|
816
|
+
return i;
|
|
817
|
+
}
|
|
818
|
+
if (i = 2 ** 32 * r + s, !Number.isSafeInteger(i)) throw new Error(`${i} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);
|
|
819
|
+
return i;
|
|
820
|
+
}
|
|
821
|
+
getInt64(e, t) {
|
|
822
|
+
let r = 0;
|
|
823
|
+
const s = (this._dataView.getUint8(e + (t ? 7 : 0)) & 128) > 0;
|
|
824
|
+
let i = !0;
|
|
825
|
+
for (let a = 0; a < 8; a++) {
|
|
826
|
+
let o = this._dataView.getUint8(e + (t ? a : 7 - a));
|
|
827
|
+
s && (i ? o !== 0 && (o = ~(o - 1) & 255, i = !1) : o = ~o & 255), r += o * 256 ** a;
|
|
828
|
+
}
|
|
829
|
+
return s && (r = -r), r;
|
|
830
|
+
}
|
|
831
|
+
getUint8(e) {
|
|
832
|
+
return this._dataView.getUint8(e);
|
|
833
|
+
}
|
|
834
|
+
getInt8(e) {
|
|
835
|
+
return this._dataView.getInt8(e);
|
|
836
|
+
}
|
|
837
|
+
getUint16(e, t) {
|
|
838
|
+
return this._dataView.getUint16(e, t);
|
|
839
|
+
}
|
|
840
|
+
getInt16(e, t) {
|
|
841
|
+
return this._dataView.getInt16(e, t);
|
|
842
|
+
}
|
|
843
|
+
getUint32(e, t) {
|
|
844
|
+
return this._dataView.getUint32(e, t);
|
|
845
|
+
}
|
|
846
|
+
getInt32(e, t) {
|
|
847
|
+
return this._dataView.getInt32(e, t);
|
|
848
|
+
}
|
|
849
|
+
getFloat16(e, t) {
|
|
850
|
+
return je(this._dataView, e, t);
|
|
851
|
+
}
|
|
852
|
+
getFloat32(e, t) {
|
|
853
|
+
return this._dataView.getFloat32(e, t);
|
|
854
|
+
}
|
|
855
|
+
getFloat64(e, t) {
|
|
856
|
+
return this._dataView.getFloat64(e, t);
|
|
857
|
+
}
|
|
858
|
+
}, re = class {
|
|
859
|
+
constructor(e, t, r, s) {
|
|
860
|
+
this._dataView = new DataView(e), this._sliceOffset = t, this._littleEndian = r, this._bigTiff = s;
|
|
861
|
+
}
|
|
862
|
+
get sliceOffset() {
|
|
863
|
+
return this._sliceOffset;
|
|
864
|
+
}
|
|
865
|
+
get sliceTop() {
|
|
866
|
+
return this._sliceOffset + this.buffer.byteLength;
|
|
867
|
+
}
|
|
868
|
+
get littleEndian() {
|
|
869
|
+
return this._littleEndian;
|
|
870
|
+
}
|
|
871
|
+
get bigTiff() {
|
|
872
|
+
return this._bigTiff;
|
|
873
|
+
}
|
|
874
|
+
get buffer() {
|
|
875
|
+
return this._dataView.buffer;
|
|
876
|
+
}
|
|
877
|
+
covers(e, t) {
|
|
878
|
+
return this.sliceOffset <= e && this.sliceTop >= e + t;
|
|
879
|
+
}
|
|
880
|
+
readUint8(e) {
|
|
881
|
+
return this._dataView.getUint8(e - this._sliceOffset);
|
|
882
|
+
}
|
|
883
|
+
readInt8(e) {
|
|
884
|
+
return this._dataView.getInt8(e - this._sliceOffset);
|
|
885
|
+
}
|
|
886
|
+
readUint16(e) {
|
|
887
|
+
return this._dataView.getUint16(e - this._sliceOffset, this._littleEndian);
|
|
888
|
+
}
|
|
889
|
+
readInt16(e) {
|
|
890
|
+
return this._dataView.getInt16(e - this._sliceOffset, this._littleEndian);
|
|
891
|
+
}
|
|
892
|
+
readUint32(e) {
|
|
893
|
+
return this._dataView.getUint32(e - this._sliceOffset, this._littleEndian);
|
|
894
|
+
}
|
|
895
|
+
readInt32(e) {
|
|
896
|
+
return this._dataView.getInt32(e - this._sliceOffset, this._littleEndian);
|
|
897
|
+
}
|
|
898
|
+
readFloat32(e) {
|
|
899
|
+
return this._dataView.getFloat32(e - this._sliceOffset, this._littleEndian);
|
|
900
|
+
}
|
|
901
|
+
readFloat64(e) {
|
|
902
|
+
return this._dataView.getFloat64(e - this._sliceOffset, this._littleEndian);
|
|
903
|
+
}
|
|
904
|
+
readUint64(e) {
|
|
905
|
+
const t = this.readUint32(e), r = this.readUint32(e + 4);
|
|
906
|
+
let s;
|
|
907
|
+
if (this._littleEndian) {
|
|
908
|
+
if (s = t + 2 ** 32 * r, !Number.isSafeInteger(s)) throw new Error(`${s} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);
|
|
909
|
+
return s;
|
|
910
|
+
}
|
|
911
|
+
if (s = 2 ** 32 * t + r, !Number.isSafeInteger(s)) throw new Error(`${s} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);
|
|
912
|
+
return s;
|
|
913
|
+
}
|
|
914
|
+
readInt64(e) {
|
|
915
|
+
let t = 0;
|
|
916
|
+
const r = (this._dataView.getUint8(e + (this._littleEndian ? 7 : 0)) & 128) > 0;
|
|
917
|
+
let s = !0;
|
|
918
|
+
for (let i = 0; i < 8; i++) {
|
|
919
|
+
let a = this._dataView.getUint8(e + (this._littleEndian ? i : 7 - i));
|
|
920
|
+
r && (s ? a !== 0 && (a = ~(a - 1) & 255, s = !1) : a = ~a & 255), t += a * 256 ** i;
|
|
921
|
+
}
|
|
922
|
+
return r && (t = -t), t;
|
|
923
|
+
}
|
|
924
|
+
readOffset(e) {
|
|
925
|
+
return this._bigTiff ? this.readUint64(e) : this.readUint32(e);
|
|
926
|
+
}
|
|
927
|
+
}, nr = `\r
|
|
928
|
+
\r
|
|
929
|
+
`;
|
|
930
|
+
function He(e) {
|
|
931
|
+
if (typeof Object.fromEntries < "u") return Object.fromEntries(e);
|
|
932
|
+
const t = {};
|
|
933
|
+
for (const [r, s] of e) t[r.toLowerCase()] = s;
|
|
934
|
+
return t;
|
|
935
|
+
}
|
|
936
|
+
function or(e) {
|
|
937
|
+
return He(e.split(`\r
|
|
938
|
+
`).map((t) => {
|
|
939
|
+
const r = t.split(":").map((s) => s.trim());
|
|
940
|
+
return r[0] = r[0].toLowerCase(), r;
|
|
941
|
+
}));
|
|
942
|
+
}
|
|
943
|
+
function lr(e) {
|
|
944
|
+
if (!e) return {
|
|
945
|
+
type: null,
|
|
946
|
+
params: {}
|
|
947
|
+
};
|
|
948
|
+
const [t, ...r] = e.split(";").map((s) => s.trim());
|
|
949
|
+
return {
|
|
950
|
+
type: t,
|
|
951
|
+
params: He(r.map((s) => s.split("=")))
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
function de(e) {
|
|
955
|
+
let t = NaN, r = NaN, s = NaN;
|
|
956
|
+
return e && ([, t, r, s] = (e.match(/bytes (\d+)-(\d+)\/(\d+)/) || []).map(Number)), {
|
|
957
|
+
start: t,
|
|
958
|
+
end: r,
|
|
959
|
+
total: s
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
function cr(e, t) {
|
|
963
|
+
let r = -1;
|
|
964
|
+
const s = new TextDecoder("ascii"), i = [], a = `--${t}`, o = `${a}--`;
|
|
965
|
+
for (let n = 0; n < 10; ++n) s.decode(new Uint8Array(e, n, a.length)) === a && (r = n);
|
|
966
|
+
if (r === -1) throw new Error("Could not find initial boundary");
|
|
967
|
+
for (; r < e.byteLength; ) {
|
|
968
|
+
const n = s.decode(new Uint8Array(e, r, Math.min(a.length + 1024, e.byteLength - r)));
|
|
969
|
+
if (n.length === 0 || n.startsWith(o)) break;
|
|
970
|
+
if (!n.startsWith(a)) throw new Error("Part does not start with boundary");
|
|
971
|
+
const f = n.substr(a.length + 2);
|
|
972
|
+
if (f.length === 0) break;
|
|
973
|
+
const l = f.indexOf(nr), c = or(f.substr(0, l)), { start: h, end: d, total: u } = de(c["content-range"]), g = r + a.length + l + 4, p = d + 1 - h;
|
|
974
|
+
i.push({
|
|
975
|
+
headers: c,
|
|
976
|
+
data: e.slice(g, g + p),
|
|
977
|
+
offset: h,
|
|
978
|
+
length: p,
|
|
979
|
+
fileSize: u
|
|
980
|
+
}), r = g + p + 4;
|
|
981
|
+
}
|
|
982
|
+
return i;
|
|
983
|
+
}
|
|
984
|
+
var Ye = class {
|
|
985
|
+
async fetch(e, t) {
|
|
986
|
+
return Promise.all(e.map(async (r) => (await this.fetchSlice(r, t)).data));
|
|
987
|
+
}
|
|
988
|
+
async fetchSlice(e, t) {
|
|
989
|
+
throw new Error(`fetching of slice ${e} not possible, not implemented`);
|
|
990
|
+
}
|
|
991
|
+
get fileSize() {
|
|
992
|
+
return null;
|
|
993
|
+
}
|
|
994
|
+
async close() {
|
|
995
|
+
}
|
|
996
|
+
}, hr = class extends Map {
|
|
997
|
+
constructor(e = {}) {
|
|
998
|
+
if (super(), !(e.maxSize && e.maxSize > 0)) throw new TypeError("`maxSize` must be a number greater than 0");
|
|
999
|
+
if (typeof e.maxAge == "number" && e.maxAge === 0) throw new TypeError("`maxAge` must be a number greater than 0");
|
|
1000
|
+
this.maxSize = e.maxSize, this.maxAge = e.maxAge || Number.POSITIVE_INFINITY, this.onEviction = e.onEviction, this.cache = /* @__PURE__ */ new Map(), this.oldCache = /* @__PURE__ */ new Map(), this._size = 0;
|
|
1001
|
+
}
|
|
1002
|
+
_emitEvictions(e) {
|
|
1003
|
+
if (typeof this.onEviction == "function")
|
|
1004
|
+
for (const [t, r] of e) this.onEviction(t, r.value);
|
|
1005
|
+
}
|
|
1006
|
+
_deleteIfExpired(e, t) {
|
|
1007
|
+
return typeof t.expiry == "number" && t.expiry <= Date.now() ? (typeof this.onEviction == "function" && this.onEviction(e, t.value), this.delete(e)) : !1;
|
|
1008
|
+
}
|
|
1009
|
+
_getOrDeleteIfExpired(e, t) {
|
|
1010
|
+
if (this._deleteIfExpired(e, t) === !1) return t.value;
|
|
1011
|
+
}
|
|
1012
|
+
_getItemValue(e, t) {
|
|
1013
|
+
return t.expiry ? this._getOrDeleteIfExpired(e, t) : t.value;
|
|
1014
|
+
}
|
|
1015
|
+
_peek(e, t) {
|
|
1016
|
+
const r = t.get(e);
|
|
1017
|
+
return this._getItemValue(e, r);
|
|
1018
|
+
}
|
|
1019
|
+
_set(e, t) {
|
|
1020
|
+
this.cache.set(e, t), this._size++, this._size >= this.maxSize && (this._size = 0, this._emitEvictions(this.oldCache), this.oldCache = this.cache, this.cache = /* @__PURE__ */ new Map());
|
|
1021
|
+
}
|
|
1022
|
+
_moveToRecent(e, t) {
|
|
1023
|
+
this.oldCache.delete(e), this._set(e, t);
|
|
1024
|
+
}
|
|
1025
|
+
*_entriesAscending() {
|
|
1026
|
+
for (const e of this.oldCache) {
|
|
1027
|
+
const [t, r] = e;
|
|
1028
|
+
this.cache.has(t) || this._deleteIfExpired(t, r) === !1 && (yield e);
|
|
1029
|
+
}
|
|
1030
|
+
for (const e of this.cache) {
|
|
1031
|
+
const [t, r] = e;
|
|
1032
|
+
this._deleteIfExpired(t, r) === !1 && (yield e);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
get(e) {
|
|
1036
|
+
if (this.cache.has(e)) {
|
|
1037
|
+
const t = this.cache.get(e);
|
|
1038
|
+
return this._getItemValue(e, t);
|
|
1039
|
+
}
|
|
1040
|
+
if (this.oldCache.has(e)) {
|
|
1041
|
+
const t = this.oldCache.get(e);
|
|
1042
|
+
if (this._deleteIfExpired(e, t) === !1)
|
|
1043
|
+
return this._moveToRecent(e, t), t.value;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
set(e, t, { maxAge: r = this.maxAge } = {}) {
|
|
1047
|
+
const s = typeof r == "number" && r !== Number.POSITIVE_INFINITY ? Date.now() + r : void 0;
|
|
1048
|
+
return this.cache.has(e) ? this.cache.set(e, {
|
|
1049
|
+
value: t,
|
|
1050
|
+
expiry: s
|
|
1051
|
+
}) : this._set(e, {
|
|
1052
|
+
value: t,
|
|
1053
|
+
expiry: s
|
|
1054
|
+
}), this;
|
|
1055
|
+
}
|
|
1056
|
+
has(e) {
|
|
1057
|
+
return this.cache.has(e) ? !this._deleteIfExpired(e, this.cache.get(e)) : this.oldCache.has(e) ? !this._deleteIfExpired(e, this.oldCache.get(e)) : !1;
|
|
1058
|
+
}
|
|
1059
|
+
peek(e) {
|
|
1060
|
+
if (this.cache.has(e)) return this._peek(e, this.cache);
|
|
1061
|
+
if (this.oldCache.has(e)) return this._peek(e, this.oldCache);
|
|
1062
|
+
}
|
|
1063
|
+
delete(e) {
|
|
1064
|
+
const t = this.cache.delete(e);
|
|
1065
|
+
return t && this._size--, this.oldCache.delete(e) || t;
|
|
1066
|
+
}
|
|
1067
|
+
clear() {
|
|
1068
|
+
this.cache.clear(), this.oldCache.clear(), this._size = 0;
|
|
1069
|
+
}
|
|
1070
|
+
resize(e) {
|
|
1071
|
+
if (!(e && e > 0)) throw new TypeError("`maxSize` must be a number greater than 0");
|
|
1072
|
+
const t = [...this._entriesAscending()], r = t.length - e;
|
|
1073
|
+
r < 0 ? (this.cache = new Map(t), this.oldCache = /* @__PURE__ */ new Map(), this._size = t.length) : (r > 0 && this._emitEvictions(t.slice(0, r)), this.oldCache = new Map(t.slice(r)), this.cache = /* @__PURE__ */ new Map(), this._size = 0), this.maxSize = e;
|
|
1074
|
+
}
|
|
1075
|
+
*keys() {
|
|
1076
|
+
for (const [e] of this) yield e;
|
|
1077
|
+
}
|
|
1078
|
+
*values() {
|
|
1079
|
+
for (const [, e] of this) yield e;
|
|
1080
|
+
}
|
|
1081
|
+
*[Symbol.iterator]() {
|
|
1082
|
+
for (const e of this.cache) {
|
|
1083
|
+
const [t, r] = e;
|
|
1084
|
+
this._deleteIfExpired(t, r) === !1 && (yield [t, r.value]);
|
|
1085
|
+
}
|
|
1086
|
+
for (const e of this.oldCache) {
|
|
1087
|
+
const [t, r] = e;
|
|
1088
|
+
this.cache.has(t) || this._deleteIfExpired(t, r) === !1 && (yield [t, r.value]);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
*entriesDescending() {
|
|
1092
|
+
let e = [...this.cache];
|
|
1093
|
+
for (let t = e.length - 1; t >= 0; --t) {
|
|
1094
|
+
const [r, s] = e[t];
|
|
1095
|
+
this._deleteIfExpired(r, s) === !1 && (yield [r, s.value]);
|
|
1096
|
+
}
|
|
1097
|
+
e = [...this.oldCache];
|
|
1098
|
+
for (let t = e.length - 1; t >= 0; --t) {
|
|
1099
|
+
const [r, s] = e[t];
|
|
1100
|
+
this.cache.has(r) || this._deleteIfExpired(r, s) === !1 && (yield [r, s.value]);
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
*entriesAscending() {
|
|
1104
|
+
for (const [e, t] of this._entriesAscending()) yield [e, t.value];
|
|
1105
|
+
}
|
|
1106
|
+
get size() {
|
|
1107
|
+
if (!this._size) return this.oldCache.size;
|
|
1108
|
+
let e = 0;
|
|
1109
|
+
for (const t of this.oldCache.keys()) this.cache.has(t) || e++;
|
|
1110
|
+
return Math.min(this._size + e, this.maxSize);
|
|
1111
|
+
}
|
|
1112
|
+
entries() {
|
|
1113
|
+
return this.entriesAscending();
|
|
1114
|
+
}
|
|
1115
|
+
forEach(e, t = this) {
|
|
1116
|
+
for (const [r, s] of this.entriesAscending()) e.call(t, s, r, this);
|
|
1117
|
+
}
|
|
1118
|
+
get [Symbol.toStringTag]() {
|
|
1119
|
+
return JSON.stringify([...this.entriesAscending()]);
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
async function fr(e) {
|
|
1123
|
+
return new Promise((t) => setTimeout(t, e));
|
|
1124
|
+
}
|
|
1125
|
+
function ur(e, t) {
|
|
1126
|
+
const r = Array.isArray(e) ? e : Array.from(e), s = Array.isArray(t) ? t : Array.from(t);
|
|
1127
|
+
return r.map((i, a) => [i, s[a]]);
|
|
1128
|
+
}
|
|
1129
|
+
var H = class $e extends Error {
|
|
1130
|
+
constructor(...t) {
|
|
1131
|
+
super(...t), Error.captureStackTrace && Error.captureStackTrace(this, $e), this.name = "AbortError", this.signal = void 0;
|
|
1132
|
+
}
|
|
1133
|
+
}, dr = class extends Error {
|
|
1134
|
+
constructor(e, t) {
|
|
1135
|
+
super(t), this.errors = e, this.message = t, this.name = "AggregateError";
|
|
1136
|
+
}
|
|
1137
|
+
}, gr = dr, yr = class {
|
|
1138
|
+
constructor(e, t, r) {
|
|
1139
|
+
this.offset = e, this.length = t, this.data = r;
|
|
1140
|
+
}
|
|
1141
|
+
get top() {
|
|
1142
|
+
return this.offset + this.length;
|
|
1143
|
+
}
|
|
1144
|
+
}, Fe = class {
|
|
1145
|
+
constructor(e, t, r) {
|
|
1146
|
+
this.offset = e, this.length = t, this.blockIds = r;
|
|
1147
|
+
}
|
|
1148
|
+
}, pr = class extends Ye {
|
|
1149
|
+
constructor(e, { blockSize: t = 65536, cacheSize: r = 100 } = {}) {
|
|
1150
|
+
super(), this.source = e, this.blockSize = t, this.blockCache = new hr({
|
|
1151
|
+
maxSize: r,
|
|
1152
|
+
onEviction: (s, i) => {
|
|
1153
|
+
this.evictedBlocks.set(s, i);
|
|
1154
|
+
}
|
|
1155
|
+
}), this.evictedBlocks = /* @__PURE__ */ new Map(), this.blockRequests = /* @__PURE__ */ new Map(), this.blockIdsToFetch = /* @__PURE__ */ new Set(), this.abortedBlockIds = /* @__PURE__ */ new Set();
|
|
1156
|
+
}
|
|
1157
|
+
get fileSize() {
|
|
1158
|
+
return this.source.fileSize;
|
|
1159
|
+
}
|
|
1160
|
+
async fetch(e, t) {
|
|
1161
|
+
const r = [], s = [], i = [];
|
|
1162
|
+
this.evictedBlocks.clear();
|
|
1163
|
+
for (const { offset: h, length: d } of e) {
|
|
1164
|
+
let u = h + d;
|
|
1165
|
+
const { fileSize: g } = this;
|
|
1166
|
+
g !== null && (u = Math.min(u, g));
|
|
1167
|
+
const p = Math.floor(h / this.blockSize) * this.blockSize;
|
|
1168
|
+
for (let w = p; w < u; w += this.blockSize) {
|
|
1169
|
+
const m = Math.floor(w / this.blockSize);
|
|
1170
|
+
!this.blockCache.has(m) && !this.blockRequests.has(m) && (this.blockIdsToFetch.add(m), s.push(m)), this.blockRequests.has(m) && r.push(this.blockRequests.get(m)), i.push(m);
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
await fr(), this.fetchBlocks(t);
|
|
1174
|
+
const a = [];
|
|
1175
|
+
for (const h of s) this.blockRequests.has(h) && a.push(this.blockRequests.get(h));
|
|
1176
|
+
await Promise.allSettled(r), await Promise.allSettled(a);
|
|
1177
|
+
const o = [], n = i.filter((h) => this.abortedBlockIds.has(h) || !this.blockCache.has(h));
|
|
1178
|
+
if (n.forEach((h) => this.blockIdsToFetch.add(h)), n.length > 0 && t && !t.aborted) {
|
|
1179
|
+
this.fetchBlocks();
|
|
1180
|
+
for (const h of n) {
|
|
1181
|
+
const d = this.blockRequests.get(h);
|
|
1182
|
+
if (!d) throw new Error(`Block ${h} is not in the block requests`);
|
|
1183
|
+
o.push(d);
|
|
1184
|
+
}
|
|
1185
|
+
await Promise.allSettled(o);
|
|
1186
|
+
}
|
|
1187
|
+
if (t && t.aborted) throw new H("Request was aborted");
|
|
1188
|
+
const f = i.map((h) => this.blockCache.get(h) || this.evictedBlocks.get(h)), l = f.filter((h) => !h);
|
|
1189
|
+
if (l.length) throw new gr(l, "Request failed");
|
|
1190
|
+
const c = new Map(ur(i, f));
|
|
1191
|
+
return this.readSliceData(e, c);
|
|
1192
|
+
}
|
|
1193
|
+
fetchBlocks(e) {
|
|
1194
|
+
if (this.blockIdsToFetch.size > 0) {
|
|
1195
|
+
const t = this.groupBlocks(this.blockIdsToFetch), r = t.map(async (s) => ({
|
|
1196
|
+
...s,
|
|
1197
|
+
...await this.source.fetchSlice(s, e)
|
|
1198
|
+
}));
|
|
1199
|
+
for (let s = 0; s < t.length; ++s) {
|
|
1200
|
+
const i = t[s];
|
|
1201
|
+
for (const a of i.blockIds) this.blockRequests.set(a, (async () => {
|
|
1202
|
+
try {
|
|
1203
|
+
const o = (await Promise.all(r))[s], n = a * this.blockSize, f = n - o.offset, l = Math.min(f + this.blockSize, o.data.byteLength), c = o.data.slice(f, l), h = new yr(n, c.byteLength, c);
|
|
1204
|
+
this.blockCache.set(a, h), this.abortedBlockIds.delete(a);
|
|
1205
|
+
} catch (o) {
|
|
1206
|
+
if (o instanceof H && o.name === "AbortError")
|
|
1207
|
+
o.signal = e, this.blockCache.delete(a), this.abortedBlockIds.add(a);
|
|
1208
|
+
else throw o;
|
|
1209
|
+
} finally {
|
|
1210
|
+
this.blockRequests.delete(a);
|
|
1211
|
+
}
|
|
1212
|
+
})());
|
|
1213
|
+
}
|
|
1214
|
+
this.blockIdsToFetch.clear();
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
groupBlocks(e) {
|
|
1218
|
+
const t = Array.from(e).sort((a, o) => a - o);
|
|
1219
|
+
if (t.length === 0) return [];
|
|
1220
|
+
let r = [], s = null;
|
|
1221
|
+
const i = [];
|
|
1222
|
+
for (const a of t) s === null || s + 1 === a ? (r.push(a), s = a) : (i.push(new Fe(r[0] * this.blockSize, r.length * this.blockSize, r)), r = [a], s = a);
|
|
1223
|
+
return i.push(new Fe(r[0] * this.blockSize, r.length * this.blockSize, r)), i;
|
|
1224
|
+
}
|
|
1225
|
+
readSliceData(e, t) {
|
|
1226
|
+
return e.map((r) => {
|
|
1227
|
+
let s = r.offset + r.length;
|
|
1228
|
+
this.fileSize !== null && (s = Math.min(this.fileSize, s));
|
|
1229
|
+
const i = Math.floor(r.offset / this.blockSize), a = Math.floor((s - 1) / this.blockSize), o = new ArrayBuffer(r.length), n = new Uint8Array(o);
|
|
1230
|
+
for (let f = i; f <= a; ++f) {
|
|
1231
|
+
const l = t.get(f);
|
|
1232
|
+
if (!l) continue;
|
|
1233
|
+
const c = l.offset - r.offset, h = l.top - s;
|
|
1234
|
+
let d = 0, u = 0, g;
|
|
1235
|
+
c < 0 ? d = -c : c > 0 && (u = c), h < 0 ? g = l.length - d : g = s - l.offset - d;
|
|
1236
|
+
const p = new Uint8Array(l.data, d, g);
|
|
1237
|
+
n.set(p, u);
|
|
1238
|
+
}
|
|
1239
|
+
return o;
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
}, Ie = class {
|
|
1243
|
+
get ok() {
|
|
1244
|
+
return this.status >= 200 && this.status <= 299;
|
|
1245
|
+
}
|
|
1246
|
+
get status() {
|
|
1247
|
+
throw new Error("not implemented");
|
|
1248
|
+
}
|
|
1249
|
+
getHeader(e) {
|
|
1250
|
+
throw new Error("not implemented");
|
|
1251
|
+
}
|
|
1252
|
+
async getData() {
|
|
1253
|
+
throw new Error("not implemented");
|
|
1254
|
+
}
|
|
1255
|
+
}, Ae = class {
|
|
1256
|
+
constructor(e) {
|
|
1257
|
+
this.url = e;
|
|
1258
|
+
}
|
|
1259
|
+
async request(e) {
|
|
1260
|
+
throw new Error("request is not implemented");
|
|
1261
|
+
}
|
|
1262
|
+
}, wr = class extends Ie {
|
|
1263
|
+
constructor(e) {
|
|
1264
|
+
super(), this.response = e;
|
|
1265
|
+
}
|
|
1266
|
+
get status() {
|
|
1267
|
+
return this.response.status;
|
|
1268
|
+
}
|
|
1269
|
+
getHeader(e) {
|
|
1270
|
+
return this.response.headers.get(e) || void 0;
|
|
1271
|
+
}
|
|
1272
|
+
async getData() {
|
|
1273
|
+
return this.response.arrayBuffer ? await this.response.arrayBuffer() : (await this.response.buffer()).buffer;
|
|
1274
|
+
}
|
|
1275
|
+
}, mr = class extends Ae {
|
|
1276
|
+
constructor(e, t) {
|
|
1277
|
+
super(e), this.credentials = t;
|
|
1278
|
+
}
|
|
1279
|
+
async request({ headers: e, signal: t } = {}) {
|
|
1280
|
+
return new wr(await fetch(this.url, {
|
|
1281
|
+
headers: e,
|
|
1282
|
+
credentials: this.credentials,
|
|
1283
|
+
signal: t
|
|
1284
|
+
}));
|
|
1285
|
+
}
|
|
1286
|
+
}, br = class extends Ie {
|
|
1287
|
+
constructor(e, t) {
|
|
1288
|
+
super(), this.xhr = e, this.data = t;
|
|
1289
|
+
}
|
|
1290
|
+
get status() {
|
|
1291
|
+
return this.xhr.status;
|
|
1292
|
+
}
|
|
1293
|
+
getHeader(e) {
|
|
1294
|
+
return this.xhr.getResponseHeader(e) || void 0;
|
|
1295
|
+
}
|
|
1296
|
+
async getData() {
|
|
1297
|
+
return this.data;
|
|
1298
|
+
}
|
|
1299
|
+
}, vr = class extends Ae {
|
|
1300
|
+
constructRequest(e, t) {
|
|
1301
|
+
return new Promise((r, s) => {
|
|
1302
|
+
const i = new XMLHttpRequest();
|
|
1303
|
+
i.open("GET", this.url), i.responseType = "arraybuffer";
|
|
1304
|
+
for (const [a, o] of Object.entries(e)) i.setRequestHeader(a, o);
|
|
1305
|
+
i.onload = () => {
|
|
1306
|
+
const a = i.response;
|
|
1307
|
+
r(new br(i, a));
|
|
1308
|
+
}, i.onerror = s, i.onabort = () => s(new H("Request aborted")), i.send(), t && (t.aborted && i.abort(), t.addEventListener("abort", () => i.abort()));
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
async request({ headers: e = {}, signal: t = void 0 } = {}) {
|
|
1312
|
+
return await this.constructRequest(e, t);
|
|
1313
|
+
}
|
|
1314
|
+
}, Ir = /* @__PURE__ */ at(((e, t) => {
|
|
1315
|
+
t.exports = {};
|
|
1316
|
+
})), ce = /* @__PURE__ */ it(Ir(), 1), Ar = class extends Ie {
|
|
1317
|
+
constructor(e, t) {
|
|
1318
|
+
super(), this.response = e, this.dataPromise = t;
|
|
1319
|
+
}
|
|
1320
|
+
get status() {
|
|
1321
|
+
return this.response.statusCode;
|
|
1322
|
+
}
|
|
1323
|
+
getHeader(e) {
|
|
1324
|
+
const t = this.response.headers[e];
|
|
1325
|
+
return Array.isArray(t) ? t.join(", ") : t;
|
|
1326
|
+
}
|
|
1327
|
+
async getData() {
|
|
1328
|
+
return await this.dataPromise;
|
|
1329
|
+
}
|
|
1330
|
+
}, Tr = class extends Ae {
|
|
1331
|
+
constructor(e) {
|
|
1332
|
+
super(e), this.parsedUrl = ce.default.parse(this.url), this.httpApi = (this.parsedUrl.protocol === "http:", ce.default);
|
|
1333
|
+
}
|
|
1334
|
+
constructRequest(e, t) {
|
|
1335
|
+
return new Promise((r, s) => {
|
|
1336
|
+
const i = this.httpApi.get({
|
|
1337
|
+
...this.parsedUrl,
|
|
1338
|
+
headers: e
|
|
1339
|
+
}, (a) => {
|
|
1340
|
+
r(new Ar(a, new Promise((o) => {
|
|
1341
|
+
const n = [];
|
|
1342
|
+
a.on("data", (f) => {
|
|
1343
|
+
n.push(f);
|
|
1344
|
+
}), a.on("end", () => {
|
|
1345
|
+
const f = Buffer.concat(n).buffer;
|
|
1346
|
+
o(f);
|
|
1347
|
+
}), a.on("error", s);
|
|
1348
|
+
})));
|
|
1349
|
+
});
|
|
1350
|
+
i.on("error", s), t && (t.aborted && i.destroy(new H("Request aborted")), t.addEventListener("abort", () => i.destroy(new H("Request aborted"))));
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
async request({ headers: e = {}, signal: t = void 0 } = {}) {
|
|
1354
|
+
return await this.constructRequest(e, t);
|
|
1355
|
+
}
|
|
1356
|
+
}, Te = class extends Ye {
|
|
1357
|
+
constructor(e, { headers: t, maxRanges: r = 0, allowFullFile: s } = {}) {
|
|
1358
|
+
super(), this.client = e, this.headers = t, this.maxRanges = r, this.allowFullFile = s, this._fileSize = null;
|
|
1359
|
+
}
|
|
1360
|
+
async fetch(e, t) {
|
|
1361
|
+
return this.maxRanges >= e.length ? this.fetchSlices(e, t).then((r) => r.map((s) => s.data)) : (this.maxRanges > 0 && e.length > 1, Promise.all(e.map(async (r) => (await this.fetchSlice(r, t)).data)));
|
|
1362
|
+
}
|
|
1363
|
+
async fetchSlices(e, t) {
|
|
1364
|
+
const r = await this.client.request({
|
|
1365
|
+
headers: {
|
|
1366
|
+
...this.headers,
|
|
1367
|
+
Range: `bytes=${e.map(({ offset: s, length: i }) => `${s}-${s + i - 1}`).join(",")}`
|
|
1368
|
+
},
|
|
1369
|
+
signal: t
|
|
1370
|
+
});
|
|
1371
|
+
if (r.ok) if (r.status === 206) {
|
|
1372
|
+
const { type: s, params: i } = lr(r.getHeader("content-type"));
|
|
1373
|
+
if (s === "multipart/byteranges") {
|
|
1374
|
+
const c = cr(await r.getData(), i.boundary);
|
|
1375
|
+
return this._fileSize = c[0].fileSize || null, c;
|
|
1376
|
+
}
|
|
1377
|
+
const a = await r.getData(), { start: o, end: n, total: f } = de(r.getHeader("content-range"));
|
|
1378
|
+
this._fileSize = f || null;
|
|
1379
|
+
const l = [{
|
|
1380
|
+
data: a,
|
|
1381
|
+
offset: o,
|
|
1382
|
+
length: n + 1 - o
|
|
1383
|
+
}];
|
|
1384
|
+
if (e.length > 1) {
|
|
1385
|
+
const c = await Promise.all(e.slice(1).map((h) => this.fetchSlice(h, t)));
|
|
1386
|
+
return l.concat(c);
|
|
1387
|
+
}
|
|
1388
|
+
return l;
|
|
1389
|
+
} else {
|
|
1390
|
+
if (!this.allowFullFile) throw new Error("Server responded with full file");
|
|
1391
|
+
const s = await r.getData();
|
|
1392
|
+
return this._fileSize = s.byteLength, [{
|
|
1393
|
+
data: s,
|
|
1394
|
+
offset: 0,
|
|
1395
|
+
length: s.byteLength
|
|
1396
|
+
}];
|
|
1397
|
+
}
|
|
1398
|
+
else throw new Error("Error fetching data.");
|
|
1399
|
+
}
|
|
1400
|
+
async fetchSlice(e, t) {
|
|
1401
|
+
const { offset: r, length: s } = e, i = await this.client.request({
|
|
1402
|
+
headers: {
|
|
1403
|
+
...this.headers,
|
|
1404
|
+
Range: `bytes=${r}-${r + s - 1}`
|
|
1405
|
+
},
|
|
1406
|
+
signal: t
|
|
1407
|
+
});
|
|
1408
|
+
if (i.ok) if (i.status === 206) {
|
|
1409
|
+
const a = await i.getData(), { total: o } = de(i.getHeader("content-range"));
|
|
1410
|
+
return this._fileSize = o || null, {
|
|
1411
|
+
data: a,
|
|
1412
|
+
offset: r,
|
|
1413
|
+
length: s
|
|
1414
|
+
};
|
|
1415
|
+
} else {
|
|
1416
|
+
if (!this.allowFullFile) throw new Error("Server responded with full file");
|
|
1417
|
+
const a = await i.getData();
|
|
1418
|
+
return this._fileSize = a.byteLength, {
|
|
1419
|
+
data: a,
|
|
1420
|
+
offset: 0,
|
|
1421
|
+
length: a.byteLength
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1424
|
+
else throw new Error("Error fetching data.");
|
|
1425
|
+
}
|
|
1426
|
+
get fileSize() {
|
|
1427
|
+
return this._fileSize;
|
|
1428
|
+
}
|
|
1429
|
+
};
|
|
1430
|
+
function Se(e, { blockSize: t, cacheSize: r }) {
|
|
1431
|
+
return t === void 0 ? e : new pr(e, {
|
|
1432
|
+
blockSize: t,
|
|
1433
|
+
cacheSize: r
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
function Sr(e, { headers: t = {}, credentials: r, maxRanges: s = 0, allowFullFile: i = !1, ...a } = {}) {
|
|
1437
|
+
return Se(new Te(new mr(e, r), {
|
|
1438
|
+
headers: t,
|
|
1439
|
+
maxRanges: s,
|
|
1440
|
+
allowFullFile: i
|
|
1441
|
+
}), a);
|
|
1442
|
+
}
|
|
1443
|
+
function Er(e, { headers: t = {}, maxRanges: r = 0, allowFullFile: s = !1, ...i } = {}) {
|
|
1444
|
+
return Se(new Te(new vr(e), {
|
|
1445
|
+
headers: t,
|
|
1446
|
+
maxRanges: r,
|
|
1447
|
+
allowFullFile: s
|
|
1448
|
+
}), i);
|
|
1449
|
+
}
|
|
1450
|
+
function _r(e, { headers: t = {}, maxRanges: r = 0, allowFullFile: s = !1, ...i } = {}) {
|
|
1451
|
+
return Se(new Te(new Tr(e), {
|
|
1452
|
+
headers: t,
|
|
1453
|
+
maxRanges: r,
|
|
1454
|
+
allowFullFile: s
|
|
1455
|
+
}), i);
|
|
1456
|
+
}
|
|
1457
|
+
function xr(e, { forceXHR: t = !1, ...r } = {}) {
|
|
1458
|
+
return typeof fetch == "function" && !t ? Sr(e, r) : typeof XMLHttpRequest < "u" ? Er(e, r) : _r(e, r);
|
|
1459
|
+
}
|
|
1460
|
+
function O(e, t) {
|
|
1461
|
+
switch (e) {
|
|
1462
|
+
case y.BYTE:
|
|
1463
|
+
case y.ASCII:
|
|
1464
|
+
case y.UNDEFINED:
|
|
1465
|
+
return new Uint8Array(t);
|
|
1466
|
+
case y.SBYTE:
|
|
1467
|
+
return new Int8Array(t);
|
|
1468
|
+
case y.SHORT:
|
|
1469
|
+
return new Uint16Array(t);
|
|
1470
|
+
case y.SSHORT:
|
|
1471
|
+
return new Int16Array(t);
|
|
1472
|
+
case y.LONG:
|
|
1473
|
+
case y.IFD:
|
|
1474
|
+
return new Uint32Array(t);
|
|
1475
|
+
case y.SLONG:
|
|
1476
|
+
return new Int32Array(t);
|
|
1477
|
+
case y.LONG8:
|
|
1478
|
+
case y.IFD8:
|
|
1479
|
+
return new Array(t);
|
|
1480
|
+
case y.SLONG8:
|
|
1481
|
+
return new Array(t);
|
|
1482
|
+
case y.RATIONAL:
|
|
1483
|
+
return new Uint32Array(t * 2);
|
|
1484
|
+
case y.SRATIONAL:
|
|
1485
|
+
return new Int32Array(t * 2);
|
|
1486
|
+
case y.FLOAT:
|
|
1487
|
+
return new Float32Array(t);
|
|
1488
|
+
case y.DOUBLE:
|
|
1489
|
+
return new Float64Array(t);
|
|
1490
|
+
default:
|
|
1491
|
+
throw new RangeError(`Invalid field type: ${e}`);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
function R(e, t) {
|
|
1495
|
+
switch (t) {
|
|
1496
|
+
case y.BYTE:
|
|
1497
|
+
case y.ASCII:
|
|
1498
|
+
case y.UNDEFINED:
|
|
1499
|
+
return e.readUint8;
|
|
1500
|
+
case y.SBYTE:
|
|
1501
|
+
return e.readInt8;
|
|
1502
|
+
case y.SHORT:
|
|
1503
|
+
return e.readUint16;
|
|
1504
|
+
case y.SSHORT:
|
|
1505
|
+
return e.readInt16;
|
|
1506
|
+
case y.LONG:
|
|
1507
|
+
case y.IFD:
|
|
1508
|
+
return e.readUint32;
|
|
1509
|
+
case y.SLONG:
|
|
1510
|
+
return e.readInt32;
|
|
1511
|
+
case y.LONG8:
|
|
1512
|
+
case y.IFD8:
|
|
1513
|
+
return e.readUint64;
|
|
1514
|
+
case y.SLONG8:
|
|
1515
|
+
return e.readInt64;
|
|
1516
|
+
case y.RATIONAL:
|
|
1517
|
+
return e.readUint32;
|
|
1518
|
+
case y.SRATIONAL:
|
|
1519
|
+
return e.readInt32;
|
|
1520
|
+
case y.FLOAT:
|
|
1521
|
+
return e.readFloat32;
|
|
1522
|
+
case y.DOUBLE:
|
|
1523
|
+
return e.readFloat64;
|
|
1524
|
+
default:
|
|
1525
|
+
throw new RangeError(`Invalid field type: ${t}`);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
function z(e = null, t, r, s, i, a, o = !1) {
|
|
1529
|
+
const n = G(s), f = e || O(s, i), l = s === y.RATIONAL || s === y.SRATIONAL;
|
|
1530
|
+
if (l) for (let c = 0; c < i; c += 2)
|
|
1531
|
+
f[c] = t.call(r, a + c * n), f[c + 1] = t.call(r, a + (c * n + 4));
|
|
1532
|
+
else for (let c = 0; c < i; ++c) f[c] = t.call(r, a + c * n);
|
|
1533
|
+
return s === y.ASCII ? new TextDecoder("utf-8").decode(f) : i === 1 && !o && !l ? f[0] : f;
|
|
1534
|
+
}
|
|
1535
|
+
var kr = class {
|
|
1536
|
+
constructor(e, t, r, s, i) {
|
|
1537
|
+
this.source = e, this.arrayOffset = t, this.littleEndian = r, this.fieldType = s, this.length = i, this.data = O(s, i), this.itemSize = G(s), this.maskBitmap = new Uint8Array(Math.ceil(i / 8)), this.fetchIndexPromises = /* @__PURE__ */ new Map(), this.fullFetchPromise = null;
|
|
1538
|
+
}
|
|
1539
|
+
async loadAll() {
|
|
1540
|
+
return this.fullFetchPromise || (this.fullFetchPromise = this.source.fetch([{
|
|
1541
|
+
offset: this.arrayOffset,
|
|
1542
|
+
length: this.itemSize * this.length
|
|
1543
|
+
}]).then((e) => {
|
|
1544
|
+
const t = new re(e[0], this.arrayOffset, !0, !1), r = z(this.data, R(t, this.fieldType), t, this.fieldType, this.length, this.arrayOffset, !0);
|
|
1545
|
+
return this.maskBitmap.fill(255), this.fetchIndexPromises.clear(), r;
|
|
1546
|
+
})), this.fullFetchPromise;
|
|
1547
|
+
}
|
|
1548
|
+
async get(e) {
|
|
1549
|
+
if (e < 0 || e >= this.data.length) throw new RangeError(`Index ${e} out of bounds for length ${this.data.length}`);
|
|
1550
|
+
const t = Math.floor(e / 8), r = 1 << e % 8, s = this.arrayOffset + e * this.itemSize;
|
|
1551
|
+
if ((this.maskBitmap[t] & r) === 0) {
|
|
1552
|
+
if (!this.fetchIndexPromises.has(e)) {
|
|
1553
|
+
const i = this.source.fetch([{
|
|
1554
|
+
offset: s,
|
|
1555
|
+
length: this.itemSize
|
|
1556
|
+
}]).then((a) => {
|
|
1557
|
+
const o = new re(a[0], this.arrayOffset + e * this.itemSize, !0, !1), n = R(o, this.fieldType).call(o, s);
|
|
1558
|
+
return this.data[e] = n, this.maskBitmap[t] |= r, this.fetchIndexPromises.delete(e), n;
|
|
1559
|
+
});
|
|
1560
|
+
this.fetchIndexPromises.set(e, i);
|
|
1561
|
+
}
|
|
1562
|
+
return this.fetchIndexPromises.get(e);
|
|
1563
|
+
}
|
|
1564
|
+
return this.data[e];
|
|
1565
|
+
}
|
|
1566
|
+
}, Pr = class {
|
|
1567
|
+
constructor(e, t, r, s) {
|
|
1568
|
+
this.actualizedFields = e, this.deferredFields = t, this.deferredFieldsBeingResolved = /* @__PURE__ */ new Map(), this.deferredArrays = r, this.nextIFDByteOffset = s;
|
|
1569
|
+
}
|
|
1570
|
+
hasTag(e) {
|
|
1571
|
+
const t = Q(e);
|
|
1572
|
+
return this.actualizedFields.has(t) || this.deferredFields.has(t) || this.deferredArrays.has(t);
|
|
1573
|
+
}
|
|
1574
|
+
getValue(e) {
|
|
1575
|
+
const t = Q(e);
|
|
1576
|
+
if (this.deferredFields.has(t) || this.deferredArrays.has(t)) {
|
|
1577
|
+
const r = te[t]?.name || `Tag${t}`;
|
|
1578
|
+
throw new Error(`Field '${r}' (${t}) is deferred. Use loadValue() to load it asynchronously.`);
|
|
1579
|
+
}
|
|
1580
|
+
if (this.actualizedFields.has(t))
|
|
1581
|
+
return this.actualizedFields.get(t);
|
|
1582
|
+
}
|
|
1583
|
+
async loadValue(e) {
|
|
1584
|
+
const t = Q(e);
|
|
1585
|
+
if (this.actualizedFields.has(t)) return this.actualizedFields.get(t);
|
|
1586
|
+
if (this.deferredFieldsBeingResolved.has(t)) return this.deferredFieldsBeingResolved.get(t);
|
|
1587
|
+
const r = this.deferredFields.get(t);
|
|
1588
|
+
if (r) {
|
|
1589
|
+
this.deferredFields.delete(t);
|
|
1590
|
+
const i = (async () => {
|
|
1591
|
+
try {
|
|
1592
|
+
const a = await r();
|
|
1593
|
+
return this.actualizedFields.set(t, a), a;
|
|
1594
|
+
} finally {
|
|
1595
|
+
this.deferredFieldsBeingResolved.delete(t);
|
|
1596
|
+
}
|
|
1597
|
+
})();
|
|
1598
|
+
return this.deferredFieldsBeingResolved.set(t, i), i;
|
|
1599
|
+
}
|
|
1600
|
+
const s = this.deferredArrays.get(t);
|
|
1601
|
+
if (s) return s.loadAll();
|
|
1602
|
+
}
|
|
1603
|
+
async loadValueIndexed(e, t) {
|
|
1604
|
+
const r = Q(e);
|
|
1605
|
+
if (this.actualizedFields.has(r)) return this.actualizedFields.get(r)[t];
|
|
1606
|
+
if (this.deferredArrays.has(r)) return this.deferredArrays.get(r).get(t);
|
|
1607
|
+
if (this.hasTag(r)) {
|
|
1608
|
+
const s = await this.loadValue(r);
|
|
1609
|
+
if (s && typeof s != "number") return s[t];
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
parseGeoKeyDirectory() {
|
|
1613
|
+
const e = this.getValue("GeoKeyDirectory");
|
|
1614
|
+
if (!e) return null;
|
|
1615
|
+
const t = {};
|
|
1616
|
+
for (let r = 4; r <= e[3] * 4; r += 4) {
|
|
1617
|
+
const s = nt[e[r]], i = e[r + 1] || null, a = e[r + 2], o = e[r + 3];
|
|
1618
|
+
let n = null;
|
|
1619
|
+
if (!i) n = o;
|
|
1620
|
+
else {
|
|
1621
|
+
if (n = this.getValue(i), typeof n > "u" || n === null) throw new Error(`Could not get value of geoKey '${s}'.`);
|
|
1622
|
+
typeof n == "string" ? n = n.substring(o, o + a - 1) : n.subarray && (n = n.subarray(o, o + a), a === 1 && (n = n[0]));
|
|
1623
|
+
}
|
|
1624
|
+
t[s] = n;
|
|
1625
|
+
}
|
|
1626
|
+
return t;
|
|
1627
|
+
}
|
|
1628
|
+
toObject() {
|
|
1629
|
+
const e = {};
|
|
1630
|
+
for (const [t, r] of this.actualizedFields.entries()) {
|
|
1631
|
+
const s = typeof t == "number" ? te[t] : void 0, i = s ? s.name : `Tag${t}`;
|
|
1632
|
+
e[i] = r;
|
|
1633
|
+
}
|
|
1634
|
+
return e;
|
|
1635
|
+
}
|
|
1636
|
+
}, Fr = class {
|
|
1637
|
+
constructor(e, t, r, s = !1) {
|
|
1638
|
+
this.source = e, this.littleEndian = t, this.bigTiff = r, this.eager = s;
|
|
1639
|
+
}
|
|
1640
|
+
async getSlice(e, t) {
|
|
1641
|
+
const r = this.bigTiff ? 4048 : 1024;
|
|
1642
|
+
return new re((await this.source.fetch([{
|
|
1643
|
+
offset: e,
|
|
1644
|
+
length: typeof t < "u" ? t : r
|
|
1645
|
+
}]))[0], e, this.littleEndian, this.bigTiff);
|
|
1646
|
+
}
|
|
1647
|
+
async parseFileDirectoryAt(e) {
|
|
1648
|
+
const t = this.bigTiff ? 20 : 12, r = this.bigTiff ? 8 : 2;
|
|
1649
|
+
let s = await this.getSlice(e);
|
|
1650
|
+
const i = this.bigTiff ? s.readUint64(e) : s.readUint16(e), a = i * (t + (this.bigTiff ? 16 : 6));
|
|
1651
|
+
s.covers(e, a) || (s = await this.getSlice(e, a));
|
|
1652
|
+
const o = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
1653
|
+
let l = e + (this.bigTiff ? 8 : 2);
|
|
1654
|
+
for (let c = 0; c < i; l += t, ++c) {
|
|
1655
|
+
const h = s.readUint16(l), d = s.readUint16(l + 2), u = this.bigTiff ? s.readUint64(l + 4) : s.readUint32(l + 4);
|
|
1656
|
+
let g = null, p = null, w = null;
|
|
1657
|
+
const m = G(d), b = l + (this.bigTiff ? 12 : 8), I = te[h]?.isArray, S = te[h]?.eager || this.eager;
|
|
1658
|
+
if (m * u <= (this.bigTiff ? 8 : 4)) g = z(O(d, u), R(s, d), s, d, u, b, I);
|
|
1659
|
+
else {
|
|
1660
|
+
const v = s.readOffset(b), T = G(d) * u;
|
|
1661
|
+
if (s.covers(v, T)) g = z(O(d, u), R(s, d), s, d, u, v, I);
|
|
1662
|
+
else if (S) {
|
|
1663
|
+
const k = await this.getSlice(v, T);
|
|
1664
|
+
g = z(O(d, u), R(k, d), k, d, u, v, I);
|
|
1665
|
+
} else I ? w = new kr(this.source, v, this.littleEndian, d, u) : p = async () => {
|
|
1666
|
+
const k = await this.getSlice(v, T);
|
|
1667
|
+
return z(O(d, u), R(k, d), k, d, u, v, I);
|
|
1668
|
+
};
|
|
1669
|
+
}
|
|
1670
|
+
g !== null ? o.set(h, g) : p !== null ? n.set(h, p) : w !== null && f.set(h, w);
|
|
1671
|
+
}
|
|
1672
|
+
return new Pr(o, n, f, s.readOffset(e + r + t * i));
|
|
1673
|
+
}
|
|
1674
|
+
};
|
|
1675
|
+
function he(e, t, r, s) {
|
|
1676
|
+
let i = null, a = null;
|
|
1677
|
+
const o = G(t);
|
|
1678
|
+
switch (t) {
|
|
1679
|
+
case y.BYTE:
|
|
1680
|
+
case y.ASCII:
|
|
1681
|
+
case y.UNDEFINED:
|
|
1682
|
+
i = new Uint8Array(r), a = e.readUint8;
|
|
1683
|
+
break;
|
|
1684
|
+
case y.SBYTE:
|
|
1685
|
+
i = new Int8Array(r), a = e.readInt8;
|
|
1686
|
+
break;
|
|
1687
|
+
case y.SHORT:
|
|
1688
|
+
i = new Uint16Array(r), a = e.readUint16;
|
|
1689
|
+
break;
|
|
1690
|
+
case y.SSHORT:
|
|
1691
|
+
i = new Int16Array(r), a = e.readInt16;
|
|
1692
|
+
break;
|
|
1693
|
+
case y.LONG:
|
|
1694
|
+
case y.IFD:
|
|
1695
|
+
i = new Uint32Array(r), a = e.readUint32;
|
|
1696
|
+
break;
|
|
1697
|
+
case y.SLONG:
|
|
1698
|
+
i = new Int32Array(r), a = e.readInt32;
|
|
1699
|
+
break;
|
|
1700
|
+
case y.LONG8:
|
|
1701
|
+
case y.IFD8:
|
|
1702
|
+
i = new Array(r), a = e.readUint64;
|
|
1703
|
+
break;
|
|
1704
|
+
case y.SLONG8:
|
|
1705
|
+
i = new Array(r), a = e.readInt64;
|
|
1706
|
+
break;
|
|
1707
|
+
case y.RATIONAL:
|
|
1708
|
+
i = new Uint32Array(r * 2), a = e.readUint32;
|
|
1709
|
+
break;
|
|
1710
|
+
case y.SRATIONAL:
|
|
1711
|
+
i = new Int32Array(r * 2), a = e.readInt32;
|
|
1712
|
+
break;
|
|
1713
|
+
case y.FLOAT:
|
|
1714
|
+
i = new Float32Array(r), a = e.readFloat32;
|
|
1715
|
+
break;
|
|
1716
|
+
case y.DOUBLE:
|
|
1717
|
+
i = new Float64Array(r), a = e.readFloat64;
|
|
1718
|
+
break;
|
|
1719
|
+
default:
|
|
1720
|
+
}
|
|
1721
|
+
if (i === null || a === null) throw new RangeError(`Invalid field type: ${t}`);
|
|
1722
|
+
if (t === y.RATIONAL || t === y.SRATIONAL) for (let n = 0; n < r; n += 2)
|
|
1723
|
+
i[n] = a.call(e, s + n * o), i[n + 1] = a.call(e, s + (n * o + 4));
|
|
1724
|
+
else for (let n = 0; n < r; ++n) i[n] = a.call(e, s + n * o);
|
|
1725
|
+
return t === y.ASCII ? new TextDecoder("utf-8").decode(i) : i;
|
|
1726
|
+
}
|
|
1727
|
+
var W = class extends Error {
|
|
1728
|
+
constructor(e) {
|
|
1729
|
+
super(`No image at index ${e}`), this.index = e;
|
|
1730
|
+
}
|
|
1731
|
+
}, Dr = class {
|
|
1732
|
+
async getImage(e = 0) {
|
|
1733
|
+
throw new Error("Not implemented");
|
|
1734
|
+
}
|
|
1735
|
+
async getImageCount() {
|
|
1736
|
+
throw new Error("Not implemented");
|
|
1737
|
+
}
|
|
1738
|
+
async readRasters(e = {}) {
|
|
1739
|
+
const { window: t, width: r, height: s } = e;
|
|
1740
|
+
let { resX: i, resY: a, bbox: o } = e;
|
|
1741
|
+
const n = await this.getImage();
|
|
1742
|
+
let f = n;
|
|
1743
|
+
const l = await this.getImageCount(), c = n.getBoundingBox();
|
|
1744
|
+
if (t && o) throw new Error('Both "bbox" and "window" passed.');
|
|
1745
|
+
if (r || s) {
|
|
1746
|
+
if (t) {
|
|
1747
|
+
const [u, g] = n.getOrigin(), [p, w] = n.getResolution();
|
|
1748
|
+
o = [
|
|
1749
|
+
u + t[0] * p,
|
|
1750
|
+
g + t[1] * w,
|
|
1751
|
+
u + t[2] * p,
|
|
1752
|
+
g + t[3] * w
|
|
1753
|
+
];
|
|
1754
|
+
}
|
|
1755
|
+
const d = o || c;
|
|
1756
|
+
if (r) {
|
|
1757
|
+
if (i) throw new Error("Both width and resX passed");
|
|
1758
|
+
i = (d[2] - d[0]) / r;
|
|
1759
|
+
}
|
|
1760
|
+
if (s) {
|
|
1761
|
+
if (a) throw new Error("Both width and resY passed");
|
|
1762
|
+
a = (d[3] - d[1]) / s;
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
if (i || a) {
|
|
1766
|
+
const d = [];
|
|
1767
|
+
for (let u = 0; u < l; ++u) {
|
|
1768
|
+
const g = await this.getImage(u), p = g.fileDirectory.getValue("SubfileType"), w = g.fileDirectory.getValue("NewSubfileType");
|
|
1769
|
+
(u === 0 || p === 2 || (w || 0) & 1) && d.push(g);
|
|
1770
|
+
}
|
|
1771
|
+
d.sort((u, g) => u.getWidth() - g.getWidth());
|
|
1772
|
+
for (let u = 0; u < d.length; ++u) {
|
|
1773
|
+
const g = d[u], p = (c[2] - c[0]) / g.getWidth(), w = (c[3] - c[1]) / g.getHeight();
|
|
1774
|
+
if (f = g, i && i > p || a && a > w) break;
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
let h = t;
|
|
1778
|
+
if (o) {
|
|
1779
|
+
const [d, u] = n.getOrigin(), [g, p] = f.getResolution(n);
|
|
1780
|
+
h = [
|
|
1781
|
+
Math.round((o[0] - d) / g),
|
|
1782
|
+
Math.round((o[1] - u) / p),
|
|
1783
|
+
Math.round((o[2] - d) / g),
|
|
1784
|
+
Math.round((o[3] - u) / p)
|
|
1785
|
+
], h = [
|
|
1786
|
+
Math.min(h[0], h[2]),
|
|
1787
|
+
Math.min(h[1], h[3]),
|
|
1788
|
+
Math.max(h[0], h[2]),
|
|
1789
|
+
Math.max(h[1], h[3])
|
|
1790
|
+
];
|
|
1791
|
+
}
|
|
1792
|
+
return f.readRasters({
|
|
1793
|
+
...e,
|
|
1794
|
+
window: h
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
}, Or = class Xe extends Dr {
|
|
1798
|
+
constructor(t, r, s, i, a = {}) {
|
|
1799
|
+
super(), this.source = t, this.parser = new Fr(t, r, s, !1), this.littleEndian = r, this.bigTiff = s, this.firstIFDOffset = i, this.cache = a.cache || !1, this.ifdRequests = [], this.ghostValues = null;
|
|
1800
|
+
}
|
|
1801
|
+
async getSlice(t, r) {
|
|
1802
|
+
const s = this.bigTiff ? 4048 : 1024;
|
|
1803
|
+
return new re((await this.source.fetch([{
|
|
1804
|
+
offset: t,
|
|
1805
|
+
length: typeof r < "u" ? r : s
|
|
1806
|
+
}]))[0], t, this.littleEndian, this.bigTiff);
|
|
1807
|
+
}
|
|
1808
|
+
async requestIFD(t) {
|
|
1809
|
+
if (this.ifdRequests[t]) return this.ifdRequests[t];
|
|
1810
|
+
if (t === 0)
|
|
1811
|
+
return this.ifdRequests[t] = this.parser.parseFileDirectoryAt(this.firstIFDOffset), this.ifdRequests[t];
|
|
1812
|
+
if (!this.ifdRequests[t - 1]) try {
|
|
1813
|
+
this.ifdRequests[t - 1] = this.requestIFD(t - 1);
|
|
1814
|
+
} catch (r) {
|
|
1815
|
+
throw r instanceof W ? new W(t) : r;
|
|
1816
|
+
}
|
|
1817
|
+
return this.ifdRequests[t] = (async () => {
|
|
1818
|
+
const r = this.ifdRequests[t - 1];
|
|
1819
|
+
if (!r) throw new Error("Previous IFD request missing");
|
|
1820
|
+
const s = await r;
|
|
1821
|
+
if (s.nextIFDByteOffset === 0) throw new W(t);
|
|
1822
|
+
return this.parser.parseFileDirectoryAt(s.nextIFDByteOffset);
|
|
1823
|
+
})(), this.ifdRequests[t];
|
|
1824
|
+
}
|
|
1825
|
+
async getImage(t = 0) {
|
|
1826
|
+
return new ir(await this.requestIFD(t), this.littleEndian, this.cache, this.source);
|
|
1827
|
+
}
|
|
1828
|
+
async getImageCount() {
|
|
1829
|
+
let t = 0, r = !0;
|
|
1830
|
+
for (; r; ) try {
|
|
1831
|
+
await this.requestIFD(t), ++t;
|
|
1832
|
+
} catch (s) {
|
|
1833
|
+
if (s instanceof W) r = !1;
|
|
1834
|
+
else throw s;
|
|
1835
|
+
}
|
|
1836
|
+
return t;
|
|
1837
|
+
}
|
|
1838
|
+
async getGhostValues() {
|
|
1839
|
+
const t = this.bigTiff ? 16 : 8;
|
|
1840
|
+
if (this.ghostValues !== null) return this.ghostValues;
|
|
1841
|
+
const r = "GDAL_STRUCTURAL_METADATA_SIZE=", s = 130;
|
|
1842
|
+
let i = await this.getSlice(t, s);
|
|
1843
|
+
if (r === he(i, y.ASCII, 30, t)) {
|
|
1844
|
+
const a = he(i, y.ASCII, s, t).split(`
|
|
1845
|
+
`)[0], o = Number(a.split("=")[1].split(" ")[0]) + a.length;
|
|
1846
|
+
o > s && (i = await this.getSlice(t, o));
|
|
1847
|
+
const n = he(i, y.ASCII, o, t), f = {};
|
|
1848
|
+
n.split(`
|
|
1849
|
+
`).filter((l) => l.length > 0).map((l) => l.split("=")).forEach(([l, c]) => {
|
|
1850
|
+
f[l] = c;
|
|
1851
|
+
}), this.ghostValues = f;
|
|
1852
|
+
}
|
|
1853
|
+
return this.ghostValues;
|
|
1854
|
+
}
|
|
1855
|
+
static async fromSource(t, r, s) {
|
|
1856
|
+
const i = (await t.fetch([{
|
|
1857
|
+
offset: 0,
|
|
1858
|
+
length: 1024
|
|
1859
|
+
}], s))[0], a = new ar(i), o = a.getUint16(0, !1);
|
|
1860
|
+
let n;
|
|
1861
|
+
if (o === 18761) n = !0;
|
|
1862
|
+
else if (o === 19789) n = !1;
|
|
1863
|
+
else throw new TypeError("Invalid byte order value.");
|
|
1864
|
+
const f = a.getUint16(2, n);
|
|
1865
|
+
let l;
|
|
1866
|
+
if (f === 42) l = !1;
|
|
1867
|
+
else if (f === 43) {
|
|
1868
|
+
if (l = !0, a.getUint16(4, n) !== 8) throw new Error("Unsupported offset byte-size.");
|
|
1869
|
+
} else throw new TypeError("Invalid magic number.");
|
|
1870
|
+
const c = l ? a.getUint64(8, n) : a.getUint32(4, n);
|
|
1871
|
+
return new Xe(t, n, l, c, r);
|
|
1872
|
+
}
|
|
1873
|
+
close() {
|
|
1874
|
+
return typeof this.source.close == "function" ? this.source.close() : !1;
|
|
1875
|
+
}
|
|
1876
|
+
};
|
|
1877
|
+
async function Fs(e, t = {}, r) {
|
|
1878
|
+
return Or.fromSource(xr(e, t), void 0, r);
|
|
1879
|
+
}
|
|
1880
|
+
export {
|
|
1881
|
+
Fs as fromUrl
|
|
1882
|
+
};
|