maplibre-gl-raster 0.14.3 → 0.14.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.
@@ -4,7 +4,7 @@ import { PathLayer, PolygonLayer, TextLayer } from "@deck.gl/layers";
4
4
  import { CompositeLayer, _GlobeViewport, assert } from "@deck.gl/core";
5
5
  import { SimpleMeshLayer } from "@deck.gl/mesh-layers";
6
6
  import { TileLayer, _Tileset2D } from "@deck.gl/geo-layers";
7
- import maplibregl, { Popup } from "maplibre-gl";
7
+ import { Popup, addProtocol, removeProtocol } from "maplibre-gl";
8
8
  //#region node_modules/@developmentseed/proj/dist/meters-per-unit.js
9
9
  /**
10
10
  * Coefficient to convert the coordinate reference system (CRS)
@@ -2043,12 +2043,27 @@ async function computeAutoStats(tiff, signal, onProgress) {
2043
2043
  /** Discards pixels whose red channel is NaN. Float32 COGs commonly use
2044
2044
  * NaN as the nodata sentinel, but the upstream `FilterNoDataVal` does an
2045
2045
  * `==` comparison which IEEE 754 says is always false for NaN. Use this
2046
- * module instead when the COG's declared nodata value is NaN. */
2046
+ * module instead when the COG's declared nodata value is NaN.
2047
+ *
2048
+ * The test is a raw IEEE-754 bit-pattern check (exponent all ones and a
2049
+ * non-zero mantissa) rather than the GLSL `isnan()` intrinsic. `isnan()` is
2050
+ * unreliable on ANGLE's Direct3D 11 backend — the default on Windows for both
2051
+ * Chrome and the Tauri/WebView2 desktop shell — where the HLSL compiler is
2052
+ * free to fold it to a constant `false` under fast-math assumptions, so NaN
2053
+ * nodata rendered as an opaque colormap border instead of a transparent gap
2054
+ * (opengeos/maplibre-gl-raster#64). `floatBitsToUint` lowers to HLSL `asuint`,
2055
+ * a pure reinterpret with no float arithmetic for the optimizer to remove, so
2056
+ * the check survives on every backend. `float != float` is *not* a safe
2057
+ * substitute: it is the exact comparison those same fast-math passes drop. */
2047
2058
  var FilterNaN = {
2048
2059
  name: "filterNaN",
2049
2060
  inject: { "fs:DECKGL_FILTER_COLOR": `
2050
- if (isnan(color.r)) {
2051
- discard;
2061
+ {
2062
+ uint filterNaNBits = floatBitsToUint(color.r);
2063
+ if ((filterNaNBits & 0x7f800000u) == 0x7f800000u &&
2064
+ (filterNaNBits & 0x007fffffu) != 0u) {
2065
+ discard;
2066
+ }
2052
2067
  }
2053
2068
  ` }
2054
2069
  };
@@ -2226,7 +2241,8 @@ function effectiveNodata(state, perTileNodata) {
2226
2241
  /** Build the nodata-discard module appropriate for the chosen value.
2227
2242
  * Float32 COGs frequently use NaN as the nodata sentinel; FilterNoDataVal's
2228
2243
  * `color.r == nodata` comparison is always false for NaN per IEEE 754, so
2229
- * we route NaN nodata through a custom isnan() shader instead. */
2244
+ * we route NaN nodata through the custom bit-pattern FilterNaN shader
2245
+ * instead. */
2230
2246
  function nodataModule(nodata, sampleScale) {
2231
2247
  if (Number.isNaN(nodata)) return { module: FilterNaN };
2232
2248
  if (!Number.isFinite(nodata)) return null;
@@ -2272,7 +2288,7 @@ function pickMapping(data, requested, mode) {
2272
2288
  /** Push the nodata-discard modules for a tile, in the correct order. Filters
2273
2289
  * nodata BEFORE any rescale / gamma / colormap so the comparison happens
2274
2290
  * against the texture's native sample value. NaN nodata uses the custom
2275
- * isnan() shader; everything else uses FilterNoDataVal with the value
2291
+ * FilterNaN shader; everything else uses FilterNoDataVal with the value
2276
2292
  * normalized into the GPU's sample space (uint8 255 → 1.0 for r8unorm). Also
2277
2293
  * applies implicit NaN-as-nodata for float COGs — IEEE-754 NaN is invalid by
2278
2294
  * definition, and GDAL/QGIS treat it as transparent even when the file
@@ -19391,7 +19407,7 @@ var CogTilerEngine = class {
19391
19407
  this.clear();
19392
19408
  if (this._protocolRegistered) {
19393
19409
  try {
19394
- maplibregl.removeProtocol(this._protocol);
19410
+ removeProtocol(this._protocol);
19395
19411
  } catch {}
19396
19412
  this._protocolRegistered = false;
19397
19413
  }
@@ -19446,7 +19462,7 @@ var CogTilerEngine = class {
19446
19462
  }
19447
19463
  _ensureProtocol() {
19448
19464
  if (this._protocolRegistered) return;
19449
- maplibregl.addProtocol(this._protocol, (async (params) => ({ data: await this._handleTile(params.url) })));
19465
+ addProtocol(this._protocol, (async (params) => ({ data: await this._handleTile(params.url) })));
19450
19466
  this._protocolRegistered = true;
19451
19467
  }
19452
19468
  /** Protocol handler: parse `<scheme>://<layerId>/<z>/<x>/<y>` and render the
@@ -24204,4 +24220,4 @@ var RasterControl = class {
24204
24220
  //#endregion
24205
24221
  export { 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, createResilientEpsgResolver 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, MosaicUnsupportedError as f, mosaicMinZoom as g, mosaicInitialView as h, CUSTOM_NORMALIZED_DIFFERENCE as i, TITILER_TMS as j, loadGeoTIFF as k, DEFAULT_ENGINE as l, loadMosaic as m, Colorbar as n, guessBandForRole as o, assetUrlToHttps as p, computeAutoStats as q, CUSTOM_INDEX_ID as r, indexById as s, RasterControl as t, LayerManager as u, clamp as v, VrtUnsupportedError as w, formatNumericValue as x, classNames as y, COLORMAP_OPTIONS as z };
24206
24222
 
24207
- //# sourceMappingURL=RasterControl-Bem7j-bZ.js.map
24223
+ //# sourceMappingURL=RasterControl-BgzJWA7T.js.map