maplibre-gl-raster 0.14.7 → 0.14.8
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.
|
@@ -18151,6 +18151,38 @@ function deriveLayerName(source) {
|
|
|
18151
18151
|
}
|
|
18152
18152
|
//#endregion
|
|
18153
18153
|
//#region src/lib/state/CogTilerEngine.ts
|
|
18154
|
+
/** Convert cog-tiler's TiTiler-style statistics into the panel's 128-bin shape. */
|
|
18155
|
+
function fromCogStatistics(raw) {
|
|
18156
|
+
const perBand = /* @__PURE__ */ new Map();
|
|
18157
|
+
for (const [key, stats] of Object.entries(raw)) {
|
|
18158
|
+
const band = Number(key.replace(/^b/, ""));
|
|
18159
|
+
if (!Number.isInteger(band) || !Number.isFinite(stats.min) || !Number.isFinite(stats.max)) continue;
|
|
18160
|
+
const histogram = new Array(128).fill(0);
|
|
18161
|
+
const counts = stats.histogram?.[0] ?? [];
|
|
18162
|
+
for (let i = 0; i < counts.length; i++) {
|
|
18163
|
+
const target = Math.min(127, Math.floor((i + .5) / counts.length * 128));
|
|
18164
|
+
histogram[target] += counts[i] ?? 0;
|
|
18165
|
+
}
|
|
18166
|
+
perBand.set(band, {
|
|
18167
|
+
min: stats.min,
|
|
18168
|
+
max: stats.max,
|
|
18169
|
+
histogram
|
|
18170
|
+
});
|
|
18171
|
+
}
|
|
18172
|
+
const values = [...perBand.values()];
|
|
18173
|
+
if (values.length === 0) return {
|
|
18174
|
+
perBand: null,
|
|
18175
|
+
global: null
|
|
18176
|
+
};
|
|
18177
|
+
return {
|
|
18178
|
+
perBand,
|
|
18179
|
+
global: {
|
|
18180
|
+
min: values.reduce((sum, s) => sum + s.min, 0) / values.length,
|
|
18181
|
+
max: values.reduce((sum, s) => sum + s.max, 0) / values.length,
|
|
18182
|
+
histogram: values[0].histogram.map((_, i) => values.reduce((sum, s) => sum + (s.histogram[i] ?? 0), 0))
|
|
18183
|
+
}
|
|
18184
|
+
};
|
|
18185
|
+
}
|
|
18154
18186
|
/**
|
|
18155
18187
|
* The colormaps assumed renderable before the wasm module has loaded.
|
|
18156
18188
|
*
|
|
@@ -18556,6 +18588,10 @@ var CogTilerEngine = class {
|
|
|
18556
18588
|
east: b[2],
|
|
18557
18589
|
north: b[3]
|
|
18558
18590
|
}, layer.zoomTo);
|
|
18591
|
+
if (typeof source.statistics === "function") source.statistics().then((stats) => {
|
|
18592
|
+
if (this._destroyed || this._sources.get(layer.id) !== entry) return;
|
|
18593
|
+
this._deps.onStats?.(layer.id, fromCogStatistics(stats));
|
|
18594
|
+
}, () => {});
|
|
18559
18595
|
this._apply();
|
|
18560
18596
|
}, (err) => {
|
|
18561
18597
|
if (this._destroyed || this._sources.get(layer.id) !== entry) return;
|
|
@@ -19961,6 +19997,16 @@ var LayerManager = class {
|
|
|
19961
19997
|
if (!this._cogEngine) this._cogEngine = new CogTilerEngine(this._map, {
|
|
19962
19998
|
loadModule: this._deps.loadCogTiler,
|
|
19963
19999
|
onBounds: (id, bounds, zoomTo) => this._onCogBounds(id, bounds, zoomTo),
|
|
20000
|
+
onStats: (id, stats) => {
|
|
20001
|
+
const layer = this.getLayer(id);
|
|
20002
|
+
if (!layer || this._engine !== "cog-tiler-wasm") return;
|
|
20003
|
+
layer.autoStats = stats;
|
|
20004
|
+
this._rebuild();
|
|
20005
|
+
this._emit({
|
|
20006
|
+
type: "rasterchange",
|
|
20007
|
+
layerId: id
|
|
20008
|
+
});
|
|
20009
|
+
},
|
|
19964
20010
|
onError: (id, error) => this._onCogError(id, error),
|
|
19965
20011
|
onReady: () => this._emit({ type: "rasterchange" })
|
|
19966
20012
|
});
|
|
@@ -20111,6 +20157,7 @@ var LayerManager = class {
|
|
|
20111
20157
|
*/
|
|
20112
20158
|
_computeStats(layer) {
|
|
20113
20159
|
if (!layer.geotiff) return;
|
|
20160
|
+
if (this._engine === "cog-tiler-wasm") return;
|
|
20114
20161
|
const signal = layer.abort.signal;
|
|
20115
20162
|
const apply = (stats) => {
|
|
20116
20163
|
if (signal.aborted || this._destroyed) return;
|
|
@@ -23146,4 +23193,4 @@ var RasterControl = class {
|
|
|
23146
23193
|
//#endregion
|
|
23147
23194
|
export { Photometric as $, DEFAULT_TITILER_ENDPOINT as A, COLORMAP_ROW_COUNT as B, throttle as C, loadVrt as D, isVrtUrl as E, loadColormapSprite as F, statsForBand as G, colormaps_default as H, sampleColormapStops as I, mergeAutoStats as J, MAX_SAMPLE_TILES as K, COLORMAP_DISPLAY_NAMES as L, isMosaicJsonUrl as M, PALETTE_COLORMAP as N, parseVrt as O, isKnownColormap as P, Compression as Q, COLORMAP_NAMES as R, generateId as S, isVrtFile as T, DEFAULT_INDEX_RANGE as U, colormapDisplayName as V, autoRangeFor as W, percentileFromHistogram as X, mergeBandStats as Y, readBandNames as Z, parseMosaic as _, NORMALIZED_DIFFERENCE_INDICES as a, debounce as b, readPixelValues as c, MAX_MOSAIC_ASSETS as d, PlanarConfiguration as et, MosaicUnsupportedError as f, mosaicMinZoom as g, mosaicInitialView as h, CUSTOM_NORMALIZED_DIFFERENCE as i, createResilientEpsgResolver as it, TITILER_TMS as j, loadGeoTIFF as k, DEFAULT_ENGINE as l, loadMosaic as m, Colorbar as n, SampleFormat as nt, guessBandForRole as o, assetUrlToHttps as p, computeAutoStats as q, CUSTOM_INDEX_ID as r, TiffTag as rt, indexById as s, RasterControl as t, Predictor as tt, LayerManager as u, clamp as v, VrtUnsupportedError as w, formatNumericValue as x, classNames as y, COLORMAP_OPTIONS as z };
|
|
23148
23195
|
|
|
23149
|
-
//# sourceMappingURL=RasterControl-
|
|
23196
|
+
//# sourceMappingURL=RasterControl-BiPVKYvs.js.map
|