maplibre-gl-components 0.20.3 → 0.20.5
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/dist/{ControlGrid-96YvXuIh.cjs → ControlGrid-BWs3QP5M.cjs} +9 -9
- package/dist/{ControlGrid-BhXCg6_6.js → ControlGrid-V59Ovz6J.js} +39 -35
- package/dist/{DuckDBConverter-uWVU-eAR.js → DuckDBConverter-BiaCHtYV.js} +1 -1
- package/dist/{DuckDBConverter-BfGlAhtm.cjs → DuckDBConverter-D-Von6Le.cjs} +1 -1
- package/dist/{ShapefileConverter-Ch3A6x1f.js → ShapefileConverter-CWtJ9IOJ.js} +1 -1
- package/dist/{ShapefileConverter-BHHDCN1E.cjs → ShapefileConverter-wLF296OF.cjs} +1 -1
- package/dist/{geotiff-C2ECK1Ba.cjs → geotiff-CNfLW-N0.cjs} +2 -2
- package/dist/{geotiff--1panAaD.js → geotiff-D9_iwF_H.js} +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{lerc-BeWDdDnk.js → lerc-DZUVO3mM.js} +1 -1
- package/dist/{lerc-DAhaV--0.cjs → lerc-aWBIByFf.cjs} +1 -1
- package/dist/{maplibre-geoman.es-Pay8LQVk.cjs → maplibre-geoman.es-DcHAy9ox.cjs} +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/core/ZarrLayer.d.ts +9 -2
- package/dist/types/lib/core/ZarrLayer.d.ts.map +1 -1
- package/dist/types/lib/core/types.d.ts +57 -0
- package/dist/types/lib/core/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -3054,7 +3054,7 @@ var mq = {
|
|
|
3054
3054
|
if (t === "shapefile") {
|
|
3055
3055
|
if (!this._shapefileConverter) {
|
|
3056
3056
|
this._updateLoading("Loading Shapefile converter...");
|
|
3057
|
-
const { getShapefileConverter: s } = await import("./ShapefileConverter-
|
|
3057
|
+
const { getShapefileConverter: s } = await import("./ShapefileConverter-CWtJ9IOJ.js").then((a) => a.n);
|
|
3058
3058
|
this._shapefileConverter = s();
|
|
3059
3059
|
}
|
|
3060
3060
|
const r = await this._shapefileConverter.convert(n, e.name, i);
|
|
@@ -3062,9 +3062,9 @@ var mq = {
|
|
|
3062
3062
|
} else if (Fae(t)) {
|
|
3063
3063
|
if (!this._duckdbConverter) {
|
|
3064
3064
|
this._updateLoading("Loading DuckDB converter...");
|
|
3065
|
-
const { getDuckDBConverter: s } = await import("./DuckDBConverter-
|
|
3065
|
+
const { getDuckDBConverter: s } = await import("./DuckDBConverter-BiaCHtYV.js").then((a) => a.n);
|
|
3066
3066
|
if (this._duckdbConverter = s(), this._options.duckdbBundleUrl) {
|
|
3067
|
-
const { DuckDBConverter: a } = await import("./DuckDBConverter-
|
|
3067
|
+
const { DuckDBConverter: a } = await import("./DuckDBConverter-BiaCHtYV.js").then((l) => l.n);
|
|
3068
3068
|
this._duckdbConverter = new a(this._options.duckdbBundleUrl);
|
|
3069
3069
|
}
|
|
3070
3070
|
}
|
|
@@ -4530,7 +4530,7 @@ var ioe = ["none", "bone", "bwr", "cividis", "cool", "coolwarm", "gray", "hot",
|
|
|
4530
4530
|
if (!(i instanceof Error ? i.message : String(i)).includes("non-unsigned integers not yet supported")) throw i;
|
|
4531
4531
|
const { parseCOGTileMatrixSet: n, texture: r } = await import("@developmentseed/deck.gl-geotiff");
|
|
4532
4532
|
if (typeof n != "function" || typeof r?.inferTextureFormat != "function") throw i;
|
|
4533
|
-
const { fromUrl: s } = await import("./geotiff
|
|
4533
|
+
const { fromUrl: s } = await import("./geotiff-D9_iwF_H.js"), { CreateTexture: a, FilterNoDataVal: l, MaskTexture: h } = await import("@developmentseed/deck.gl-raster/gpu-modules"), d = await import("./lib-CNQtqzfc.js"), p = d.default || d, g = this.props.geotiff, v = typeof g == "string" ? await s(g) : g, y = this.props.geoKeysParser, E = await n(v, y), S = await v.getImage(), R = await v.getImageCount(), I = [];
|
|
4534
4534
|
for (let ae = 0; ae < R; ae++) I.push(await v.getImage(ae));
|
|
4535
4535
|
const k = await y(S.getGeoKeys());
|
|
4536
4536
|
if (!k) throw new Error("Could not determine source projection from GeoTIFF geo keys");
|
|
@@ -5236,7 +5236,7 @@ var poe = class {
|
|
|
5236
5236
|
<div class="segment-label">Segments</div>
|
|
5237
5237
|
<div class="segment-list"></div>
|
|
5238
5238
|
</div>
|
|
5239
|
-
`, this._resultValueEl = a.querySelector(".result-value"), this._resultUnitEl = a.querySelector(".result-unit"), this._segmentListEl = a.querySelector(".segment-list"), i.appendChild(a), this._instructionsEl = document.createElement("div"), this._instructionsEl.className = "measure-instructions", this._instructionsEl.textContent = "Click
|
|
5239
|
+
`, this._resultValueEl = a.querySelector(".result-value"), this._resultUnitEl = a.querySelector(".result-unit"), this._segmentListEl = a.querySelector(".segment-list"), i.appendChild(a), this._instructionsEl = document.createElement("div"), this._instructionsEl.className = "measure-instructions", this._instructionsEl.textContent = "Click Start, then click the map to add points. Double-click to finish.", i.appendChild(this._instructionsEl), this._measurementsListEl = document.createElement("div"), this._measurementsListEl.className = "measurements-list", this._measurementsListEl.style.display = "none", i.appendChild(this._measurementsListEl);
|
|
5240
5240
|
const l = document.createElement("div");
|
|
5241
5241
|
return l.className = "measure-actions", l.innerHTML = `
|
|
5242
5242
|
<button type="button" class="action-btn primary start-btn">
|
|
@@ -5372,7 +5372,7 @@ var poe = class {
|
|
|
5372
5372
|
_cancelDrawing() {
|
|
5373
5373
|
this._stopDrawing(), this._clearMarkers(), this._state.currentPoints = [], this._state.currentValue = 0, this._state.currentSegments = [], this._updateMapGeometry();
|
|
5374
5374
|
const e = this._panel?.querySelector(".measure-result");
|
|
5375
|
-
e && (e.style.display = "none"), this._instructionsEl && (this._instructionsEl.textContent = "Click
|
|
5375
|
+
e && (e.style.display = "none"), this._instructionsEl && (this._instructionsEl.textContent = "Click Start, then click the map to add points. Double-click to finish.");
|
|
5376
5376
|
}
|
|
5377
5377
|
_updateMeasurement() {
|
|
5378
5378
|
const e = this._state.currentPoints;
|
|
@@ -6728,8 +6728,8 @@ var Loe = '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBo
|
|
|
6728
6728
|
off(e, t) {
|
|
6729
6729
|
this._eventHandlers.get(e)?.delete(t);
|
|
6730
6730
|
}
|
|
6731
|
-
async addLayer(e, t) {
|
|
6732
|
-
e && (this._state.url = e), t && (this._state.variable = t), await this._addLayer();
|
|
6731
|
+
async addLayer(e, t, i) {
|
|
6732
|
+
e && (this._state.url = e), t && (this._state.variable = t), await this._addLayer(i);
|
|
6733
6733
|
}
|
|
6734
6734
|
removeLayer(e) {
|
|
6735
6735
|
this._removeLayer(e), this._render();
|
|
@@ -6996,32 +6996,36 @@ var Loe = '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBo
|
|
|
6996
6996
|
const e = document.getElementById("zarr-colormap-preview");
|
|
6997
6997
|
e && (e.style.background = `linear-gradient(to right, ${this._state.colormap.join(", ")})`);
|
|
6998
6998
|
}
|
|
6999
|
-
async _addLayer() {
|
|
7000
|
-
|
|
7001
|
-
|
|
6999
|
+
async _addLayer(e) {
|
|
7000
|
+
const t = !!e?.store;
|
|
7001
|
+
if (!this._map || !t && !this._state.url || !this._state.variable) {
|
|
7002
|
+
this._state.error = t ? "Please enter a variable name." : "Please enter a Zarr URL and variable name.", this._render();
|
|
7002
7003
|
return;
|
|
7003
7004
|
}
|
|
7004
7005
|
this._state.loading = !0, this._state.error = null, this._state.status = null, this._render();
|
|
7005
7006
|
try {
|
|
7006
|
-
const { ZarrLayer:
|
|
7007
|
-
id:
|
|
7008
|
-
source: this._state.url,
|
|
7007
|
+
const { ZarrLayer: i } = await import("@carbonplan/zarr-layer"), n = `zarr-layer-${this._layerCounter++}`, r = e?.selector ?? (this._state.selector && Object.keys(this._state.selector).length > 0 ? this._state.selector : void 0), s = {
|
|
7008
|
+
id: n,
|
|
7009
7009
|
variable: this._state.variable,
|
|
7010
|
-
colormap: this._state.colormap,
|
|
7011
|
-
clim: this._state.clim,
|
|
7012
|
-
opacity: this._state.layerOpacity,
|
|
7013
|
-
selector:
|
|
7014
|
-
}
|
|
7015
|
-
|
|
7016
|
-
const
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7010
|
+
colormap: e?.colormap ?? this._state.colormap,
|
|
7011
|
+
clim: e?.clim ?? this._state.clim,
|
|
7012
|
+
opacity: e?.opacity ?? this._state.layerOpacity,
|
|
7013
|
+
selector: r
|
|
7014
|
+
};
|
|
7015
|
+
this._state.url && (s.source = this._state.url), e?.store && (s.store = e.store), e?.zarrVersion && (s.zarrVersion = e.zarrVersion), e?.transformRequest && (s.transformRequest = e.transformRequest), e?.crs && (s.crs = e.crs), e?.proj4 && (s.proj4 = e.proj4), e?.bounds && (s.bounds = e.bounds), e?.spatialDimensions && (s.spatialDimensions = e.spatialDimensions);
|
|
7016
|
+
const a = { ...s };
|
|
7017
|
+
delete a.store, delete a.transformRequest;
|
|
7018
|
+
const l = this._state.layerName?.trim();
|
|
7019
|
+
l && (a._layerName = l), this._zarrLayerPropsMap.set(n, a);
|
|
7020
|
+
const h = new i(s);
|
|
7021
|
+
this._zarrLayers.set(n, h);
|
|
7022
|
+
let d;
|
|
7023
|
+
this._options.beforeId && (this._map.getLayer(this._options.beforeId) ? d = this._options.beforeId : console.warn(`[ZarrLayerControl] beforeId "${this._options.beforeId}" not found in map layers, adding layer on top`)), d ? this._map.addLayer(h, d) : this._map.addLayer(h), this._state.pickable && this._setupLayerClickHandler(n), this._state.hasLayer = this._zarrLayers.size > 0, this._state.layerCount = this._zarrLayers.size, this._state.layers = this._buildLayerInfoList(), this._state.loading = !1, this._state.status = "Zarr layer added successfully.", this._state.layerName = "", this._render(), this._emit("layeradd", {
|
|
7020
7024
|
url: this._state.url,
|
|
7021
|
-
layerId:
|
|
7025
|
+
layerId: n
|
|
7022
7026
|
});
|
|
7023
|
-
} catch (
|
|
7024
|
-
this._state.loading = !1, this._state.error = `Failed to load Zarr: ${
|
|
7027
|
+
} catch (i) {
|
|
7028
|
+
this._state.loading = !1, this._state.error = `Failed to load Zarr: ${i instanceof Error ? i.message : String(i)}`, this._render(), this._emit("error", { error: this._state.error });
|
|
7025
7029
|
}
|
|
7026
7030
|
}
|
|
7027
7031
|
_setupLayerClickHandler(e) {
|
|
@@ -8222,7 +8226,7 @@ var Goe = [
|
|
|
8222
8226
|
this._state.loading = !0, this._state.error = null, this._state.status = null, this._render();
|
|
8223
8227
|
try {
|
|
8224
8228
|
await this._ensureOverlay();
|
|
8225
|
-
const { COGLayer: l } = await import("@developmentseed/deck.gl-geotiff"), { fromUrl: h } = await import("./geotiff
|
|
8229
|
+
const { COGLayer: l } = await import("@developmentseed/deck.gl-geotiff"), { fromUrl: h } = await import("./geotiff-D9_iwF_H.js");
|
|
8226
8230
|
this._patchCOGLayer(l);
|
|
8227
8231
|
const d = `stac-${this._state.stacItem?.id || "layer"}-rgb-${this._layerCounter++}`, [p, g, v] = await Promise.all([
|
|
8228
8232
|
h(r.href),
|
|
@@ -8390,7 +8394,7 @@ var Goe = [
|
|
|
8390
8394
|
e.prototype._parseGeoTIFF = async function() {
|
|
8391
8395
|
const { parseCOGTileMatrixSet: n, texture: r } = await import("@developmentseed/deck.gl-geotiff");
|
|
8392
8396
|
if (typeof n != "function" || typeof r?.inferTextureFormat != "function") return i.call(this);
|
|
8393
|
-
const { fromUrl: s } = await import("./geotiff
|
|
8397
|
+
const { fromUrl: s } = await import("./geotiff-D9_iwF_H.js"), { CreateTexture: a, FilterNoDataVal: l, Colormap: h } = await import("@developmentseed/deck.gl-raster/gpu-modules"), d = await import("./lib-CNQtqzfc.js"), p = d.default || d, g = this.props.geotiff, v = typeof g == "string" ? await s(g) : g, y = this.props.geoKeysParser;
|
|
8394
8398
|
let E;
|
|
8395
8399
|
try {
|
|
8396
8400
|
E = await n(v, y);
|
|
@@ -10073,7 +10077,7 @@ var a9 = class {
|
|
|
10073
10077
|
throw new Error("CORS error: Unable to fetch the file. The server doesn't allow cross-origin requests.");
|
|
10074
10078
|
}
|
|
10075
10079
|
async _loadGeoParquet(e) {
|
|
10076
|
-
const { getDuckDBConverter: t } = await import("./DuckDBConverter-
|
|
10080
|
+
const { getDuckDBConverter: t } = await import("./DuckDBConverter-BiaCHtYV.js").then((a) => a.n), i = t(), n = await this._fetchWithCorsProxy(e);
|
|
10077
10081
|
let r;
|
|
10078
10082
|
try {
|
|
10079
10083
|
r = await n.arrayBuffer();
|
|
@@ -10117,7 +10121,7 @@ var a9 = class {
|
|
|
10117
10121
|
}
|
|
10118
10122
|
async _setupViewportLoading(e, t, i) {
|
|
10119
10123
|
if (!this._map) return;
|
|
10120
|
-
const { getDuckDBConverter: n } = await import("./DuckDBConverter-
|
|
10124
|
+
const { getDuckDBConverter: n } = await import("./DuckDBConverter-BiaCHtYV.js").then((a) => a.n), r = n(), s = `${e}.parquet`;
|
|
10121
10125
|
try {
|
|
10122
10126
|
await r.registerRemoteParquet(t, s);
|
|
10123
10127
|
const a = await r.getParquetSchema(s);
|
|
@@ -10146,7 +10150,7 @@ var a9 = class {
|
|
|
10146
10150
|
for (const n of t.layerIds) this._map.getLayer(n) && this._map.setLayoutProperty(n, "visibility", "visible");
|
|
10147
10151
|
this._viewportLoadingState.set(e, !0);
|
|
10148
10152
|
try {
|
|
10149
|
-
const { getDuckDBConverter: n } = await import("./DuckDBConverter-
|
|
10153
|
+
const { getDuckDBConverter: n } = await import("./DuckDBConverter-BiaCHtYV.js").then((d) => d.n), r = n(), s = this._map.getBounds(), a = [
|
|
10150
10154
|
s.getWest(),
|
|
10151
10155
|
s.getSouth(),
|
|
10152
10156
|
s.getEast(),
|
|
@@ -10161,7 +10165,7 @@ var a9 = class {
|
|
|
10161
10165
|
}
|
|
10162
10166
|
async _cleanupViewportLoading() {
|
|
10163
10167
|
if (this._map && this._viewportHandler && (this._map.off("moveend", this._viewportHandler), this._viewportHandler = void 0), this._viewportLoadingLayers.size > 0) try {
|
|
10164
|
-
const { getDuckDBConverter: e } = await import("./DuckDBConverter-
|
|
10168
|
+
const { getDuckDBConverter: e } = await import("./DuckDBConverter-BiaCHtYV.js").then((i) => i.n), t = e();
|
|
10165
10169
|
for (const i of this._viewportLoadingLayers) {
|
|
10166
10170
|
const n = this._vectorLayers.get(i);
|
|
10167
10171
|
n?.duckdbFileName && await t.unregisterFile(n.duckdbFileName);
|
|
@@ -10174,7 +10178,7 @@ var a9 = class {
|
|
|
10174
10178
|
const t = this._vectorLayers.get(e);
|
|
10175
10179
|
if (!(!t?.viewportLoading || !t.duckdbFileName)) {
|
|
10176
10180
|
try {
|
|
10177
|
-
const { getDuckDBConverter: i } = await import("./DuckDBConverter-
|
|
10181
|
+
const { getDuckDBConverter: i } = await import("./DuckDBConverter-BiaCHtYV.js").then((n) => n.n);
|
|
10178
10182
|
await i().unregisterFile(t.duckdbFileName);
|
|
10179
10183
|
} catch {
|
|
10180
10184
|
}
|
|
@@ -11048,7 +11052,7 @@ var rle = class {
|
|
|
11048
11052
|
throw new Error("CORS error: Unable to fetch the file. The server doesn't allow cross-origin requests.");
|
|
11049
11053
|
}
|
|
11050
11054
|
async _loadGeoParquet(e) {
|
|
11051
|
-
const { getDuckDBConverter: t } = await import("./DuckDBConverter-
|
|
11055
|
+
const { getDuckDBConverter: t } = await import("./DuckDBConverter-BiaCHtYV.js").then((a) => a.n), i = t(), n = await this._fetchWithCorsProxy(e);
|
|
11052
11056
|
let r;
|
|
11053
11057
|
try {
|
|
11054
11058
|
r = await n.arrayBuffer();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var q=Object.create;var v=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var M=(e,t,r,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of J(t))!I.call(e,o)&&o!==r&&v(e,o,{get:()=>t[o],enumerable:!(p=G(t,o))||p.enumerable});return e};var K=(e,t,r)=>(r=e!=null?q(W(e)):{},M(t||!e||!e.__esModule?v(r,"default",{value:e,enumerable:!0}):r,e));const H=require("./ControlGrid-
|
|
1
|
+
var q=Object.create;var v=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var M=(e,t,r,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of J(t))!I.call(e,o)&&o!==r&&v(e,o,{get:()=>t[o],enumerable:!(p=G(t,o))||p.enumerable});return e};var K=(e,t,r)=>(r=e!=null?q(W(e)):{},M(t||!e||!e.__esModule?v(r,"default",{value:e,enumerable:!0}):r,e));const H=require("./ControlGrid-BWs3QP5M.cjs");var Y=H.__exportAll({DuckDBConverter:()=>T,getDuckDBConverter:()=>C}),D=null;function C(){return D||(D=new T),D}var T=class{_duckdb=null;_db=null;_worker=null;_initialized=!1;_initializing=!1;_bundleUrl;constructor(e){this._bundleUrl=e}isReady(){return this._initialized&&this._db!==null}async initialize(e){if(!this._initialized){if(this._initializing){for(;this._initializing;)await new Promise(t=>setTimeout(t,50));return}this._initializing=!0;try{e?.({stage:"initializing",percent:0,message:"Loading DuckDB WASM..."});let t;try{const n=await import("@duckdb/duckdb-wasm");t=n.default||n}catch(n){throw new Error(`DuckDB WASM is not installed or failed to load. Install it with: npm install @duckdb/duckdb-wasm. Error: ${n instanceof Error?n.message:"Unknown error"}`)}this._duckdb=t,e?.({stage:"initializing",percent:30,message:"Selecting DuckDB bundle..."});let r;if(this._duckdb.getJsDelivrBundles){const n=this._duckdb.getJsDelivrBundles();r=await this._duckdb.selectBundle(n)}else{const n=this._getJsDelivrBundles();r=await this._duckdb.selectBundle(n)}e?.({stage:"initializing",percent:50,message:"Instantiating DuckDB..."});const p=new this._duckdb.ConsoleLogger(4);let o,a=null;try{a=URL.createObjectURL(new Blob([`importScripts("${r.mainWorker}");`],{type:"text/javascript"})),o=new Worker(a)}catch(n){throw a&&URL.revokeObjectURL(a),new Error(`Failed to create DuckDB worker: ${n instanceof Error?n.message:"Unknown error"}`)}this._worker=o;const g=new this._duckdb.AsyncDuckDB(p,o);try{await g.instantiate(r.mainModule,r.pthreadWorker)}catch(n){throw new Error(`Failed to instantiate DuckDB: ${n instanceof Error?n.message:"Unknown error"}`)}a&&URL.revokeObjectURL(a),this._db=g,e?.({stage:"initializing",percent:70,message:"Loading spatial extension..."});const s=await this._db.connect();try{await s.query("INSTALL spatial"),await s.query("LOAD spatial")}catch(n){console.warn("Failed to load spatial extension, some features may not work:",n)}finally{await s.close()}this._initialized=!0,e?.({stage:"initializing",percent:100,message:"DuckDB ready"})}catch(t){throw e?.({stage:"error",message:`Failed to initialize DuckDB: ${t instanceof Error?t.message:"Unknown error"}`}),t}finally{this._initializing=!1}}}_getJsDelivrBundles(){const e=this._bundleUrl||"https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@latest/dist";return{mvp:{mainModule:`${e}/duckdb-mvp.wasm`,mainWorker:`${e}/duckdb-browser-mvp.worker.js`},eh:{mainModule:`${e}/duckdb-eh.wasm`,mainWorker:`${e}/duckdb-browser-eh.worker.js`}}}async convert(e,t,r){const p=performance.now(),o=this._detectFormat(t);if(this.isReady()||await this.initialize(r),!this._db)throw new Error("DuckDB not initialized");r?.({stage:"loading",percent:0,message:`Loading ${t}...`});const a=new Uint8Array(e);await this._db.registerFileBuffer(t,a);const g=await this._db.connect();try{r?.({stage:"converting",percent:30,message:"Reading spatial data..."});let s;o==="geoparquet"||o==="parquet"?s=`read_parquet('${t}')`:s=`ST_Read('${t}')`;const n=(await g.query(`
|
|
2
2
|
DESCRIBE SELECT * FROM ${s}
|
|
3
3
|
`)).toArray();let c=null,h="",f=null,u=null,l=null;const d=[],S=["lat","latitude","y","lat_y","point_y"],B=["lon","lng","long","longitude","x","lon_x","long_x","point_x"],w=["wkt","wkt_geom","wkt_geometry","geometry_wkt"];for(const m of n){const i=m.column_name,E=m.column_type?.toUpperCase()||"",_=i.toLowerCase(),R=E.includes("GEOMETRY"),O=_==="geom"||_==="geometry"||_==="wkb_geometry"||_==="the_geom"||_==="shape",A=E.includes("BLOB")&&O;R||O||A?c||(c=i,h=E):S.includes(_)&&!f?(f=i,d.push(i)):B.includes(_)&&!u?(u=i,d.push(i)):w.includes(_)&&!l?l=i:d.push(i)}let y=!1,L=!1;if(!c)if(l)L=!0;else if(f&&u){y=!0;const m=d.indexOf(f);m>-1&&d.splice(m,1);const i=d.indexOf(u);i>-1&&d.splice(i,1)}else throw new Error("No geometry column found in the file. For CSV/Excel files, include a geometry column, WKT column, or lat/lon columns.");r?.({stage:"converting",percent:50,message:"Converting to GeoJSON..."});const x=d.length>0?`json_object(${d.map(m=>`'${m}', "${m}"`).join(", ")})`:"'{}'::JSON";let k,b;y&&f&&u?(k=`ST_AsGeoJSON(ST_Point("${u}", "${f}"))`,b=`"${f}" IS NOT NULL AND "${u}" IS NOT NULL`):L&&l?(k=`ST_AsGeoJSON(ST_GeomFromText("${l}"))`,b=`"${l}" IS NOT NULL AND "${l}" != ''`):h.includes("BLOB")?(k=`ST_AsGeoJSON(ST_GeomFromWKB("${c}"))`,b=`"${c}" IS NOT NULL`):(k=`ST_AsGeoJSON("${c}")`,b=`"${c}" IS NOT NULL`);const F=(await g.query(`
|
|
4
4
|
SELECT json_object(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var g=Object.create;var f=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var C=(t,i,r,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of m(i))!v.call(t,e)&&e!==r&&f(t,e,{get:()=>i[e],enumerable:!(n=y(i,e))||n.enumerable});return t};var _=(t,i,r)=>(r=t!=null?g(d(t)):{},C(i||!t||!t.__esModule?f(r,"default",{value:t,enumerable:!0}):r,t));const j=require("./ControlGrid-
|
|
1
|
+
var g=Object.create;var f=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var C=(t,i,r,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of m(i))!v.call(t,e)&&e!==r&&f(t,e,{get:()=>i[e],enumerable:!(n=y(i,e))||n.enumerable});return t};var _=(t,i,r)=>(r=t!=null?g(d(t)):{},C(i||!t||!t.__esModule?f(r,"default",{value:t,enumerable:!0}):r,t));const j=require("./ControlGrid-BWs3QP5M.cjs");var w=j.__exportAll({ShapefileConverter:()=>o,getShapefileConverter:()=>u}),o=class{_shpjs=null;_initialized=!1;isReady(){return this._initialized&&this._shpjs!==null}async initialize(t){if(!this._initialized){t?.({stage:"initializing",percent:0,message:"Loading shapefile parser..."});try{this._shpjs=await import("shpjs"),this._initialized=!0,t?.({stage:"initializing",percent:100,message:"Shapefile parser ready"})}catch{throw new Error("shpjs is not installed. Install it with: npm install shpjs")}}}async convert(t,i,r){const n=performance.now();this.isReady()||await this.initialize(r),r?.({stage:"loading",percent:10,message:`Loading ${i}...`});try{r?.({stage:"converting",percent:30,message:"Parsing shapefile..."});const e=await(this._shpjs.default||this._shpjs)(t);r?.({stage:"converting",percent:80,message:"Building feature collection..."});let a;Array.isArray(e)?a={type:"FeatureCollection",features:e.flatMap(s=>s.features||[])}:e.type==="FeatureCollection"?a=e:e.type==="Feature"?a={type:"FeatureCollection",features:[e]}:a={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:e}]};const p=new Set;for(const s of a.features)s.geometry&&p.add(s.geometry.type);const c=performance.now(),h={originalFormat:"shapefile",featureCount:a.features.length,geometryTypes:Array.from(p),fileSize:t.byteLength,conversionTimeMs:Math.round(c-n)};return r?.({stage:"complete",percent:100,message:`Converted ${a.features.length} features`}),{geojson:a,warnings:[],metadata:h}}catch(e){throw r?.({stage:"error",message:`Failed to parse shapefile: ${e instanceof Error?e.message:"Unknown error"}`}),e}}dispose(){this._shpjs=null,this._initialized=!1}},l=null;function u(){return l||(l=new o),l}Object.defineProperty(exports,"ShapefileConverter",{enumerable:!0,get:function(){return o}});Object.defineProperty(exports,"ShapefileConverter_exports",{enumerable:!0,get:function(){return w}});Object.defineProperty(exports,"getShapefileConverter",{enumerable:!0,get:function(){return u}});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const Pe=require("./ControlGrid-
|
|
1
|
+
const Pe=require("./ControlGrid-BWs3QP5M.cjs"),Pr=require("./basedecoder-Zw0CbD9L.cjs"),d=require("./globals-B4iCNAg9.cjs");var tt="Cannot convert undefined or null to object";function I(e){return(t,...r)=>rt(e,t,r)}function M(e,t){return I(he(e,t).get)}var{apply:rt,construct:xr,defineProperty:Fr,get:kr,getOwnPropertyDescriptor:he,getPrototypeOf:W,has:Dr,ownKeys:st,set:Or,setPrototypeOf:Rr}=Reflect,{EPSILON:it,MAX_SAFE_INTEGER:Mr,isFinite:Br,isNaN:Vr}=Number,{iterator:j,species:Ur,toStringTag:nt,for:Nr}=Symbol,ee=Object,{create:fe,defineProperty:at,freeze:Lr,is:Cr}=ee,oe=ee.prototype,zr=oe.__lookupGetter__?I(oe.__lookupGetter__):(e,t)=>{if(e==null)throw gt(tt);let r=ee(e);do{const s=he(r,t);if(s!==void 0)return ot(s,"get")?s.get:void 0}while((r=W(r))!==null)},ot=ee.hasOwn||I(oe.hasOwnProperty),xe=Array,qr=xe.isArray,te=xe.prototype,Gr=I(te.join),jr=I(te.push),Hr=I(te.toLocaleString),Fe=te[j],lt=I(Fe),{abs:Yr,trunc:$r}=Math,ue=ArrayBuffer,Xr=ue.isView,ke=ue.prototype,Kr=I(ke.slice),Zr=M(ke,"byteLength"),Ae=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:null,Jr=Ae&&M(Ae.prototype,"byteLength"),De=W(Uint8Array),Qr=De.from,E=De.prototype,Wr=E[j],es=I(E.keys),ts=I(E.values),rs=I(E.entries),ss=I(E.set),is=I(E.reverse),ns=I(E.fill),as=I(E.copyWithin),os=I(E.sort),ls=I(E.slice),cs=I(E.subarray),hs=M(E,"buffer"),fs=M(E,"byteOffset"),us=M(E,"length"),ds=M(E,nt),ct=Uint8Array,Oe=Uint16Array,de=Uint32Array,ht=Float32Array,z=W([][j]()),Re=I(z.next),ft=I((function*(){})().next),ut=W(z),Me=DataView.prototype,dt=I(Me.getUint16),gs=I(Me.setUint16),gt=TypeError,yt=WeakSet,Be=yt.prototype,ys=I(Be.add),ps=I(Be.has),ge=WeakMap,ye=ge.prototype,Ve=I(ye.get),ws=I(ye.has),pt=I(ye.set),Ue=new ge,wt=fe(null,{next:{value:function(){return Re(Ve(Ue,this))}},[j]:{value:function(){return this}}});function mt(e){if(e[j]===Fe&&z.next===Re)return e;const t=fe(wt);return pt(Ue,t,lt(e)),t}var bt=new ge,Tt=fe(ut,{next:{value:function(){return ft(Ve(bt,this))},writable:!0,configurable:!0}});for(const e of st(z))e!=="next"&&at(Tt,e,he(z,e));var vt=1/it,It=6103515625e-14,Ne=.0009765625,ms=Ne*It,bs=Ne*vt,Le=new ue(4),At=new ht(Le),St=new de(Le),F=new Oe(512),k=new ct(512);for(let e=0;e<256;++e){const t=e-127;t<-24?(F[e]=0,F[e|256]=32768,k[e]=24,k[e|256]=24):t<-14?(F[e]=1024>>-t-14,F[e|256]=1024>>-t-14|32768,k[e]=-t-1,k[e|256]=-t-1):t<=15?(F[e]=t+15<<10,F[e|256]=t+15<<10|32768,k[e]=13,k[e|256]=13):t<128?(F[e]=31744,F[e|256]=64512,k[e]=24,k[e|256]=24):(F[e]=31744,F[e|256]=64512,k[e]=13,k[e|256]=13)}var pe=new de(2048);for(let e=1;e<1024;++e){let t=e<<13,r=0;for(;(t&8388608)===0;)t<<=1,r-=8388608;t&=-8388609,r+=947912704,pe[e]=t|r}for(let e=1024;e<2048;++e)pe[e]=939524096+(e-1024<<13);var B=new de(64);for(let e=1;e<31;++e)B[e]=e<<23;B[31]=1199570944;B[32]=2147483648;for(let e=33;e<63;++e)B[e]=2147483648+(e-32<<23);B[63]=3347054592;var Ce=new Oe(64);for(let e=1;e<64;++e)e!==32&&(Ce[e]=1024);function Et(e){const t=e>>10;return St[0]=pe[Ce[t]+(e&1023)]+B[t],At[0]}function ze(e,t,...r){return Et(dt(e,t,...mt(r)))}function ie(e,t,r){const s=r&&r.debug||!1;s&&console.log("[xml-utils] getting "+t+" in "+e);const i=typeof e=="object"?e.outer:e,n=i.slice(0,i.indexOf(">")+1),o=['"',"'"];for(let a=0;a<o.length;a++){const f=o[a],l=t+"\\="+f+"([^"+f+"]*)"+f;s&&console.log("[xml-utils] pattern:",l);const c=new RegExp(l).exec(n);if(s&&console.log("[xml-utils] match:",c),c)return c[1]}}function _t(e,t,r){const s=new RegExp(t).exec(e.slice(r));return s?r+s.index:-1}function Se(e,t,r){const s=new RegExp(t).exec(e.slice(r));return s?r+s.index+s[0].length-1:-1}function Ee(e,t){const r=new RegExp(t,"g"),s=e.match(r);return s?s.length:0}function Pt(e,t,r){const s=r&&r.debug||!1,i=r&&r.startIndex||0;s&&console.log("[xml-utils] starting findTagByName with",t," and ",r);const n=_t(e,`<${t}[
|
|
2
2
|
>/]`,i);if(s&&console.log("[xml-utils] start:",n),n===-1)return;const o=e.slice(n+t.length);let a=Se(o,"^[^<]*[ /]>",0);const f=a!==-1&&o[a-1]==="/";if(s&&console.log("[xml-utils] selfClosing:",f),f===!1){let g=0,u=1,y=0;for(;(a=Se(o,"[ /]"+t+">",g))!==-1;){const p=o.substring(g,a+1);if(u+=Ee(p,"<"+t+`[
|
|
3
|
-
>]`),y+=Ee(p,"</"+t+">"),y>=u)break;g=a}}const l=n+t.length+a+1;if(s&&console.log("[xml-utils] end:",l),l===-1)return;const c=e.slice(n,l);let h;return f?h=null:h=c.slice(c.indexOf(">")+1,c.lastIndexOf("<")),{inner:h,outer:c,start:n,end:l}}function xt(e,t,r){const s=[],i=r&&r.debug||!1,n=r&&typeof r.nested=="boolean"?r.nested:!0;let o=r&&r.startIndex||0,a;for(;a=Pt(e,t,{debug:i,startIndex:o});)n?o=a.start+1+t.length:o=a.end,s.push(a);return i&&console.log("findTagsByName found",s.length,"tags"),s}function Ft(e,t){const{width:r,height:s}=e,i=new Uint8Array(r*s*3);let n;for(let o=0,a=0;o<e.length;++o,a+=3)n=256-e[o]/t*256,i[a]=n,i[a+1]=n,i[a+2]=n;return i}function kt(e,t){const{width:r,height:s}=e,i=new Uint8Array(r*s*3);let n;for(let o=0,a=0;o<e.length;++o,a+=3)n=e[o]/t*256,i[a]=n,i[a+1]=n,i[a+2]=n;return i}function Dt(e,t){const{width:r,height:s}=e,i=new Uint8Array(r*s*3),n=t.length/3,o=t.length/3*2;for(let a=0,f=0;a<e.length;++a,f+=3){const l=e[a];i[f]=t[l]/65536*256,i[f+1]=t[l+n]/65536*256,i[f+2]=t[l+o]/65536*256}return i}function Ot(e){const{width:t,height:r}=e,s=new Uint8Array(t*r*3);for(let i=0,n=0;i<e.length;i+=4,n+=3){const o=e[i],a=e[i+1],f=e[i+2],l=e[i+3];s[n]=255*((255-o)/256)*((255-l)/256),s[n+1]=255*((255-a)/256)*((255-l)/256),s[n+2]=255*((255-f)/256)*((255-l)/256)}return s}function Rt(e){const{width:t,height:r}=e,s=new Uint8ClampedArray(t*r*3);for(let i=0,n=0;i<e.length;i+=3,n+=3){const o=e[i],a=e[i+1],f=e[i+2];s[n]=o+1.402*(f-128),s[n+1]=o-.34414*(a-128)-.71414*(f-128),s[n+2]=o+1.772*(a-128)}return s}var Mt=.95047,Bt=1,Vt=1.08883;function Ut(e){const{width:t,height:r}=e,s=new Uint8Array(t*r*3);for(let i=0,n=0;i<e.length;i+=3,n+=3){const o=e[i+0],a=e[i+1]<<24>>24,f=e[i+2]<<24>>24;let l=(o+16)/116,c=a/500+l,h=l-f/200,g,u,y;c=Mt*(c*c*c>.008856?c*c*c:(c-16/116)/7.787),l=Bt*(l*l*l>.008856?l*l*l:(l-16/116)/7.787),h=Vt*(h*h*h>.008856?h*h*h:(h-16/116)/7.787),g=c*3.2406+l*-1.5372+h*-.4986,u=c*-.9689+l*1.8758+h*.0415,y=c*.0557+l*-.204+h*1.057,g=g>.0031308?1.055*g**(1/2.4)-.055:12.92*g,u=u>.0031308?1.055*u**(1/2.4)-.055:12.92*u,y=y>.0031308?1.055*y**(1/2.4)-.055:12.92*y,s[n]=Math.max(0,Math.min(1,g))*255,s[n+1]=Math.max(0,Math.min(1,u))*255,s[n+2]=Math.max(0,Math.min(1,y))*255}return s}var q=new Map;async function J(e){const t=!e.hasTag("StripOffsets");return{tileWidth:t?await e.loadValue("TileWidth"):await e.loadValue("ImageWidth"),tileHeight:t?await e.loadValue("TileLength"):await e.loadValue("RowsPerStrip")||await e.loadValue("ImageLength"),planarConfiguration:await e.loadValue("PlanarConfiguration"),bitsPerSample:await e.loadValue("BitsPerSample"),predictor:await e.loadValue("Predictor")||1}}function Nt(e,t,r=J,s=!0){Array.isArray(e)||(e=[e]),e.forEach(i=>{q.set(i,{importFn:t,decoderParameterFn:r,preferWorker:s})})}async function Lt(e,t){if(!q.has(e))throw new Error(`Unknown compression method identifier: ${e}`);const{decoderParameterFn:r}=q.get(e);return r(t)}async function Ct(e,t){if(!q.has(e))throw new Error(`Unknown compression method identifier: ${e}`);const{importFn:r}=q.get(e);return new(await r())(t)}var zt=[{cases:[void 0,1],importFn:()=>Promise.resolve().then(()=>require("./raw-C-CSxCoU.cjs")).then(e=>e.default),preferWorker:!1},{cases:5,importFn:()=>Promise.resolve().then(()=>require("./lzw-1HaU0PJK.cjs")).then(e=>e.default)},{cases:6,importFn:()=>{throw new Error("old style JPEG compression is not supported.")}},{cases:7,importFn:()=>Promise.resolve().then(()=>require("./jpeg-B6Sg6W8k.cjs")).then(e=>e.default),decoderParameterFn:async e=>({...await J(e),JPEGTables:await e.loadValue("JPEGTables")})},{cases:[8,32946],importFn:()=>Promise.resolve().then(()=>require("./deflate-DNeBKDsy.cjs")).then(e=>e.default)},{cases:32773,importFn:()=>Promise.resolve().then(()=>require("./packbits-D5Zovac7.cjs")).then(e=>e.default)},{cases:34887,importFn:()=>Promise.resolve().then(()=>require("./lerc-DAhaV--0.cjs")).then(async e=>(await e.zstd.init(),e)).then(e=>e.default),decoderParameterFn:async e=>({...await J(e),LercParameters:await e.loadValue("LercParameters")})},{cases:5e4,importFn:()=>Promise.resolve().then(()=>require("./zstd-B3Xa90HD.cjs")).then(async e=>(await e.zstd.init(),e)).then(e=>e.default)},{cases:50001,importFn:()=>Promise.resolve().then(()=>require("./webimage-Bh2pNwjN.cjs")).then(e=>e.default),decoderParameterFn:async e=>({...await J(e),samplesPerPixel:Number(await e.loadValue("SamplesPerPixel"))||4}),preferWorker:!1}];for(const e of zt){const{cases:t,importFn:r,decoderParameterFn:s,preferWorker:i}=e;Nt(t,r,s,i)}function re(e,t,r,s=1){return new(Object.getPrototypeOf(e)).constructor(t*r*s)}function qt(e,t,r,s,i){const n=t/s,o=r/i;return e.map(a=>{const f=re(a,s,i);for(let l=0;l<i;++l){const c=Math.min(Math.round(o*l),r-1);for(let h=0;h<s;++h){const g=Math.min(Math.round(n*h),t-1),u=a[c*t+g];f[l*s+h]=u}}return f})}function R(e,t,r){return(1-r)*e+r*t}function Gt(e,t,r,s,i){const n=t/s,o=r/i;return e.map(a=>{const f=re(a,s,i);for(let l=0;l<i;++l){const c=o*l,h=Math.floor(c),g=Math.min(Math.ceil(c),r-1);for(let u=0;u<s;++u){const y=n*u,p=y%1,w=Math.floor(y),m=Math.min(Math.ceil(y),t-1),b=a[h*t+w],v=a[h*t+m],S=a[g*t+w],T=a[g*t+m],A=R(R(b,v,p),R(S,T,p),c%1);f[l*s+u]=A}}return f})}function jt(e,t,r,s,i,n="nearest"){switch(n.toLowerCase()){case"nearest":return qt(e,t,r,s,i);case"bilinear":case"linear":return Gt(e,t,r,s,i);default:throw new Error(`Unsupported resampling method: '${n}'`)}}function Ht(e,t,r,s,i,n){const o=t/s,a=r/i,f=re(e,s,i,n);for(let l=0;l<i;++l){const c=Math.min(Math.round(a*l),r-1);for(let h=0;h<s;++h){const g=Math.min(Math.round(o*h),t-1);for(let u=0;u<n;++u){const y=e[c*t*n+g*n+u];f[l*s*n+h*n+u]=y}}}return f}function Yt(e,t,r,s,i,n){const o=t/s,a=r/i,f=re(e,s,i,n);for(let l=0;l<i;++l){const c=a*l,h=Math.floor(c),g=Math.min(Math.ceil(c),r-1);for(let u=0;u<s;++u){const y=o*u,p=y%1,w=Math.floor(y),m=Math.min(Math.ceil(y),t-1);for(let b=0;b<n;++b){const v=e[h*t*n+w*n+b],S=e[h*t*n+m*n+b],T=e[g*t*n+w*n+b],A=e[g*t*n+m*n+b],P=R(R(v,S,p),R(T,A,p),c%1);f[l*s*n+u*n+b]=P}}}return f}function $t(e,t,r,s,i,n,o="nearest"){switch(o.toLowerCase()){case"nearest":return Ht(e,t,r,s,i,n);case"bilinear":case"linear":return Yt(e,t,r,s,i,n);default:throw new Error(`Unsupported resampling method: '${o}'`)}}function Xt(e,t,r){let s=0;for(let i=t;i<r;++i)s+=e[i];return s}function le(e,t,r){let s;switch(e){case 1:t<=8?s=Uint8Array:t<=16?s=Uint16Array:t<=32&&(s=Uint32Array);break;case 2:t===8?s=Int8Array:t===16?s=Int16Array:t===32&&(s=Int32Array);break;case 3:switch(t){case 16:case 32:s=Float32Array;break;case 64:s=Float64Array;break;default:break}break;default:break}if(s){if(typeof r=="number")return new s(r);if(r instanceof ArrayBuffer)return new s(r)}throw Error("Unsupported data format/bitsPerSample")}function Kt(e,t){return(e===1||e===2)&&t<=32&&t%8===0?!1:!(e===3&&(t===16||t===32||t===64))}function Zt(e,t,r,s,i,n,o){const a=new DataView(e),f=r===2?o*n:o*n*s,l=r===2?1:s,c=le(t,i,f),h=parseInt("1".repeat(i),2);if(t===1){let g;r===1?g=s*i:g=i;let u=n*g;(u&7)!==0&&(u=u+7&-8);for(let y=0;y<o;++y){const p=y*u;for(let w=0;w<n;++w){const m=p+w*l*i;for(let b=0;b<l;++b){const v=m+b*i,S=(y*n+w)*l+b,T=Math.floor(v/8),A=v%8;A+i<=8?c[S]=a.getUint8(T)>>8-i-A&h:A+i<=16?c[S]=a.getUint16(T)>>16-i-A&h:A+i<=24?c[S]=(a.getUint16(T)<<8|a.getUint8(T+2))>>24-i-A&h:c[S]=a.getUint32(T)>>32-i-A&h}}}}return c.buffer}var Jt=class{constructor(e,t,r,s){this.fileDirectory=e,this.littleEndian=t,this.tiles=r?[]:null,this.isTiled=!e.hasTag("StripOffsets");const i=e.getValue("PlanarConfiguration")??1;if(i!==1&&i!==2)throw new Error("Invalid planar configuration.");this.planarConfiguration=i,this.source=s}getFileDirectory(){return this.fileDirectory}getGeoKeys(){return this.fileDirectory.parseGeoKeyDirectory()}getWidth(){return this.fileDirectory.getValue("ImageWidth")||0}getHeight(){return this.fileDirectory.getValue("ImageLength")||0}getSamplesPerPixel(){return this.fileDirectory.getValue("SamplesPerPixel")??1}getTileWidth(){return this.isTiled?this.fileDirectory.getValue("TileWidth")||0:this.getWidth()}getTileHeight(){if(this.isTiled)return this.fileDirectory.getValue("TileLength")||0;const e=this.fileDirectory.hasTag("RowsPerStrip")&&this.fileDirectory.getValue("RowsPerStrip");return e?Math.min(e,this.getHeight()):this.getHeight()}getBlockWidth(){return this.getTileWidth()}getBlockHeight(e){return this.isTiled||(e+1)*this.getTileHeight()<=this.getHeight()?this.getTileHeight():this.getHeight()-e*this.getTileHeight()}getBytesPerPixel(){let e=0;const t=this.fileDirectory.getValue("BitsPerSample")||[];for(let r=0;r<t.length;++r)e+=this.getSampleByteSize(r);return e}getSampleByteSize(e){const t=this.fileDirectory.getValue("BitsPerSample")||[];if(e>=t.length)throw new RangeError(`Sample index ${e} is out of range.`);return Math.ceil(t[e]/8)}getReaderForSample(e){const t=this.fileDirectory.getValue("SampleFormat"),r=t?t[e]:1,s=(this.fileDirectory.getValue("BitsPerSample")||[])[e];switch(r){case 1:if(s<=8)return DataView.prototype.getUint8;if(s<=16)return DataView.prototype.getUint16;if(s<=32)return DataView.prototype.getUint32;break;case 2:if(s<=8)return DataView.prototype.getInt8;if(s<=16)return DataView.prototype.getInt16;if(s<=32)return DataView.prototype.getInt32;break;case 3:switch(s){case 16:return function(i,n){return ze(this,i,n)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64;default:break}break;default:break}throw Error("Unsupported data format/bitsPerSample")}getSampleFormat(e=0){const t=this.fileDirectory.getValue("SampleFormat");return t?t[e]:1}getBitsPerSample(e=0){const t=this.fileDirectory.getValue("BitsPerSample");return t?t[e]:0}getArrayForSample(e,t){return le(this.getSampleFormat(e),this.getBitsPerSample(e),t)}async getTileOrStrip(e,t,r,s,i){const n=Math.ceil(this.getWidth()/this.getTileWidth()),o=Math.ceil(this.getHeight()/this.getTileHeight());let a;const{tiles:f}=this;if(this.planarConfiguration===1?a=t*n+e:this.planarConfiguration===2&&(a=r*n*o+t*n+e),a===void 0)throw new Error("Could not determine tile or strip index.");let l,c;if(this.isTiled?(l=Number(await this.fileDirectory.loadValueIndexed("TileOffsets",a)),c=Number(await this.fileDirectory.loadValueIndexed("TileByteCounts",a))):(l=Number(await this.fileDirectory.loadValueIndexed("StripOffsets",a)),c=Number(await this.fileDirectory.loadValueIndexed("StripByteCounts",a))),c===0){const u=this.getBlockHeight(t)*this.getTileWidth(),y=this.planarConfiguration===2?this.getSampleByteSize(r):this.getBytesPerPixel(),p=new ArrayBuffer(u*y);return this.getArrayForSample(r,p).fill(this.getGDALNoData()||0),{x:e,y:t,sample:r,data:p}}const h=(await this.source.fetch([{offset:l,length:c}],i))[0];let g;return f===null||!f[a]?(g=(async()=>{let u=await s.decode(h);const y=this.getSampleFormat(),p=this.getBitsPerSample();return Kt(y,p)&&(u=Zt(u,y,this.planarConfiguration,this.getSamplesPerPixel(),p,this.getTileWidth(),this.getBlockHeight(t))),u})(),f!==null&&(f[a]=g)):g=f[a],{x:e,y:t,sample:r,data:await g}}async _readRaster(e,t,r,s,i,n,o,a,f){const l=this.getTileWidth(),c=this.getTileHeight(),h=this.getWidth(),g=this.getHeight(),u=Math.max(Math.floor(e[0]/l),0),y=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(g/c)),m=e[2]-e[0];let b=this.getBytesPerPixel();const v=[],S=[];for(let _=0;_<t.length;++_){if(this.planarConfiguration===1){const x=await this.fileDirectory.loadValue("BitsPerSample");if(typeof x!="object")throw new Error("Expected BitsPerSample to be an array or typed array.");v.push(Xt(x,0,t[_])/8)}else v.push(0);S.push(this.getReaderForSample(t[_]))}const T=[],{littleEndian:A}=this;for(let _=p;_<w;++_)for(let x=u;x<y;++x){let H;this.planarConfiguration===1&&(H=this.getTileOrStrip(x,_,0,i,f));for(let Y=0;Y<t.length;++Y){const $=Y,ve=t[Y];if(this.planarConfiguration===2&&(b=this.getSampleByteSize(ve),H=this.getTileOrStrip(x,_,ve,i,f)),!H)throw new Error("Could not get tile or strip data.");const Ye=H.then(V=>{const $e=V.data,Xe=new DataView($e),se=this.getBlockHeight(V.y),U=V.y*c,X=V.x*l,Ke=U+se,Ze=(V.x+1)*l,Je=S[$],Qe=Math.min(se,se-(Ke-e[3]),g-U),We=Math.min(l,l-(Ze-e[2]),h-X);for(let N=Math.max(0,e[1]-U);N<Qe;++N)for(let L=Math.max(0,e[0]-X);L<We;++L){const et=(N*l+L)*b,Ie=Je.call(Xe,et+v[$],A);let K;s?(K=(N+U-e[1])*m*t.length+(L+X-e[0])*t.length+$,r[K]=Ie):(K=(N+U-e[1])*m+L+X-e[0],r[$][K]=Ie)}});T.push(Ye)}}if(await Promise.all(T),n&&e[2]-e[0]!==n||o&&e[3]-e[1]!==o){let _;s?_=$t(r,e[2]-e[0],e[3]-e[1],n,o,t.length,a):_=jt(r,e[2]-e[0],e[3]-e[1],n,o,a);const x=_;return x.width=n??e[2]-e[0],x.height=o??e[3]-e[1],x}const P=r;return P.width=n||e[2]-e[0],P.height=o||e[3]-e[1],P}async readRasters(e={}){const{window:t,samples:r=[],pool:s=null,width:i,height:n,resampleMethod:o,fillValue:a,signal:f}=e,l="interleave"in e&&e.interleave,c=t||[0,0,this.getWidth(),this.getHeight()];if(c[0]>c[2]||c[1]>c[3])throw new Error("Invalid subsets");const h=(c[2]-c[0])*(c[3]-c[1]),g=this.getSamplesPerPixel();if(!r||!r.length)for(let m=0;m<g;++m)r.push(m);else for(let m=0;m<r.length;++m)if(r[m]>=g)return Promise.reject(new RangeError(`Invalid sample index '${r[m]}'.`));let u;if(l){const{fileDirectory:m}=this,b=m.getValue("SampleFormat"),v=b?Math.max.apply(null,Array.from(b)):1;if(v!==1&&v!==2&&v!==3)throw new Error("Unsupported sample format for interleaved data. Must be 1, 2, or 3.");const S=m.getValue("BitsPerSample");if(u=le(v,S?Math.max.apply(null,Array.from(S)):8,h*r.length),a){if(Array.isArray(a))throw new Error("When reading interleaved data, fillValue must be a single number.");u.fill(a)}}else{u=[];for(let m=0;m<r.length;++m){const b=this.getArrayForSample(r[m],h);Array.isArray(a)&&m<a.length?b.fill(a[m]):a&&!Array.isArray(a)&&b.fill(a),u.push(b)}}const y=this.fileDirectory.getValue("Compression")||1,p=await Lt(y,this.fileDirectory),w=s?s.bindParameters(y,p):await Ct(y,p);return await this._readRaster(c,r,u,l,w,i,n,o,f)}async readRGB(e={}){const{window:t,pool:r=null,width:s,height:i,resampleMethod:n,enableAlpha:o=!1,signal:a}=e,f=("interleave"in e&&e.interleave)??!1,l=t||[0,0,this.getWidth(),this.getHeight()];if(l[0]>l[2]||l[1]>l[3])throw new Error("Invalid subsets");const c=this.fileDirectory.getValue("PhotometricInterpretation");if(c===d.photometricInterpretations.RGB){let b=[0,1,2];const v=this.fileDirectory.getValue("ExtraSamples");if(v&&v[0]!==d.ExtraSamplesValues.Unspecified&&o){b=[];const S=this.fileDirectory.getValue("BitsPerSample")||[];for(let T=0;T<S.length;T+=1)b.push(T)}return this.readRasters({window:t,interleave:f,samples:b,pool:r,width:s,height:i,resampleMethod:n,signal:a})}let h;switch(c){case d.photometricInterpretations.WhiteIsZero:case d.photometricInterpretations.BlackIsZero:case d.photometricInterpretations.Palette:h=[0];break;case d.photometricInterpretations.CMYK:h=[0,1,2,3];break;case d.photometricInterpretations.YCbCr:case d.photometricInterpretations.CIELab:h=[0,1,2];break;default:throw new Error("Invalid or unsupported photometric interpretation.")}const g={window:l,interleave:!0,samples:h,pool:r,width:s,height:i,resampleMethod:n,signal:a},{fileDirectory:u}=this,y=await this.readRasters(g),p=2**this.getBitsPerSample(0);let w;switch(c){case d.photometricInterpretations.WhiteIsZero:w=Ft(y,p);break;case d.photometricInterpretations.BlackIsZero:w=kt(y,p);break;case d.photometricInterpretations.Palette:w=Dt(y,await u.loadValue("ColorMap"));break;case d.photometricInterpretations.CMYK:w=Ot(y);break;case d.photometricInterpretations.YCbCr:w=Rt(y);break;case d.photometricInterpretations.CIELab:w=Ut(y);break;default:throw new Error("Unsupported photometric interpretation.")}if(!f){const b=new Uint8Array(w.length/3),v=new Uint8Array(w.length/3),S=new Uint8Array(w.length/3);for(let T=0,A=0;T<w.length;T+=3,++A)b[A]=w[T],v[A]=w[T+1],S[A]=w[T+2];w=[b,v,S]}const m=w;return m.width=y.width,m.height=y.height,m}async getTiePoints(){if(!this.fileDirectory.hasTag("ModelTiepoint"))return[];const e=await this.fileDirectory.loadValue("ModelTiepoint");if(typeof e!="object")throw new Error("Expected ModelTiepoint to be an array or typed array.");const t=[];for(let r=0;r<e.length;r+=6)t.push({i:e[r],j:e[r+1],k:e[r+2],x:e[r+3],y:e[r+4],z:e[r+5]});return t}async getGDALMetadata(e=null){const t={};if(!this.fileDirectory.hasTag("GDAL_METADATA"))return null;let r=xt(await this.fileDirectory.loadValue("GDAL_METADATA"),"Item");e===null?r=r.filter(s=>ie(s,"sample")===void 0):r=r.filter(s=>Number(ie(s,"sample"))===e);for(let s=0;s<r.length;++s){const i=r[s];t[ie(i,"name")]=i.inner}return t}getGDALNoData(){const e=this.fileDirectory.hasTag("GDAL_NODATA")&&this.fileDirectory.getValue("GDAL_NODATA");return e?Number(e.substring(0,e.length-1)):null}getOrigin(){const e=this.fileDirectory.getValue("ModelTiepoint"),t=this.fileDirectory.getValue("ModelTransformation");if(e&&e.length===6)return[e[3],e[4],e[5]];if(t)return[t[3],t[7],t[11]];throw new Error("The image does not have an affine transformation.")}getResolution(e=null){const t=this.fileDirectory.getValue("ModelPixelScale"),r=this.fileDirectory.getValue("ModelTransformation");if(t)return[t[0],-t[1],t[2]];if(r)return r[1]===0&&r[4]===0?[r[0],-r[5],r[10]]:[Math.sqrt(r[0]*r[0]+r[4]*r[4]),-Math.sqrt(r[1]*r[1]+r[5]*r[5]),r[10]];if(e){const[s,i,n]=e.getResolution();return[s*e.getWidth()/this.getWidth(),i*e.getHeight()/this.getHeight(),n*e.getWidth()/this.getWidth()]}throw new Error("The image does not have an affine transformation.")}pixelIsArea(){return this.getGeoKeys()?.GTRasterTypeGeoKey===1}getBoundingBox(e=!1){const t=this.getHeight(),r=this.getWidth(),s=this.fileDirectory.getValue("ModelTransformation");if(s&&!e){const[i,n,,o,a,f,,l]=s,c=[[0,0],[0,t],[r,0],[r,t]].map(([u,y])=>[o+i*u+n*y,l+a*u+f*y]),h=c.map(u=>u[0]),g=c.map(u=>u[1]);return[Math.min(...h),Math.min(...g),Math.max(...h),Math.max(...g)]}else{const i=this.getOrigin(),n=this.getResolution(),o=i[0],a=i[1],f=o+n[0]*r,l=a+n[1]*t;return[Math.min(o,f),Math.min(a,l),Math.max(o,f),Math.max(a,l)]}}},Qt=class{constructor(e){this._dataView=new DataView(e)}get buffer(){return this._dataView.buffer}getUint64(e,t){const r=this.getUint32(e,t),s=this.getUint32(e+4,t);let i;if(t){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`);return i}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`);return i}getInt64(e,t){let r=0;const s=(this._dataView.getUint8(e+(t?7:0))&128)>0;let i=!0;for(let n=0;n<8;n++){let o=this._dataView.getUint8(e+(t?n:7-n));s&&(i?o!==0&&(o=~(o-1)&255,i=!1):o=~o&255),r+=o*256**n}return s&&(r=-r),r}getUint8(e){return this._dataView.getUint8(e)}getInt8(e){return this._dataView.getInt8(e)}getUint16(e,t){return this._dataView.getUint16(e,t)}getInt16(e,t){return this._dataView.getInt16(e,t)}getUint32(e,t){return this._dataView.getUint32(e,t)}getInt32(e,t){return this._dataView.getInt32(e,t)}getFloat16(e,t){return ze(this._dataView,e,t)}getFloat32(e,t){return this._dataView.getFloat32(e,t)}getFloat64(e,t){return this._dataView.getFloat64(e,t)}},Q=class{constructor(e,t,r,s){this._dataView=new DataView(e),this._sliceOffset=t,this._littleEndian=r,this._bigTiff=s}get sliceOffset(){return this._sliceOffset}get sliceTop(){return this._sliceOffset+this.buffer.byteLength}get littleEndian(){return this._littleEndian}get bigTiff(){return this._bigTiff}get buffer(){return this._dataView.buffer}covers(e,t){return this.sliceOffset<=e&&this.sliceTop>=e+t}readUint8(e){return this._dataView.getUint8(e-this._sliceOffset)}readInt8(e){return this._dataView.getInt8(e-this._sliceOffset)}readUint16(e){return this._dataView.getUint16(e-this._sliceOffset,this._littleEndian)}readInt16(e){return this._dataView.getInt16(e-this._sliceOffset,this._littleEndian)}readUint32(e){return this._dataView.getUint32(e-this._sliceOffset,this._littleEndian)}readInt32(e){return this._dataView.getInt32(e-this._sliceOffset,this._littleEndian)}readFloat32(e){return this._dataView.getFloat32(e-this._sliceOffset,this._littleEndian)}readFloat64(e){return this._dataView.getFloat64(e-this._sliceOffset,this._littleEndian)}readUint64(e){const t=this.readUint32(e),r=this.readUint32(e+4);let s;if(this._littleEndian){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`);return s}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`);return s}readInt64(e){let t=0;const r=(this._dataView.getUint8(e+(this._littleEndian?7:0))&128)>0;let s=!0;for(let i=0;i<8;i++){let n=this._dataView.getUint8(e+(this._littleEndian?i:7-i));r&&(s?n!==0&&(n=~(n-1)&255,s=!1):n=~n&255),t+=n*256**i}return r&&(t=-t),t}readOffset(e){return this._bigTiff?this.readUint64(e):this.readUint32(e)}},Wt=`\r
|
|
3
|
+
>]`),y+=Ee(p,"</"+t+">"),y>=u)break;g=a}}const l=n+t.length+a+1;if(s&&console.log("[xml-utils] end:",l),l===-1)return;const c=e.slice(n,l);let h;return f?h=null:h=c.slice(c.indexOf(">")+1,c.lastIndexOf("<")),{inner:h,outer:c,start:n,end:l}}function xt(e,t,r){const s=[],i=r&&r.debug||!1,n=r&&typeof r.nested=="boolean"?r.nested:!0;let o=r&&r.startIndex||0,a;for(;a=Pt(e,t,{debug:i,startIndex:o});)n?o=a.start+1+t.length:o=a.end,s.push(a);return i&&console.log("findTagsByName found",s.length,"tags"),s}function Ft(e,t){const{width:r,height:s}=e,i=new Uint8Array(r*s*3);let n;for(let o=0,a=0;o<e.length;++o,a+=3)n=256-e[o]/t*256,i[a]=n,i[a+1]=n,i[a+2]=n;return i}function kt(e,t){const{width:r,height:s}=e,i=new Uint8Array(r*s*3);let n;for(let o=0,a=0;o<e.length;++o,a+=3)n=e[o]/t*256,i[a]=n,i[a+1]=n,i[a+2]=n;return i}function Dt(e,t){const{width:r,height:s}=e,i=new Uint8Array(r*s*3),n=t.length/3,o=t.length/3*2;for(let a=0,f=0;a<e.length;++a,f+=3){const l=e[a];i[f]=t[l]/65536*256,i[f+1]=t[l+n]/65536*256,i[f+2]=t[l+o]/65536*256}return i}function Ot(e){const{width:t,height:r}=e,s=new Uint8Array(t*r*3);for(let i=0,n=0;i<e.length;i+=4,n+=3){const o=e[i],a=e[i+1],f=e[i+2],l=e[i+3];s[n]=255*((255-o)/256)*((255-l)/256),s[n+1]=255*((255-a)/256)*((255-l)/256),s[n+2]=255*((255-f)/256)*((255-l)/256)}return s}function Rt(e){const{width:t,height:r}=e,s=new Uint8ClampedArray(t*r*3);for(let i=0,n=0;i<e.length;i+=3,n+=3){const o=e[i],a=e[i+1],f=e[i+2];s[n]=o+1.402*(f-128),s[n+1]=o-.34414*(a-128)-.71414*(f-128),s[n+2]=o+1.772*(a-128)}return s}var Mt=.95047,Bt=1,Vt=1.08883;function Ut(e){const{width:t,height:r}=e,s=new Uint8Array(t*r*3);for(let i=0,n=0;i<e.length;i+=3,n+=3){const o=e[i+0],a=e[i+1]<<24>>24,f=e[i+2]<<24>>24;let l=(o+16)/116,c=a/500+l,h=l-f/200,g,u,y;c=Mt*(c*c*c>.008856?c*c*c:(c-16/116)/7.787),l=Bt*(l*l*l>.008856?l*l*l:(l-16/116)/7.787),h=Vt*(h*h*h>.008856?h*h*h:(h-16/116)/7.787),g=c*3.2406+l*-1.5372+h*-.4986,u=c*-.9689+l*1.8758+h*.0415,y=c*.0557+l*-.204+h*1.057,g=g>.0031308?1.055*g**(1/2.4)-.055:12.92*g,u=u>.0031308?1.055*u**(1/2.4)-.055:12.92*u,y=y>.0031308?1.055*y**(1/2.4)-.055:12.92*y,s[n]=Math.max(0,Math.min(1,g))*255,s[n+1]=Math.max(0,Math.min(1,u))*255,s[n+2]=Math.max(0,Math.min(1,y))*255}return s}var q=new Map;async function J(e){const t=!e.hasTag("StripOffsets");return{tileWidth:t?await e.loadValue("TileWidth"):await e.loadValue("ImageWidth"),tileHeight:t?await e.loadValue("TileLength"):await e.loadValue("RowsPerStrip")||await e.loadValue("ImageLength"),planarConfiguration:await e.loadValue("PlanarConfiguration"),bitsPerSample:await e.loadValue("BitsPerSample"),predictor:await e.loadValue("Predictor")||1}}function Nt(e,t,r=J,s=!0){Array.isArray(e)||(e=[e]),e.forEach(i=>{q.set(i,{importFn:t,decoderParameterFn:r,preferWorker:s})})}async function Lt(e,t){if(!q.has(e))throw new Error(`Unknown compression method identifier: ${e}`);const{decoderParameterFn:r}=q.get(e);return r(t)}async function Ct(e,t){if(!q.has(e))throw new Error(`Unknown compression method identifier: ${e}`);const{importFn:r}=q.get(e);return new(await r())(t)}var zt=[{cases:[void 0,1],importFn:()=>Promise.resolve().then(()=>require("./raw-C-CSxCoU.cjs")).then(e=>e.default),preferWorker:!1},{cases:5,importFn:()=>Promise.resolve().then(()=>require("./lzw-1HaU0PJK.cjs")).then(e=>e.default)},{cases:6,importFn:()=>{throw new Error("old style JPEG compression is not supported.")}},{cases:7,importFn:()=>Promise.resolve().then(()=>require("./jpeg-B6Sg6W8k.cjs")).then(e=>e.default),decoderParameterFn:async e=>({...await J(e),JPEGTables:await e.loadValue("JPEGTables")})},{cases:[8,32946],importFn:()=>Promise.resolve().then(()=>require("./deflate-DNeBKDsy.cjs")).then(e=>e.default)},{cases:32773,importFn:()=>Promise.resolve().then(()=>require("./packbits-D5Zovac7.cjs")).then(e=>e.default)},{cases:34887,importFn:()=>Promise.resolve().then(()=>require("./lerc-aWBIByFf.cjs")).then(async e=>(await e.zstd.init(),e)).then(e=>e.default),decoderParameterFn:async e=>({...await J(e),LercParameters:await e.loadValue("LercParameters")})},{cases:5e4,importFn:()=>Promise.resolve().then(()=>require("./zstd-B3Xa90HD.cjs")).then(async e=>(await e.zstd.init(),e)).then(e=>e.default)},{cases:50001,importFn:()=>Promise.resolve().then(()=>require("./webimage-Bh2pNwjN.cjs")).then(e=>e.default),decoderParameterFn:async e=>({...await J(e),samplesPerPixel:Number(await e.loadValue("SamplesPerPixel"))||4}),preferWorker:!1}];for(const e of zt){const{cases:t,importFn:r,decoderParameterFn:s,preferWorker:i}=e;Nt(t,r,s,i)}function re(e,t,r,s=1){return new(Object.getPrototypeOf(e)).constructor(t*r*s)}function qt(e,t,r,s,i){const n=t/s,o=r/i;return e.map(a=>{const f=re(a,s,i);for(let l=0;l<i;++l){const c=Math.min(Math.round(o*l),r-1);for(let h=0;h<s;++h){const g=Math.min(Math.round(n*h),t-1),u=a[c*t+g];f[l*s+h]=u}}return f})}function R(e,t,r){return(1-r)*e+r*t}function Gt(e,t,r,s,i){const n=t/s,o=r/i;return e.map(a=>{const f=re(a,s,i);for(let l=0;l<i;++l){const c=o*l,h=Math.floor(c),g=Math.min(Math.ceil(c),r-1);for(let u=0;u<s;++u){const y=n*u,p=y%1,w=Math.floor(y),m=Math.min(Math.ceil(y),t-1),b=a[h*t+w],v=a[h*t+m],S=a[g*t+w],T=a[g*t+m],A=R(R(b,v,p),R(S,T,p),c%1);f[l*s+u]=A}}return f})}function jt(e,t,r,s,i,n="nearest"){switch(n.toLowerCase()){case"nearest":return qt(e,t,r,s,i);case"bilinear":case"linear":return Gt(e,t,r,s,i);default:throw new Error(`Unsupported resampling method: '${n}'`)}}function Ht(e,t,r,s,i,n){const o=t/s,a=r/i,f=re(e,s,i,n);for(let l=0;l<i;++l){const c=Math.min(Math.round(a*l),r-1);for(let h=0;h<s;++h){const g=Math.min(Math.round(o*h),t-1);for(let u=0;u<n;++u){const y=e[c*t*n+g*n+u];f[l*s*n+h*n+u]=y}}}return f}function Yt(e,t,r,s,i,n){const o=t/s,a=r/i,f=re(e,s,i,n);for(let l=0;l<i;++l){const c=a*l,h=Math.floor(c),g=Math.min(Math.ceil(c),r-1);for(let u=0;u<s;++u){const y=o*u,p=y%1,w=Math.floor(y),m=Math.min(Math.ceil(y),t-1);for(let b=0;b<n;++b){const v=e[h*t*n+w*n+b],S=e[h*t*n+m*n+b],T=e[g*t*n+w*n+b],A=e[g*t*n+m*n+b],P=R(R(v,S,p),R(T,A,p),c%1);f[l*s*n+u*n+b]=P}}}return f}function $t(e,t,r,s,i,n,o="nearest"){switch(o.toLowerCase()){case"nearest":return Ht(e,t,r,s,i,n);case"bilinear":case"linear":return Yt(e,t,r,s,i,n);default:throw new Error(`Unsupported resampling method: '${o}'`)}}function Xt(e,t,r){let s=0;for(let i=t;i<r;++i)s+=e[i];return s}function le(e,t,r){let s;switch(e){case 1:t<=8?s=Uint8Array:t<=16?s=Uint16Array:t<=32&&(s=Uint32Array);break;case 2:t===8?s=Int8Array:t===16?s=Int16Array:t===32&&(s=Int32Array);break;case 3:switch(t){case 16:case 32:s=Float32Array;break;case 64:s=Float64Array;break;default:break}break;default:break}if(s){if(typeof r=="number")return new s(r);if(r instanceof ArrayBuffer)return new s(r)}throw Error("Unsupported data format/bitsPerSample")}function Kt(e,t){return(e===1||e===2)&&t<=32&&t%8===0?!1:!(e===3&&(t===16||t===32||t===64))}function Zt(e,t,r,s,i,n,o){const a=new DataView(e),f=r===2?o*n:o*n*s,l=r===2?1:s,c=le(t,i,f),h=parseInt("1".repeat(i),2);if(t===1){let g;r===1?g=s*i:g=i;let u=n*g;(u&7)!==0&&(u=u+7&-8);for(let y=0;y<o;++y){const p=y*u;for(let w=0;w<n;++w){const m=p+w*l*i;for(let b=0;b<l;++b){const v=m+b*i,S=(y*n+w)*l+b,T=Math.floor(v/8),A=v%8;A+i<=8?c[S]=a.getUint8(T)>>8-i-A&h:A+i<=16?c[S]=a.getUint16(T)>>16-i-A&h:A+i<=24?c[S]=(a.getUint16(T)<<8|a.getUint8(T+2))>>24-i-A&h:c[S]=a.getUint32(T)>>32-i-A&h}}}}return c.buffer}var Jt=class{constructor(e,t,r,s){this.fileDirectory=e,this.littleEndian=t,this.tiles=r?[]:null,this.isTiled=!e.hasTag("StripOffsets");const i=e.getValue("PlanarConfiguration")??1;if(i!==1&&i!==2)throw new Error("Invalid planar configuration.");this.planarConfiguration=i,this.source=s}getFileDirectory(){return this.fileDirectory}getGeoKeys(){return this.fileDirectory.parseGeoKeyDirectory()}getWidth(){return this.fileDirectory.getValue("ImageWidth")||0}getHeight(){return this.fileDirectory.getValue("ImageLength")||0}getSamplesPerPixel(){return this.fileDirectory.getValue("SamplesPerPixel")??1}getTileWidth(){return this.isTiled?this.fileDirectory.getValue("TileWidth")||0:this.getWidth()}getTileHeight(){if(this.isTiled)return this.fileDirectory.getValue("TileLength")||0;const e=this.fileDirectory.hasTag("RowsPerStrip")&&this.fileDirectory.getValue("RowsPerStrip");return e?Math.min(e,this.getHeight()):this.getHeight()}getBlockWidth(){return this.getTileWidth()}getBlockHeight(e){return this.isTiled||(e+1)*this.getTileHeight()<=this.getHeight()?this.getTileHeight():this.getHeight()-e*this.getTileHeight()}getBytesPerPixel(){let e=0;const t=this.fileDirectory.getValue("BitsPerSample")||[];for(let r=0;r<t.length;++r)e+=this.getSampleByteSize(r);return e}getSampleByteSize(e){const t=this.fileDirectory.getValue("BitsPerSample")||[];if(e>=t.length)throw new RangeError(`Sample index ${e} is out of range.`);return Math.ceil(t[e]/8)}getReaderForSample(e){const t=this.fileDirectory.getValue("SampleFormat"),r=t?t[e]:1,s=(this.fileDirectory.getValue("BitsPerSample")||[])[e];switch(r){case 1:if(s<=8)return DataView.prototype.getUint8;if(s<=16)return DataView.prototype.getUint16;if(s<=32)return DataView.prototype.getUint32;break;case 2:if(s<=8)return DataView.prototype.getInt8;if(s<=16)return DataView.prototype.getInt16;if(s<=32)return DataView.prototype.getInt32;break;case 3:switch(s){case 16:return function(i,n){return ze(this,i,n)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64;default:break}break;default:break}throw Error("Unsupported data format/bitsPerSample")}getSampleFormat(e=0){const t=this.fileDirectory.getValue("SampleFormat");return t?t[e]:1}getBitsPerSample(e=0){const t=this.fileDirectory.getValue("BitsPerSample");return t?t[e]:0}getArrayForSample(e,t){return le(this.getSampleFormat(e),this.getBitsPerSample(e),t)}async getTileOrStrip(e,t,r,s,i){const n=Math.ceil(this.getWidth()/this.getTileWidth()),o=Math.ceil(this.getHeight()/this.getTileHeight());let a;const{tiles:f}=this;if(this.planarConfiguration===1?a=t*n+e:this.planarConfiguration===2&&(a=r*n*o+t*n+e),a===void 0)throw new Error("Could not determine tile or strip index.");let l,c;if(this.isTiled?(l=Number(await this.fileDirectory.loadValueIndexed("TileOffsets",a)),c=Number(await this.fileDirectory.loadValueIndexed("TileByteCounts",a))):(l=Number(await this.fileDirectory.loadValueIndexed("StripOffsets",a)),c=Number(await this.fileDirectory.loadValueIndexed("StripByteCounts",a))),c===0){const u=this.getBlockHeight(t)*this.getTileWidth(),y=this.planarConfiguration===2?this.getSampleByteSize(r):this.getBytesPerPixel(),p=new ArrayBuffer(u*y);return this.getArrayForSample(r,p).fill(this.getGDALNoData()||0),{x:e,y:t,sample:r,data:p}}const h=(await this.source.fetch([{offset:l,length:c}],i))[0];let g;return f===null||!f[a]?(g=(async()=>{let u=await s.decode(h);const y=this.getSampleFormat(),p=this.getBitsPerSample();return Kt(y,p)&&(u=Zt(u,y,this.planarConfiguration,this.getSamplesPerPixel(),p,this.getTileWidth(),this.getBlockHeight(t))),u})(),f!==null&&(f[a]=g)):g=f[a],{x:e,y:t,sample:r,data:await g}}async _readRaster(e,t,r,s,i,n,o,a,f){const l=this.getTileWidth(),c=this.getTileHeight(),h=this.getWidth(),g=this.getHeight(),u=Math.max(Math.floor(e[0]/l),0),y=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(g/c)),m=e[2]-e[0];let b=this.getBytesPerPixel();const v=[],S=[];for(let _=0;_<t.length;++_){if(this.planarConfiguration===1){const x=await this.fileDirectory.loadValue("BitsPerSample");if(typeof x!="object")throw new Error("Expected BitsPerSample to be an array or typed array.");v.push(Xt(x,0,t[_])/8)}else v.push(0);S.push(this.getReaderForSample(t[_]))}const T=[],{littleEndian:A}=this;for(let _=p;_<w;++_)for(let x=u;x<y;++x){let H;this.planarConfiguration===1&&(H=this.getTileOrStrip(x,_,0,i,f));for(let Y=0;Y<t.length;++Y){const $=Y,ve=t[Y];if(this.planarConfiguration===2&&(b=this.getSampleByteSize(ve),H=this.getTileOrStrip(x,_,ve,i,f)),!H)throw new Error("Could not get tile or strip data.");const Ye=H.then(V=>{const $e=V.data,Xe=new DataView($e),se=this.getBlockHeight(V.y),U=V.y*c,X=V.x*l,Ke=U+se,Ze=(V.x+1)*l,Je=S[$],Qe=Math.min(se,se-(Ke-e[3]),g-U),We=Math.min(l,l-(Ze-e[2]),h-X);for(let N=Math.max(0,e[1]-U);N<Qe;++N)for(let L=Math.max(0,e[0]-X);L<We;++L){const et=(N*l+L)*b,Ie=Je.call(Xe,et+v[$],A);let K;s?(K=(N+U-e[1])*m*t.length+(L+X-e[0])*t.length+$,r[K]=Ie):(K=(N+U-e[1])*m+L+X-e[0],r[$][K]=Ie)}});T.push(Ye)}}if(await Promise.all(T),n&&e[2]-e[0]!==n||o&&e[3]-e[1]!==o){let _;s?_=$t(r,e[2]-e[0],e[3]-e[1],n,o,t.length,a):_=jt(r,e[2]-e[0],e[3]-e[1],n,o,a);const x=_;return x.width=n??e[2]-e[0],x.height=o??e[3]-e[1],x}const P=r;return P.width=n||e[2]-e[0],P.height=o||e[3]-e[1],P}async readRasters(e={}){const{window:t,samples:r=[],pool:s=null,width:i,height:n,resampleMethod:o,fillValue:a,signal:f}=e,l="interleave"in e&&e.interleave,c=t||[0,0,this.getWidth(),this.getHeight()];if(c[0]>c[2]||c[1]>c[3])throw new Error("Invalid subsets");const h=(c[2]-c[0])*(c[3]-c[1]),g=this.getSamplesPerPixel();if(!r||!r.length)for(let m=0;m<g;++m)r.push(m);else for(let m=0;m<r.length;++m)if(r[m]>=g)return Promise.reject(new RangeError(`Invalid sample index '${r[m]}'.`));let u;if(l){const{fileDirectory:m}=this,b=m.getValue("SampleFormat"),v=b?Math.max.apply(null,Array.from(b)):1;if(v!==1&&v!==2&&v!==3)throw new Error("Unsupported sample format for interleaved data. Must be 1, 2, or 3.");const S=m.getValue("BitsPerSample");if(u=le(v,S?Math.max.apply(null,Array.from(S)):8,h*r.length),a){if(Array.isArray(a))throw new Error("When reading interleaved data, fillValue must be a single number.");u.fill(a)}}else{u=[];for(let m=0;m<r.length;++m){const b=this.getArrayForSample(r[m],h);Array.isArray(a)&&m<a.length?b.fill(a[m]):a&&!Array.isArray(a)&&b.fill(a),u.push(b)}}const y=this.fileDirectory.getValue("Compression")||1,p=await Lt(y,this.fileDirectory),w=s?s.bindParameters(y,p):await Ct(y,p);return await this._readRaster(c,r,u,l,w,i,n,o,f)}async readRGB(e={}){const{window:t,pool:r=null,width:s,height:i,resampleMethod:n,enableAlpha:o=!1,signal:a}=e,f=("interleave"in e&&e.interleave)??!1,l=t||[0,0,this.getWidth(),this.getHeight()];if(l[0]>l[2]||l[1]>l[3])throw new Error("Invalid subsets");const c=this.fileDirectory.getValue("PhotometricInterpretation");if(c===d.photometricInterpretations.RGB){let b=[0,1,2];const v=this.fileDirectory.getValue("ExtraSamples");if(v&&v[0]!==d.ExtraSamplesValues.Unspecified&&o){b=[];const S=this.fileDirectory.getValue("BitsPerSample")||[];for(let T=0;T<S.length;T+=1)b.push(T)}return this.readRasters({window:t,interleave:f,samples:b,pool:r,width:s,height:i,resampleMethod:n,signal:a})}let h;switch(c){case d.photometricInterpretations.WhiteIsZero:case d.photometricInterpretations.BlackIsZero:case d.photometricInterpretations.Palette:h=[0];break;case d.photometricInterpretations.CMYK:h=[0,1,2,3];break;case d.photometricInterpretations.YCbCr:case d.photometricInterpretations.CIELab:h=[0,1,2];break;default:throw new Error("Invalid or unsupported photometric interpretation.")}const g={window:l,interleave:!0,samples:h,pool:r,width:s,height:i,resampleMethod:n,signal:a},{fileDirectory:u}=this,y=await this.readRasters(g),p=2**this.getBitsPerSample(0);let w;switch(c){case d.photometricInterpretations.WhiteIsZero:w=Ft(y,p);break;case d.photometricInterpretations.BlackIsZero:w=kt(y,p);break;case d.photometricInterpretations.Palette:w=Dt(y,await u.loadValue("ColorMap"));break;case d.photometricInterpretations.CMYK:w=Ot(y);break;case d.photometricInterpretations.YCbCr:w=Rt(y);break;case d.photometricInterpretations.CIELab:w=Ut(y);break;default:throw new Error("Unsupported photometric interpretation.")}if(!f){const b=new Uint8Array(w.length/3),v=new Uint8Array(w.length/3),S=new Uint8Array(w.length/3);for(let T=0,A=0;T<w.length;T+=3,++A)b[A]=w[T],v[A]=w[T+1],S[A]=w[T+2];w=[b,v,S]}const m=w;return m.width=y.width,m.height=y.height,m}async getTiePoints(){if(!this.fileDirectory.hasTag("ModelTiepoint"))return[];const e=await this.fileDirectory.loadValue("ModelTiepoint");if(typeof e!="object")throw new Error("Expected ModelTiepoint to be an array or typed array.");const t=[];for(let r=0;r<e.length;r+=6)t.push({i:e[r],j:e[r+1],k:e[r+2],x:e[r+3],y:e[r+4],z:e[r+5]});return t}async getGDALMetadata(e=null){const t={};if(!this.fileDirectory.hasTag("GDAL_METADATA"))return null;let r=xt(await this.fileDirectory.loadValue("GDAL_METADATA"),"Item");e===null?r=r.filter(s=>ie(s,"sample")===void 0):r=r.filter(s=>Number(ie(s,"sample"))===e);for(let s=0;s<r.length;++s){const i=r[s];t[ie(i,"name")]=i.inner}return t}getGDALNoData(){const e=this.fileDirectory.hasTag("GDAL_NODATA")&&this.fileDirectory.getValue("GDAL_NODATA");return e?Number(e.substring(0,e.length-1)):null}getOrigin(){const e=this.fileDirectory.getValue("ModelTiepoint"),t=this.fileDirectory.getValue("ModelTransformation");if(e&&e.length===6)return[e[3],e[4],e[5]];if(t)return[t[3],t[7],t[11]];throw new Error("The image does not have an affine transformation.")}getResolution(e=null){const t=this.fileDirectory.getValue("ModelPixelScale"),r=this.fileDirectory.getValue("ModelTransformation");if(t)return[t[0],-t[1],t[2]];if(r)return r[1]===0&&r[4]===0?[r[0],-r[5],r[10]]:[Math.sqrt(r[0]*r[0]+r[4]*r[4]),-Math.sqrt(r[1]*r[1]+r[5]*r[5]),r[10]];if(e){const[s,i,n]=e.getResolution();return[s*e.getWidth()/this.getWidth(),i*e.getHeight()/this.getHeight(),n*e.getWidth()/this.getWidth()]}throw new Error("The image does not have an affine transformation.")}pixelIsArea(){return this.getGeoKeys()?.GTRasterTypeGeoKey===1}getBoundingBox(e=!1){const t=this.getHeight(),r=this.getWidth(),s=this.fileDirectory.getValue("ModelTransformation");if(s&&!e){const[i,n,,o,a,f,,l]=s,c=[[0,0],[0,t],[r,0],[r,t]].map(([u,y])=>[o+i*u+n*y,l+a*u+f*y]),h=c.map(u=>u[0]),g=c.map(u=>u[1]);return[Math.min(...h),Math.min(...g),Math.max(...h),Math.max(...g)]}else{const i=this.getOrigin(),n=this.getResolution(),o=i[0],a=i[1],f=o+n[0]*r,l=a+n[1]*t;return[Math.min(o,f),Math.min(a,l),Math.max(o,f),Math.max(a,l)]}}},Qt=class{constructor(e){this._dataView=new DataView(e)}get buffer(){return this._dataView.buffer}getUint64(e,t){const r=this.getUint32(e,t),s=this.getUint32(e+4,t);let i;if(t){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`);return i}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`);return i}getInt64(e,t){let r=0;const s=(this._dataView.getUint8(e+(t?7:0))&128)>0;let i=!0;for(let n=0;n<8;n++){let o=this._dataView.getUint8(e+(t?n:7-n));s&&(i?o!==0&&(o=~(o-1)&255,i=!1):o=~o&255),r+=o*256**n}return s&&(r=-r),r}getUint8(e){return this._dataView.getUint8(e)}getInt8(e){return this._dataView.getInt8(e)}getUint16(e,t){return this._dataView.getUint16(e,t)}getInt16(e,t){return this._dataView.getInt16(e,t)}getUint32(e,t){return this._dataView.getUint32(e,t)}getInt32(e,t){return this._dataView.getInt32(e,t)}getFloat16(e,t){return ze(this._dataView,e,t)}getFloat32(e,t){return this._dataView.getFloat32(e,t)}getFloat64(e,t){return this._dataView.getFloat64(e,t)}},Q=class{constructor(e,t,r,s){this._dataView=new DataView(e),this._sliceOffset=t,this._littleEndian=r,this._bigTiff=s}get sliceOffset(){return this._sliceOffset}get sliceTop(){return this._sliceOffset+this.buffer.byteLength}get littleEndian(){return this._littleEndian}get bigTiff(){return this._bigTiff}get buffer(){return this._dataView.buffer}covers(e,t){return this.sliceOffset<=e&&this.sliceTop>=e+t}readUint8(e){return this._dataView.getUint8(e-this._sliceOffset)}readInt8(e){return this._dataView.getInt8(e-this._sliceOffset)}readUint16(e){return this._dataView.getUint16(e-this._sliceOffset,this._littleEndian)}readInt16(e){return this._dataView.getInt16(e-this._sliceOffset,this._littleEndian)}readUint32(e){return this._dataView.getUint32(e-this._sliceOffset,this._littleEndian)}readInt32(e){return this._dataView.getInt32(e-this._sliceOffset,this._littleEndian)}readFloat32(e){return this._dataView.getFloat32(e-this._sliceOffset,this._littleEndian)}readFloat64(e){return this._dataView.getFloat64(e-this._sliceOffset,this._littleEndian)}readUint64(e){const t=this.readUint32(e),r=this.readUint32(e+4);let s;if(this._littleEndian){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`);return s}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`);return s}readInt64(e){let t=0;const r=(this._dataView.getUint8(e+(this._littleEndian?7:0))&128)>0;let s=!0;for(let i=0;i<8;i++){let n=this._dataView.getUint8(e+(this._littleEndian?i:7-i));r&&(s?n!==0&&(n=~(n-1)&255,s=!1):n=~n&255),t+=n*256**i}return r&&(t=-t),t}readOffset(e){return this._bigTiff?this.readUint64(e):this.readUint32(e)}},Wt=`\r
|
|
4
4
|
\r
|
|
5
5
|
`;function qe(e){if(typeof Object.fromEntries<"u")return Object.fromEntries(e);const t={};for(const[r,s]of e)t[r.toLowerCase()]=s;return t}function er(e){return qe(e.split(`\r
|
|
6
6
|
`).map(t=>{const r=t.split(":").map(s=>s.trim());return r[0]=r[0].toLowerCase(),r}))}function tr(e){if(!e)return{type:null,params:{}};const[t,...r]=e.split(";").map(s=>s.trim());return{type:t,params:qe(r.map(s=>s.split("=")))}}function ce(e){let t=NaN,r=NaN,s=NaN;return e&&([,t,r,s]=(e.match(/bytes (\d+)-(\d+)\/(\d+)/)||[]).map(Number)),{start:t,end:r,total:s}}function rr(e,t){let r=-1;const s=new TextDecoder("ascii"),i=[],n=`--${t}`,o=`${n}--`;for(let a=0;a<10;++a)s.decode(new Uint8Array(e,a,n.length))===n&&(r=a);if(r===-1)throw new Error("Could not find initial boundary");for(;r<e.byteLength;){const a=s.decode(new Uint8Array(e,r,Math.min(n.length+1024,e.byteLength-r)));if(a.length===0||a.startsWith(o))break;if(!a.startsWith(n))throw new Error("Part does not start with boundary");const f=a.substr(n.length+2);if(f.length===0)break;const l=f.indexOf(Wt),c=er(f.substr(0,l)),{start:h,end:g,total:u}=ce(c["content-range"]),y=r+n.length+l+4,p=g+1-h;i.push({headers:c,data:e.slice(y,y+p),offset:h,length:p,fileSize:u}),r=y+p+4}return i}var Ge=class{async fetch(e,t){return Promise.all(e.map(async r=>(await this.fetchSlice(r,t)).data))}async fetchSlice(e,t){throw new Error(`fetching of slice ${e} not possible, not implemented`)}get fileSize(){return null}async close(){}},sr=class extends Map{constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if(typeof e.maxAge=="number"&&e.maxAge===0)throw new TypeError("`maxAge` must be a number greater than 0");this.maxSize=e.maxSize,this.maxAge=e.maxAge||Number.POSITIVE_INFINITY,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(e){if(typeof this.onEviction=="function")for(const[t,r]of e)this.onEviction(t,r.value)}_deleteIfExpired(e,t){return typeof t.expiry=="number"&&t.expiry<=Date.now()?(typeof this.onEviction=="function"&&this.onEviction(e,t.value),this.delete(e)):!1}_getOrDeleteIfExpired(e,t){if(this._deleteIfExpired(e,t)===!1)return t.value}_getItemValue(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}_peek(e,t){const r=t.get(e);return this._getItemValue(e,r)}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(e,t){this.oldCache.delete(e),this._set(e,t)}*_entriesAscending(){for(const e of this.oldCache){const[t,r]=e;this.cache.has(t)||this._deleteIfExpired(t,r)===!1&&(yield e)}for(const e of this.cache){const[t,r]=e;this._deleteIfExpired(t,r)===!1&&(yield e)}}get(e){if(this.cache.has(e)){const t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){const t=this.oldCache.get(e);if(this._deleteIfExpired(e,t)===!1)return this._moveToRecent(e,t),t.value}}set(e,t,{maxAge:r=this.maxAge}={}){const s=typeof r=="number"&&r!==Number.POSITIVE_INFINITY?Date.now()+r:void 0;return this.cache.has(e)?this.cache.set(e,{value:t,expiry:s}):this._set(e,{value:t,expiry:s}),this}has(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):this.oldCache.has(e)?!this._deleteIfExpired(e,this.oldCache.get(e)):!1}peek(e){if(this.cache.has(e))return this._peek(e,this.cache);if(this.oldCache.has(e))return this._peek(e,this.oldCache)}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(e){if(!(e&&e>0))throw new TypeError("`maxSize` must be a number greater than 0");const t=[...this._entriesAscending()],r=t.length-e;r<0?(this.cache=new Map(t),this.oldCache=new Map,this._size=t.length):(r>0&&this._emitEvictions(t.slice(0,r)),this.oldCache=new Map(t.slice(r)),this.cache=new Map,this._size=0),this.maxSize=e}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache){const[t,r]=e;this._deleteIfExpired(t,r)===!1&&(yield[t,r.value])}for(const e of this.oldCache){const[t,r]=e;this.cache.has(t)||this._deleteIfExpired(t,r)===!1&&(yield[t,r.value])}}*entriesDescending(){let e=[...this.cache];for(let t=e.length-1;t>=0;--t){const[r,s]=e[t];this._deleteIfExpired(r,s)===!1&&(yield[r,s.value])}e=[...this.oldCache];for(let t=e.length-1;t>=0;--t){const[r,s]=e[t];this.cache.has(r)||this._deleteIfExpired(r,s)===!1&&(yield[r,s.value])}}*entriesAscending(){for(const[e,t]of this._entriesAscending())yield[e,t.value]}get size(){if(!this._size)return this.oldCache.size;let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}entries(){return this.entriesAscending()}forEach(e,t=this){for(const[r,s]of this.entriesAscending())e.call(t,s,r,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}};async function ir(e){return new Promise(t=>setTimeout(t,e))}function nr(e,t){const r=Array.isArray(e)?e:Array.from(e),s=Array.isArray(t)?t:Array.from(t);return r.map((i,n)=>[i,s[n]])}var G=class je extends Error{constructor(...t){super(...t),Error.captureStackTrace&&Error.captureStackTrace(this,je),this.name="AbortError",this.signal=void 0}},ar=class extends Error{constructor(e,t){super(t),this.errors=e,this.message=t,this.name="AggregateError"}},or=ar,lr=class{constructor(e,t,r){this.offset=e,this.length=t,this.data=r}get top(){return this.offset+this.length}},_e=class{constructor(e,t,r){this.offset=e,this.length=t,this.blockIds=r}},cr=class extends Ge{constructor(e,{blockSize:t=65536,cacheSize:r=100}={}){super(),this.source=e,this.blockSize=t,this.blockCache=new sr({maxSize:r,onEviction:(s,i)=>{this.evictedBlocks.set(s,i)}}),this.evictedBlocks=new Map,this.blockRequests=new Map,this.blockIdsToFetch=new Set,this.abortedBlockIds=new Set}get fileSize(){return this.source.fileSize}async fetch(e,t){const r=[],s=[],i=[];this.evictedBlocks.clear();for(const{offset:h,length:g}of e){let u=h+g;const{fileSize:y}=this;y!==null&&(u=Math.min(u,y));const p=Math.floor(h/this.blockSize)*this.blockSize;for(let w=p;w<u;w+=this.blockSize){const m=Math.floor(w/this.blockSize);!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)}}await ir(),this.fetchBlocks(t);const n=[];for(const h of s)this.blockRequests.has(h)&&n.push(this.blockRequests.get(h));await Promise.allSettled(r),await Promise.allSettled(n);const o=[],a=i.filter(h=>this.abortedBlockIds.has(h)||!this.blockCache.has(h));if(a.forEach(h=>this.blockIdsToFetch.add(h)),a.length>0&&t&&!t.aborted){this.fetchBlocks();for(const h of a){const g=this.blockRequests.get(h);if(!g)throw new Error(`Block ${h} is not in the block requests`);o.push(g)}await Promise.allSettled(o)}if(t&&t.aborted)throw new G("Request was aborted");const f=i.map(h=>this.blockCache.get(h)||this.evictedBlocks.get(h)),l=f.filter(h=>!h);if(l.length)throw new or(l,"Request failed");const c=new Map(nr(i,f));return this.readSliceData(e,c)}fetchBlocks(e){if(this.blockIdsToFetch.size>0){const t=this.groupBlocks(this.blockIdsToFetch),r=t.map(async s=>({...s,...await this.source.fetchSlice(s,e)}));for(let s=0;s<t.length;++s){const i=t[s];for(const n of i.blockIds)this.blockRequests.set(n,(async()=>{try{const o=(await Promise.all(r))[s],a=n*this.blockSize,f=a-o.offset,l=Math.min(f+this.blockSize,o.data.byteLength),c=o.data.slice(f,l),h=new lr(a,c.byteLength,c);this.blockCache.set(n,h),this.abortedBlockIds.delete(n)}catch(o){if(o instanceof G&&o.name==="AbortError")o.signal=e,this.blockCache.delete(n),this.abortedBlockIds.add(n);else throw o}finally{this.blockRequests.delete(n)}})())}this.blockIdsToFetch.clear()}}groupBlocks(e){const t=Array.from(e).sort((n,o)=>n-o);if(t.length===0)return[];let r=[],s=null;const i=[];for(const n of t)s===null||s+1===n?(r.push(n),s=n):(i.push(new _e(r[0]*this.blockSize,r.length*this.blockSize,r)),r=[n],s=n);return i.push(new _e(r[0]*this.blockSize,r.length*this.blockSize,r)),i}readSliceData(e,t){return e.map(r=>{let s=r.offset+r.length;this.fileSize!==null&&(s=Math.min(this.fileSize,s));const i=Math.floor(r.offset/this.blockSize),n=Math.floor((s-1)/this.blockSize),o=new ArrayBuffer(r.length),a=new Uint8Array(o);for(let f=i;f<=n;++f){const l=t.get(f);if(!l)continue;const c=l.offset-r.offset,h=l.top-s;let g=0,u=0,y;c<0?g=-c:c>0&&(u=c),h<0?y=l.length-g:y=s-l.offset-g;const p=new Uint8Array(l.data,g,y);a.set(p,u)}return o})}},we=class{get ok(){return this.status>=200&&this.status<=299}get status(){throw new Error("not implemented")}getHeader(e){throw new Error("not implemented")}async getData(){throw new Error("not implemented")}},me=class{constructor(e){this.url=e}async request(e){throw new Error("request is not implemented")}},hr=class extends we{constructor(e){super(),this.response=e}get status(){return this.response.status}getHeader(e){return this.response.headers.get(e)||void 0}async getData(){return this.response.arrayBuffer?await this.response.arrayBuffer():(await this.response.buffer()).buffer}},fr=class extends me{constructor(e,t){super(e),this.credentials=t}async request({headers:e,signal:t}={}){return new hr(await fetch(this.url,{headers:e,credentials:this.credentials,signal:t}))}},ur=class extends we{constructor(e,t){super(),this.xhr=e,this.data=t}get status(){return this.xhr.status}getHeader(e){return this.xhr.getResponseHeader(e)||void 0}async getData(){return this.data}},dr=class extends me{constructRequest(e,t){return new Promise((r,s)=>{const i=new XMLHttpRequest;i.open("GET",this.url),i.responseType="arraybuffer";for(const[n,o]of Object.entries(e))i.setRequestHeader(n,o);i.onload=()=>{const n=i.response;r(new ur(i,n))},i.onerror=s,i.onabort=()=>s(new G("Request aborted")),i.send(),t&&(t.aborted&&i.abort(),t.addEventListener("abort",()=>i.abort()))})}async request({headers:e={},signal:t=void 0}={}){return await this.constructRequest(e,t)}},gr=Pe.__commonJSMin(((e,t)=>{t.exports={}})),ne=Pe.__toESM(gr(),1),yr=class extends we{constructor(e,t){super(),this.response=e,this.dataPromise=t}get status(){return this.response.statusCode}getHeader(e){const t=this.response.headers[e];return Array.isArray(t)?t.join(", "):t}async getData(){return await this.dataPromise}},pr=class extends me{constructor(e){super(e),this.parsedUrl=ne.default.parse(this.url),this.httpApi=(this.parsedUrl.protocol==="http:",ne.default)}constructRequest(e,t){return new Promise((r,s)=>{const i=this.httpApi.get({...this.parsedUrl,headers:e},n=>{r(new yr(n,new Promise(o=>{const a=[];n.on("data",f=>{a.push(f)}),n.on("end",()=>{const f=Buffer.concat(a).buffer;o(f)}),n.on("error",s)})))});i.on("error",s),t&&(t.aborted&&i.destroy(new G("Request aborted")),t.addEventListener("abort",()=>i.destroy(new G("Request aborted"))))})}async request({headers:e={},signal:t=void 0}={}){return await this.constructRequest(e,t)}},be=class extends Ge{constructor(e,{headers:t,maxRanges:r=0,allowFullFile:s}={}){super(),this.client=e,this.headers=t,this.maxRanges=r,this.allowFullFile=s,this._fileSize=null}async fetch(e,t){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)))}async fetchSlices(e,t){const r=await this.client.request({headers:{...this.headers,Range:`bytes=${e.map(({offset:s,length:i})=>`${s}-${s+i-1}`).join(",")}`},signal:t});if(r.ok)if(r.status===206){const{type:s,params:i}=tr(r.getHeader("content-type"));if(s==="multipart/byteranges"){const c=rr(await r.getData(),i.boundary);return this._fileSize=c[0].fileSize||null,c}const n=await r.getData(),{start:o,end:a,total:f}=ce(r.getHeader("content-range"));this._fileSize=f||null;const l=[{data:n,offset:o,length:a+1-o}];if(e.length>1){const c=await Promise.all(e.slice(1).map(h=>this.fetchSlice(h,t)));return l.concat(c)}return l}else{if(!this.allowFullFile)throw new Error("Server responded with full file");const s=await r.getData();return this._fileSize=s.byteLength,[{data:s,offset:0,length:s.byteLength}]}else throw new Error("Error fetching data.")}async fetchSlice(e,t){const{offset:r,length:s}=e,i=await this.client.request({headers:{...this.headers,Range:`bytes=${r}-${r+s-1}`},signal:t});if(i.ok)if(i.status===206){const n=await i.getData(),{total:o}=ce(i.getHeader("content-range"));return this._fileSize=o||null,{data:n,offset:r,length:s}}else{if(!this.allowFullFile)throw new Error("Server responded with full file");const n=await i.getData();return this._fileSize=n.byteLength,{data:n,offset:0,length:n.byteLength}}else throw new Error("Error fetching data.")}get fileSize(){return this._fileSize}};function Te(e,{blockSize:t,cacheSize:r}){return t===void 0?e:new cr(e,{blockSize:t,cacheSize:r})}function wr(e,{headers:t={},credentials:r,maxRanges:s=0,allowFullFile:i=!1,...n}={}){return Te(new be(new fr(e,r),{headers:t,maxRanges:s,allowFullFile:i}),n)}function mr(e,{headers:t={},maxRanges:r=0,allowFullFile:s=!1,...i}={}){return Te(new be(new dr(e),{headers:t,maxRanges:r,allowFullFile:s}),i)}function br(e,{headers:t={},maxRanges:r=0,allowFullFile:s=!1,...i}={}){return Te(new be(new pr(e),{headers:t,maxRanges:r,allowFullFile:s}),i)}function Tr(e,{forceXHR:t=!1,...r}={}){return typeof fetch=="function"&&!t?wr(e,r):typeof XMLHttpRequest<"u"?mr(e,r):br(e,r)}function D(e,t){switch(e){case d.fieldTypes.BYTE:case d.fieldTypes.ASCII:case d.fieldTypes.UNDEFINED:return new Uint8Array(t);case d.fieldTypes.SBYTE:return new Int8Array(t);case d.fieldTypes.SHORT:return new Uint16Array(t);case d.fieldTypes.SSHORT:return new Int16Array(t);case d.fieldTypes.LONG:case d.fieldTypes.IFD:return new Uint32Array(t);case d.fieldTypes.SLONG:return new Int32Array(t);case d.fieldTypes.LONG8:case d.fieldTypes.IFD8:return new Array(t);case d.fieldTypes.SLONG8:return new Array(t);case d.fieldTypes.RATIONAL:return new Uint32Array(t*2);case d.fieldTypes.SRATIONAL:return new Int32Array(t*2);case d.fieldTypes.FLOAT:return new Float32Array(t);case d.fieldTypes.DOUBLE:return new Float64Array(t);default:throw new RangeError(`Invalid field type: ${e}`)}}function O(e,t){switch(t){case d.fieldTypes.BYTE:case d.fieldTypes.ASCII:case d.fieldTypes.UNDEFINED:return e.readUint8;case d.fieldTypes.SBYTE:return e.readInt8;case d.fieldTypes.SHORT:return e.readUint16;case d.fieldTypes.SSHORT:return e.readInt16;case d.fieldTypes.LONG:case d.fieldTypes.IFD:return e.readUint32;case d.fieldTypes.SLONG:return e.readInt32;case d.fieldTypes.LONG8:case d.fieldTypes.IFD8:return e.readUint64;case d.fieldTypes.SLONG8:return e.readInt64;case d.fieldTypes.RATIONAL:return e.readUint32;case d.fieldTypes.SRATIONAL:return e.readInt32;case d.fieldTypes.FLOAT:return e.readFloat32;case d.fieldTypes.DOUBLE:return e.readFloat64;default:throw new RangeError(`Invalid field type: ${t}`)}}function C(e=null,t,r,s,i,n,o=!1){const a=d.getFieldTypeSize(s),f=e||D(s,i),l=s===d.fieldTypes.RATIONAL||s===d.fieldTypes.SRATIONAL;if(l)for(let c=0;c<i;c+=2)f[c]=t.call(r,n+c*a),f[c+1]=t.call(r,n+(c*a+4));else for(let c=0;c<i;++c)f[c]=t.call(r,n+c*a);return s===d.fieldTypes.ASCII?new TextDecoder("utf-8").decode(f):i===1&&!o&&!l?f[0]:f}var vr=class{constructor(e,t,r,s,i){this.source=e,this.arrayOffset=t,this.littleEndian=r,this.fieldType=s,this.length=i,this.data=D(s,i),this.itemSize=d.getFieldTypeSize(s),this.maskBitmap=new Uint8Array(Math.ceil(i/8)),this.fetchIndexPromises=new Map,this.fullFetchPromise=null}async loadAll(){return this.fullFetchPromise||(this.fullFetchPromise=this.source.fetch([{offset:this.arrayOffset,length:this.itemSize*this.length}]).then(e=>{const t=new Q(e[0],this.arrayOffset,!0,!1),r=C(this.data,O(t,this.fieldType),t,this.fieldType,this.length,this.arrayOffset,!0);return this.maskBitmap.fill(255),this.fetchIndexPromises.clear(),r})),this.fullFetchPromise}async get(e){if(e<0||e>=this.data.length)throw new RangeError(`Index ${e} out of bounds for length ${this.data.length}`);const t=Math.floor(e/8),r=1<<e%8,s=this.arrayOffset+e*this.itemSize;if((this.maskBitmap[t]&r)===0){if(!this.fetchIndexPromises.has(e)){const i=this.source.fetch([{offset:s,length:this.itemSize}]).then(n=>{const o=new Q(n[0],this.arrayOffset+e*this.itemSize,!0,!1),a=O(o,this.fieldType).call(o,s);return this.data[e]=a,this.maskBitmap[t]|=r,this.fetchIndexPromises.delete(e),a});this.fetchIndexPromises.set(e,i)}return this.fetchIndexPromises.get(e)}return this.data[e]}},Ir=class{constructor(e,t,r,s){this.actualizedFields=e,this.deferredFields=t,this.deferredFieldsBeingResolved=new Map,this.deferredArrays=r,this.nextIFDByteOffset=s}hasTag(e){const t=d.resolveTag(e);return this.actualizedFields.has(t)||this.deferredFields.has(t)||this.deferredArrays.has(t)}getValue(e){const t=d.resolveTag(e);if(this.deferredFields.has(t)||this.deferredArrays.has(t)){const r=d.tagDefinitions[t]?.name||`Tag${t}`;throw new Error(`Field '${r}' (${t}) is deferred. Use loadValue() to load it asynchronously.`)}if(this.actualizedFields.has(t))return this.actualizedFields.get(t)}async loadValue(e){const t=d.resolveTag(e);if(this.actualizedFields.has(t))return this.actualizedFields.get(t);if(this.deferredFieldsBeingResolved.has(t))return this.deferredFieldsBeingResolved.get(t);const r=this.deferredFields.get(t);if(r){this.deferredFields.delete(t);const i=(async()=>{try{const n=await r();return this.actualizedFields.set(t,n),n}finally{this.deferredFieldsBeingResolved.delete(t)}})();return this.deferredFieldsBeingResolved.set(t,i),i}const s=this.deferredArrays.get(t);if(s)return s.loadAll()}async loadValueIndexed(e,t){const r=d.resolveTag(e);if(this.actualizedFields.has(r))return this.actualizedFields.get(r)[t];if(this.deferredArrays.has(r))return this.deferredArrays.get(r).get(t);if(this.hasTag(r)){const s=await this.loadValue(r);if(s&&typeof s!="number")return s[t]}}parseGeoKeyDirectory(){const e=this.getValue("GeoKeyDirectory");if(!e)return null;const t={};for(let r=4;r<=e[3]*4;r+=4){const s=d.geoKeyNames[e[r]],i=e[r+1]||null,n=e[r+2],o=e[r+3];let a=null;if(!i)a=o;else{if(a=this.getValue(i),typeof a>"u"||a===null)throw new Error(`Could not get value of geoKey '${s}'.`);typeof a=="string"?a=a.substring(o,o+n-1):a.subarray&&(a=a.subarray(o,o+n),n===1&&(a=a[0]))}t[s]=a}return t}toObject(){const e={};for(const[t,r]of this.actualizedFields.entries()){const s=typeof t=="number"?d.tagDefinitions[t]:void 0,i=s?s.name:`Tag${t}`;e[i]=r}return e}},Ar=class{constructor(e,t,r,s=!1){this.source=e,this.littleEndian=t,this.bigTiff=r,this.eager=s}async getSlice(e,t){const r=this.bigTiff?4048:1024;return new Q((await this.source.fetch([{offset:e,length:typeof t<"u"?t:r}]))[0],e,this.littleEndian,this.bigTiff)}async parseFileDirectoryAt(e){const t=this.bigTiff?20:12,r=this.bigTiff?8:2;let s=await this.getSlice(e);const i=this.bigTiff?s.readUint64(e):s.readUint16(e),n=i*(t+(this.bigTiff?16:6));s.covers(e,n)||(s=await this.getSlice(e,n));const o=new Map,a=new Map,f=new Map;let l=e+(this.bigTiff?8:2);for(let c=0;c<i;l+=t,++c){const h=s.readUint16(l),g=s.readUint16(l+2),u=this.bigTiff?s.readUint64(l+4):s.readUint32(l+4);let y=null,p=null,w=null;const m=d.getFieldTypeSize(g),b=l+(this.bigTiff?12:8),v=d.tagDefinitions[h]?.isArray,S=d.tagDefinitions[h]?.eager||this.eager;if(m*u<=(this.bigTiff?8:4))y=C(D(g,u),O(s,g),s,g,u,b,v);else{const T=s.readOffset(b),A=d.getFieldTypeSize(g)*u;if(s.covers(T,A))y=C(D(g,u),O(s,g),s,g,u,T,v);else if(S){const P=await this.getSlice(T,A);y=C(D(g,u),O(P,g),P,g,u,T,v)}else v?w=new vr(this.source,T,this.littleEndian,g,u):p=async()=>{const P=await this.getSlice(T,A);return C(D(g,u),O(P,g),P,g,u,T,v)}}y!==null?o.set(h,y):p!==null?a.set(h,p):w!==null&&f.set(h,w)}return new Ir(o,a,f,s.readOffset(e+r+t*i))}};function ae(e,t,r,s){let i=null,n=null;const o=d.getFieldTypeSize(t);switch(t){case d.fieldTypes.BYTE:case d.fieldTypes.ASCII:case d.fieldTypes.UNDEFINED:i=new Uint8Array(r),n=e.readUint8;break;case d.fieldTypes.SBYTE:i=new Int8Array(r),n=e.readInt8;break;case d.fieldTypes.SHORT:i=new Uint16Array(r),n=e.readUint16;break;case d.fieldTypes.SSHORT:i=new Int16Array(r),n=e.readInt16;break;case d.fieldTypes.LONG:case d.fieldTypes.IFD:i=new Uint32Array(r),n=e.readUint32;break;case d.fieldTypes.SLONG:i=new Int32Array(r),n=e.readInt32;break;case d.fieldTypes.LONG8:case d.fieldTypes.IFD8:i=new Array(r),n=e.readUint64;break;case d.fieldTypes.SLONG8:i=new Array(r),n=e.readInt64;break;case d.fieldTypes.RATIONAL:i=new Uint32Array(r*2),n=e.readUint32;break;case d.fieldTypes.SRATIONAL:i=new Int32Array(r*2),n=e.readInt32;break;case d.fieldTypes.FLOAT:i=new Float32Array(r),n=e.readFloat32;break;case d.fieldTypes.DOUBLE:i=new Float64Array(r),n=e.readFloat64;break;default:}if(i===null||n===null)throw new RangeError(`Invalid field type: ${t}`);if(t===d.fieldTypes.RATIONAL||t===d.fieldTypes.SRATIONAL)for(let a=0;a<r;a+=2)i[a]=n.call(e,s+a*o),i[a+1]=n.call(e,s+(a*o+4));else for(let a=0;a<r;++a)i[a]=n.call(e,s+a*o);return t===d.fieldTypes.ASCII?new TextDecoder("utf-8").decode(i):i}var Z=class extends Error{constructor(e){super(`No image at index ${e}`),this.index=e}},Sr=class{async getImage(e=0){throw new Error("Not implemented")}async getImageCount(){throw new Error("Not implemented")}async readRasters(e={}){const{window:t,width:r,height:s}=e;let{resX:i,resY:n,bbox:o}=e;const a=await this.getImage();let f=a;const l=await this.getImageCount(),c=a.getBoundingBox();if(t&&o)throw new Error('Both "bbox" and "window" passed.');if(r||s){if(t){const[u,y]=a.getOrigin(),[p,w]=a.getResolution();o=[u+t[0]*p,y+t[1]*w,u+t[2]*p,y+t[3]*w]}const g=o||c;if(r){if(i)throw new Error("Both width and resX passed");i=(g[2]-g[0])/r}if(s){if(n)throw new Error("Both width and resY passed");n=(g[3]-g[1])/s}}if(i||n){const g=[];for(let u=0;u<l;++u){const y=await this.getImage(u),p=y.fileDirectory.getValue("SubfileType"),w=y.fileDirectory.getValue("NewSubfileType");(u===0||p===2||(w||0)&1)&&g.push(y)}g.sort((u,y)=>u.getWidth()-y.getWidth());for(let u=0;u<g.length;++u){const y=g[u],p=(c[2]-c[0])/y.getWidth(),w=(c[3]-c[1])/y.getHeight();if(f=y,i&&i>p||n&&n>w)break}}let h=t;if(o){const[g,u]=a.getOrigin(),[y,p]=f.getResolution(a);h=[Math.round((o[0]-g)/y),Math.round((o[1]-u)/p),Math.round((o[2]-g)/y),Math.round((o[3]-u)/p)],h=[Math.min(h[0],h[2]),Math.min(h[1],h[3]),Math.max(h[0],h[2]),Math.max(h[1],h[3])]}return f.readRasters({...e,window:h})}},Er=class He extends Sr{constructor(t,r,s,i,n={}){super(),this.source=t,this.parser=new Ar(t,r,s,!1),this.littleEndian=r,this.bigTiff=s,this.firstIFDOffset=i,this.cache=n.cache||!1,this.ifdRequests=[],this.ghostValues=null}async getSlice(t,r){const s=this.bigTiff?4048:1024;return new Q((await this.source.fetch([{offset:t,length:typeof r<"u"?r:s}]))[0],t,this.littleEndian,this.bigTiff)}async requestIFD(t){if(this.ifdRequests[t])return this.ifdRequests[t];if(t===0)return this.ifdRequests[t]=this.parser.parseFileDirectoryAt(this.firstIFDOffset),this.ifdRequests[t];if(!this.ifdRequests[t-1])try{this.ifdRequests[t-1]=this.requestIFD(t-1)}catch(r){throw r instanceof Z?new Z(t):r}return this.ifdRequests[t]=(async()=>{const r=this.ifdRequests[t-1];if(!r)throw new Error("Previous IFD request missing");const s=await r;if(s.nextIFDByteOffset===0)throw new Z(t);return this.parser.parseFileDirectoryAt(s.nextIFDByteOffset)})(),this.ifdRequests[t]}async getImage(t=0){return new Jt(await this.requestIFD(t),this.littleEndian,this.cache,this.source)}async getImageCount(){let t=0,r=!0;for(;r;)try{await this.requestIFD(t),++t}catch(s){if(s instanceof Z)r=!1;else throw s}return t}async getGhostValues(){const t=this.bigTiff?16:8;if(this.ghostValues!==null)return this.ghostValues;const r="GDAL_STRUCTURAL_METADATA_SIZE=",s=130;let i=await this.getSlice(t,s);if(r===ae(i,d.fieldTypes.ASCII,30,t)){const n=ae(i,d.fieldTypes.ASCII,s,t).split(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cn as it, on as at } from "./ControlGrid-
|
|
1
|
+
import { cn as it, on as at } from "./ControlGrid-V59Ovz6J.js";
|
|
2
2
|
import "./basedecoder-BliCKuUS.js";
|
|
3
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
4
|
var lt = "Cannot convert undefined or null to object";
|
|
@@ -241,7 +241,7 @@ var Xt = [
|
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
243
|
cases: 34887,
|
|
244
|
-
importFn: () => import("./lerc-
|
|
244
|
+
importFn: () => import("./lerc-DZUVO3mM.js").then(async (e) => (await e.zstd.init(), e)).then((e) => e.default),
|
|
245
245
|
decoderParameterFn: async (e) => ({
|
|
246
246
|
...await ee(e),
|
|
247
247
|
LercParameters: await e.loadValue("LercParameters")
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ControlGrid-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ControlGrid-BWs3QP5M.cjs"),S=require("./DuckDBConverter-D-Von6Le.cjs"),d=require("./ShapefileConverter-wLF296OF.cjs");let i=require("maplibre-gl");i=e.__toESM(i,1);let n=require("@dvt3d/maplibre-three-plugin");var C=["globe","spinGlobe","fullscreen","north","terrain","search","viewState","inspect","vectorDataset","basemap","tileLayer","measure","geoEditor","bookmark","print","minimap","swipe","colorbarGui","legendGui","htmlGui","streetView","addVector","choropleth","cogLayer","zarrLayer","pmtilesLayer","stacLayer","stacSearch","planetaryComputer","gaussianSplat","lidar","usgsLidar"],E=["usgs-lidar-*","lidar-*","mapbox-gl-draw-*","gl-draw-*","gm_*","inspect-highlight-*","measure-*"];function m(o){if(o<=0)return{rows:1,columns:1};const t=Math.ceil(Math.sqrt(o));return{rows:Math.ceil(o/t),columns:t}}function u(o,t){const{exclude:c,...r}=t??{};if(r.defaultControls===void 0){const a=new Set(c??[]);r.defaultControls=C.filter(p=>!a.has(p))}const l=r.defaultControls.length;if(r.rows===void 0&&r.columns===void 0){const a=m(l);r.rows=a.rows,r.columns=a.columns}else r.rows===void 0&&r.columns!==void 0?r.rows=Math.ceil(l/r.columns):r.columns===void 0&&r.rows!==void 0&&(r.columns=Math.ceil(l/r.rows));r.position??="top-right",r.collapsible??=!0,r.collapsed??=!0,r.showRowColumnControls??=!0,r.gap??=2,r.excludeLayers??=[...E];const s=new e.ControlGrid(r);return o.addControl(s,r.position),s}function N(o){o.prototype.addControlGrid||(o.prototype.addControlGrid=function(t){return u(this,t)})}N(i.default.Map);exports.ADVANCED_EXTENSIONS=e.ADVANCED_EXTENSIONS;exports.ALL_DEFAULT_CONTROLS=C;exports.ALL_EXTENSIONS=e.ALL_EXTENSIONS;exports.AddVectorAdapter=e.AddVectorAdapter;exports.AddVectorControl=e.AddVectorControl;exports.BasemapControl=e.BasemapControl;exports.BookmarkControl=e.BookmarkControl;exports.COLORMAPS=e.COLORMAPS;exports.CSV_EXTENSIONS=e.CSV_EXTENSIONS;exports.ChoroplethControl=e.ChoroplethControl;exports.CogLayerAdapter=e.CogLayerAdapter;exports.CogLayerControl=e.CogLayerControl;exports.Colorbar=e.Colorbar;exports.ColorbarGuiControl=e.ColorbarGuiControl;exports.ControlGrid=e.ControlGrid;Object.defineProperty(exports,"Creator",{enumerable:!0,get:function(){return n.Creator}});exports.DEFAULT_EXCLUDE_LAYERS=E;exports.DUCKDB_EXTENSIONS=e.DUCKDB_EXTENSIONS;exports.DXF_EXTENSIONS=e.DXF_EXTENSIONS;exports.DuckDBConverter=S.DuckDBConverter;exports.FLATGEOBUF_EXTENSIONS=e.FLATGEOBUF_EXTENSIONS;exports.GEOJSON_EXTENSIONS=e.GEOJSON_EXTENSIONS;exports.GEOPACKAGE_EXTENSIONS=e.GEOPACKAGE_EXTENSIONS;exports.GEOPARQUET_EXTENSIONS=e.GEOPARQUET_EXTENSIONS;exports.GML_EXTENSIONS=e.GML_EXTENSIONS;exports.GOOGLE_BASEMAPS=e.GOOGLE_BASEMAPS;exports.GPX_EXTENSIONS=e.GPX_EXTENSIONS;exports.GaussianSplatControl=e.GaussianSplatControl;exports.GaussianSplatLayerAdapter=e.GaussianSplatLayerAdapter;exports.GeoEditor=e.GeoEditor;exports.GeoEditorLayerAdapter=e.GeoEditorLayerAdapter;exports.HtmlControl=e.HtmlControl;exports.HtmlGuiControl=e.HtmlGuiControl;exports.InspectControl=e.InspectControl;exports.KML_EXTENSIONS=e.KML_EXTENSIONS;exports.KMZ_EXTENSIONS=e.KMZ_EXTENSIONS;exports.Legend=e.Legend;exports.LegendGuiControl=e.LegendGuiControl;exports.LidarControl=e.LidarControl;exports.LidarLayerAdapter=e.LidarLayerAdapter;Object.defineProperty(exports,"MapScene",{enumerable:!0,get:function(){return n.MapScene}});exports.MeasureControl=e.MeasureControl;exports.MinimapControl=e.MinimapControl;exports.PMTilesLayerAdapter=e.PMTilesLayerAdapter;exports.PMTilesLayerControl=e.PMTilesLayerControl;exports.PlanetaryComputerControl=e.PlanetaryComputerControl;exports.PlanetaryComputerLayerAdapter=e.PlanetaryComputerLayerAdapter;exports.PrintControl=e.PrintControl;exports.RdBu=e.RdBu;exports.RdYlBu=e.RdYlBu;exports.RdYlGn=e.RdYlGn;exports.SHAPEFILE_EXTENSIONS=e.SHAPEFILE_EXTENSIONS;exports.SHPJS_EXTENSIONS=e.SHPJS_EXTENSIONS;Object.defineProperty(exports,"SceneTransform",{enumerable:!0,get:function(){return n.SceneTransform}});exports.SearchControl=e.SearchControl;exports.ShapefileConverter=d.ShapefileConverter;exports.SpinGlobeControl=e.SpinGlobeControl;exports.StacLayerAdapter=e.StacLayerAdapter;exports.StacLayerControl=e.StacLayerControl;exports.StacSearchControl=e.StacSearchControl;exports.StreetViewControl=e.StreetViewControl;Object.defineProperty(exports,"Sun",{enumerable:!0,get:function(){return n.Sun}});exports.SwipeControl=e.SwipeControl;exports.TOPOJSON_EXTENSIONS=e.TOPOJSON_EXTENSIONS;exports.TerrainControl=e.TerrainControl;exports.TileLayerControl=e.TileLayerControl;exports.UsgsLidarControl=e.UsgsLidarControl;exports.UsgsLidarLayerAdapter=e.UsgsLidarLayerAdapter;exports.VectorDatasetControl=e.VectorDatasetControl;exports.ViewStateControl=e.ViewStateControl;exports.XLSX_EXTENSIONS=e.XLSX_EXTENSIONS;exports.XYZSERVICES_URL=e.XYZSERVICES_URL;exports.ZarrLayerAdapter=e.ZarrLayerAdapter;exports.ZarrLayerControl=e.ZarrLayerControl;exports.addControlGrid=u;exports.bone=e.bone;exports.buildTileUrl=e.buildTileUrl;exports.bwr=e.bwr;exports.cividis=e.cividis;exports.clamp=e.clamp;exports.classNames=e.classNames;exports.cool=e.cool;exports.coolwarm=e.coolwarm;exports.debounce=e.debounce;exports.detectFormat=e.detectFormat;exports.fetchProviders=e.fetchProviders;exports.filterBasemaps=e.filterBasemaps;exports.formatNumericValue=e.formatNumericValue;exports.generateGradientCSS=e.generateGradientCSS;exports.generateId=e.generateId;exports.generateThumbnailUrl=e.generateThumbnailUrl;exports.getAcceptedExtensions=e.getAcceptedExtensions;exports.getColorAtPosition=e.getColorAtPosition;exports.getColormap=e.getColormap;exports.getColormapNames=e.getColormapNames;exports.getDuckDBConverter=S.getDuckDBConverter;exports.getFileExtension=e.getFileExtension;exports.getFormatDescription=e.getFormatDescription;exports.getFormatDisplayName=e.getFormatDisplayName;exports.getShapefileConverter=d.getShapefileConverter;exports.gray=e.gray;exports.groupBasemaps=e.groupBasemaps;exports.hexToRgb=e.hexToRgb;exports.hot=e.hot;exports.inferno=e.inferno;exports.interpolateColor=e.interpolateColor;exports.isValidColormap=e.isValidColormap;exports.isValidExtension=e.isValidExtension;exports.jet=e.jet;exports.magma=e.magma;exports.ocean=e.ocean;exports.parseProviders=e.parseProviders;exports.plasma=e.plasma;exports.rainbow=e.rainbow;exports.readFileAsBuffer=e.readFileAsBuffer;exports.requiresConversion=e.requiresConversion;exports.requiresDuckDB=e.requiresDuckDB;exports.rgbToHex=e.rgbToHex;exports.seismic=e.seismic;exports.spectral=e.spectral;exports.terrain=e.terrain;exports.throttle=e.throttle;exports.turbo=e.turbo;exports.viridis=e.viridis;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as E, $t as L, A as N, At as g, B as O, Bt as T, C as A, Ct as h, D as G, Dt as f, E as y, Et as w, F as _, Ft as X, G as I, Gt as b, H as v, Ht as D, I as P, It as M, J as B, Jt as V, K as F, Kt as R, L as U, Lt as x, M as k, Mt as H, N as K, Nt as Y, O as Z, Ot as q, P as J, Pt as j, Q as z, Qt as Q, R as W, Rt as $, S as aa, St as ta, T as ra, Tt as oa, U as sa, Ut as ea, V as na, Vt as ia, W as la, Wt as da, X as Sa, Xt as ca, Y as pa, Yt as Ca, Z as ma, Zt as ua, _ as Ea, _t as La, a as Na, an as ga, at as Oa, b as Ta, bt as Aa, c as ha, ct as Ga, d as fa, dt as ya, en as wa, et as _a, f as Xa, ft as Ia, g as ba, gt as va, h as Da, ht as Pa, i as Ma, in as Ba, it as Va, j as Fa, jt as Ra, k as Ua, kt as xa, l as ka, lt as Ha, m as Ka, mt as Ya, n as Za, nn as qa, nt as Ja, o as ja, ot as za, p as Qa, pt as Wa, q as $a, qt as at, r as tt, rn as rt, rt as ot, s as st, st as et, t as l, tn as nt, tt as it, u as lt, ut as dt, v as St, vt as ct, w as pt, wt as Ct, x as mt, xt as ut, y as Et, yt as Lt, z as Nt, zt as gt } from "./ControlGrid-
|
|
2
|
-
import { r as Tt, t as At } from "./DuckDBConverter-
|
|
3
|
-
import { r as Gt, t as ft } from "./ShapefileConverter-
|
|
1
|
+
import { $ as E, $t as L, A as N, At as g, B as O, Bt as T, C as A, Ct as h, D as G, Dt as f, E as y, Et as w, F as _, Ft as X, G as I, Gt as b, H as v, Ht as D, I as P, It as M, J as B, Jt as V, K as F, Kt as R, L as U, Lt as x, M as k, Mt as H, N as K, Nt as Y, O as Z, Ot as q, P as J, Pt as j, Q as z, Qt as Q, R as W, Rt as $, S as aa, St as ta, T as ra, Tt as oa, U as sa, Ut as ea, V as na, Vt as ia, W as la, Wt as da, X as Sa, Xt as ca, Y as pa, Yt as Ca, Z as ma, Zt as ua, _ as Ea, _t as La, a as Na, an as ga, at as Oa, b as Ta, bt as Aa, c as ha, ct as Ga, d as fa, dt as ya, en as wa, et as _a, f as Xa, ft as Ia, g as ba, gt as va, h as Da, ht as Pa, i as Ma, in as Ba, it as Va, j as Fa, jt as Ra, k as Ua, kt as xa, l as ka, lt as Ha, m as Ka, mt as Ya, n as Za, nn as qa, nt as Ja, o as ja, ot as za, p as Qa, pt as Wa, q as $a, qt as at, r as tt, rn as rt, rt as ot, s as st, st as et, t as l, tn as nt, tt as it, u as lt, ut as dt, v as St, vt as ct, w as pt, wt as Ct, x as mt, xt as ut, y as Et, yt as Lt, z as Nt, zt as gt } from "./ControlGrid-V59Ovz6J.js";
|
|
2
|
+
import { r as Tt, t as At } from "./DuckDBConverter-BiaCHtYV.js";
|
|
3
|
+
import { r as Gt, t as ft } from "./ShapefileConverter-CWtJ9IOJ.js";
|
|
4
4
|
import d from "maplibre-gl";
|
|
5
5
|
import { Creator as _t, MapScene as Xt, SceneTransform as It, Sun as bt } from "@dvt3d/maplibre-three-plugin";
|
|
6
6
|
var S = [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cn as DA, on as aA } from "./ControlGrid-
|
|
1
|
+
import { cn as DA, on as aA } from "./ControlGrid-V59Ovz6J.js";
|
|
2
2
|
import { t as sA } from "./pako.esm-hTfpTBhd.js";
|
|
3
3
|
import { t as eA } from "./basedecoder-BliCKuUS.js";
|
|
4
4
|
import { n as gA, r as rA } from "./globals-BKIWameS.js";
|