maplibre-gl-raster 0.14.9 → 0.14.10

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,18 +18151,35 @@ function deriveLayerName(source) {
18151
18151
  }
18152
18152
  //#endregion
18153
18153
  //#region src/lib/state/CogTilerEngine.ts
18154
+ /** Resample histogram buckets by their covered interval, preserving the total.
18155
+ * Point-mapping a short histogram leaves artificial empty gaps between bars. */
18156
+ function resampleHistogram(counts, targetBins = 128) {
18157
+ const output = new Array(targetBins).fill(0);
18158
+ if (counts.length === 0) return output;
18159
+ if (counts.length === targetBins) return counts.slice();
18160
+ const sourceWidth = 1 / counts.length;
18161
+ const targetWidth = 1 / targetBins;
18162
+ for (let source = 0; source < counts.length; source++) {
18163
+ const count = counts[source] ?? 0;
18164
+ if (!Number.isFinite(count) || count === 0) continue;
18165
+ const sourceStart = source * sourceWidth;
18166
+ const sourceEnd = (source + 1) * sourceWidth;
18167
+ const firstTarget = Math.floor(sourceStart * targetBins);
18168
+ const lastTarget = Math.min(targetBins - 1, Math.ceil(sourceEnd * targetBins) - 1);
18169
+ for (let target = firstTarget; target <= lastTarget; target++) {
18170
+ const overlap = Math.max(0, Math.min(sourceEnd, (target + 1) * targetWidth) - Math.max(sourceStart, target * targetWidth));
18171
+ output[target] += count * (overlap / sourceWidth);
18172
+ }
18173
+ }
18174
+ return output;
18175
+ }
18154
18176
  /** Convert cog-tiler's TiTiler-style statistics into the panel's 128-bin shape. */
18155
18177
  function fromCogStatistics(raw) {
18156
18178
  const perBand = /* @__PURE__ */ new Map();
18157
18179
  for (const [key, stats] of Object.entries(raw)) {
18158
18180
  const band = Number(key.replace(/^b/, ""));
18159
18181
  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
- }
18182
+ const histogram = resampleHistogram(stats.histogram?.[0] ?? []);
18166
18183
  perBand.set(band, {
18167
18184
  min: stats.min,
18168
18185
  max: stats.max,
@@ -23207,4 +23224,4 @@ var RasterControl = class {
23207
23224
  //#endregion
23208
23225
  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 };
23209
23226
 
23210
- //# sourceMappingURL=RasterControl-CPtuFlxg.js.map
23227
+ //# sourceMappingURL=RasterControl-CYfq9zmh.js.map